Ubuntu – How to store /var on a separate partition

mountpartitioning

I'd like to store /var on a separate partition from /. What is the correct way to set this up?

Best Answer

First prepare a new partition (e.g. with parted and mkfs).

Say the partition is /dev/sda5

Mount the new partition:

mkdir /var2
mount /dev/sda5 /var2

Sync your current var:

rsync -a /var/ /var2

Add the entry to /etc/fstab

/dev/sda5    /var    ext4    defaults      2 2

Reboot.

If you happen to need to go back you your old /var just comment out the entry in fstab.

Related Question