How to store /var on a separate partition

UbuntuWhat is the correct way to store /var on a separate partition?

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

For example, let’s create a new partition in fdisk:

then choose n for the new partition and go through configuration steps.
choose w at the end to write changes to a disk.

Now format the newly created partition.
Say the partition is /dev/vda3:


Now you are ready to mount your partition:

and sync your current /var:


Make sure all data is copied to /mnt, pay special attention that soft links are preserved.
Cleanup the current /var : for example delete logs, spool data and so on to free up some space.

Now you are ready to add the entry to /etc/fstab:

and reboot.

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

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com