FreeBSD Move /usr or /var File System To Another Hard Disk

In FreeBSD, it is possible to move the /usr or /var file systems to another hard disk. The steps below will guide you through the process:

  1. Backup the contents of the /usr or /var file system to the new hard disk. You can use rsync for this purpose:
    sudo rsync -avz /usr /mnt/new_disk

    In the above command, replace /usr with /var if you are moving the /var file system. Replace /mnt/new_disk with the mount point of the new hard disk.

  2. Unmount the old /usr or /var file system:
    sudo umount /usr

    In the above command, replace /usr with /var if you are moving the /var file system.

  3. Edit the /etc/fstab file and change the mount point of the /usr or /var file system to the new hard disk:
    # Before
    /dev/ada0p3 /usr ufs rw 2 2

    # After
    /dev/ada1p3 /usr ufs rw 2 2

    In the above example, /dev/ada0p3 is the old partition and /dev/ada1p3 is the new partition. Replace /usr with /var if you are moving the /var file system.

  4. Mount the new /usr or /var file system:
    sudo mount /usr

    In the above command, replace /usr with /var if you are moving the /var file system.

  5. Reboot the system to ensure that the new file system is mounted correctly:
    sudo reboot

    After the system has restarted, verify that the new file system is mounted correctly:

    df -h

    The output should show the new mount point for /usr or /var.

    Note: If you encounter any issues during this process, it is recommended to boot the system from an installation disk or a recovery disk to make the changes.

(https://www.tnsdiamonds.com/)

Leave a Comment