Ask Your Question

F20 - How do I safely move /var to another partition?

asked 2014-01-04 08:12:50 -0500

Yarjon gravatar image

My boot partition is an small sized SSD drive, I would like to move /var to another partition with more available space.

what step should I take ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-01-04 12:06:33 -0500

Marc lml gravatar image

updated 2014-01-04 12:31:58 -0500

Create the new partition with fdisk and mkfs.ext4. In the example below I use /dev/sdb1 as the new var.

Boot the live DVD.

Mount the root partition.

mkdir /mnt/root
mount /dev/sda1 /mnt/root/

Mount the new var partition.

mkdir /mnt/newvar
mount /dev/sdb1 /mnt/newvar/

Copy the content of var.

cd /mnt/root/var/
cp -R * /mnt/newvar/

Make a backup of fstab

cp /mnt/root/etc/fstab /mnt/root/etc/

Find the UUID of your partition first.

ls -l /dev/disk/by-uuid/

The output for my /dev/sdb1 is this.

lrwxrwxrwx. 1 root root 10 Jan  4 19:22 d14dd2ef-aa15-488b-8aed-83578158787e -> ../../sdb1

Edit /mnt/root/etc/fstab and add this line. Fill in your own UUID.

UUID=d14dd2ef-aa15-488b-8aed-83578158787e   /var    ext4    defaults    0 0

You can do this by running this command for d14dd2ef-aa15-488b-8aed-83578158787e

sed -i '$a UUID=d14dd2ef-aa15-488b-8aed-83578158787e\t/var\text4\tdefaults\t0 0' /mnt/root/etc/fstab

Rename the old var

mv /mnt/root/var/ /mnt/root/var_old/

Make a new var

mkdir /mnt/root/var

Unmount the partitions

umount /mnt/root/
umount /mnt/newvar/

Reboot and boot from your harddisk.

If everything works as expected then you can remove the old var.

rm -rf /var_old/
edit flag offensive delete link more


This is an excellent answer, but it would probably be better to use a UUID instead of /dev/sdb1 to prevent future problems. Do you mind updating your question?

randomuser gravatar imagerandomuser ( 2014-01-04 12:12:37 -0500 )edit

No problem. Done. :)

Marc lml gravatar imageMarc lml ( 2014-01-04 12:33:33 -0500 )edit

Awesome! If I could give you karma harder, I would :)

randomuser gravatar imagerandomuser ( 2014-01-04 12:44:12 -0500 )edit

Thank you - I found the instructions were easy to follow. I discovered that I also needed a cp -pR /mnt/root/var_old /mnt/newvar/ to get my X windows and boinc running again as there were some complicated group permissions in those /var subfolders

HeyBig gravatar imageHeyBig ( 2014-10-24 17:04:03 -0500 )edit

Question Tools


Asked: 2014-01-04 08:12:50 -0500

Seen: 7,994 times

Last updated: Jan 04 '14