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

Recommend readings:

  • man pages dump, fstab, mount, restore

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • kouta May 9, 2009 @ 13:18

    Awww.. /usr has nothing to do with “user”.. It’s “Unix System Ressources”.

  • uvs May 19, 2009 @ 0:28

    when i type # mount /dev/ad1s1 /new
    it returns a ‘mount: /dev/ad1s1 invalid argument’ error.

    • 🐧 nixCraft May 19, 2009 @ 0:44

      Make sure /dev/ad1s1 exists and formatted.

  • indexofire May 21, 2009 @ 1:43

    you can use fdisk, bsdlabel & newfs without sysinstall
    # fdisk -BIq /dev/ad1
    # bsdlabel -w -B /dev/ad1s1 auto
    # newfs /dev/ad1s1a
    # mount /dev/ad1s1a /mnt

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum