Thursday, May 3, 2012

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

My current /usr file system was full, so I ended up adding a new disk to my FreeBSD server. I've created a new partition at /dev/ad6s1 (size is 250G). How do I move my /usr file system over to my huge new disk at /dev/ad6s1?

First, you need to partition and label the new disk with either sysinstall, or fdisk and disklabel. The procedure to add a new hard disk under FreeBSD is discussed here.
Once new disk added, create a temporary mount point to mount your /dev/ad6s1, enter:
# mkdir /newuser
Reboot and drop system to a signal user mode to migrate to a new disk:
# reboot
At boot prompt type:
# boot -s
Mount all file systems:
# mount -a -t ufs
Mount new /newuser file system:
# mount /dev/ad6s1 /newuser
Copy old /usr to /newuser:
# cd /newuser
# dump 0af - /usr | restore rf -

Sample outputs:
Fig.01: FreeBSD Copy /usr To New Disk Using dump Command
Fig.01: FreeBSD Copy /usr To New Disk Using dump Command

Open /etc/fstab, enter:
# vi /etc/fstab
Modify /usr entry to point to a new location:
/dev/ad6s1     /usr    ufs  rw   2  2
Save and close the file. Reboot the server:
# reboot
Make sure everything is working fine after reboot:
# df -H
# tail -f /var/log/messages

No comments:

Post a Comment