How to move var directory to another partition - Stepulin/general GitHub Wiki

How to move /var directory to another partition

Check if you target location has an existing parition (If not, see the bottom of the page)

lsblk && blkid

You will get something like this

# blkid | grep sdc1
/dev/sdc1: UUID="1de46881-1f49-440e-89dd-6c32592491a7" TYPE="ext4" PARTUUID="652a2fee-01"

Create a new mount point and mount your new partition

mkdir /mnt/newvar
mount /dev/sdXY /mnt/newvar

Confirm that it is mounted correctly

df -h /mnt/newvar

Copy current /var data to the new location

rsync -aqxP /var/* /mnt/newvar

Unmount new partition:

umount /mnt/newvar/ /mnt/var/

Edit your /etc/fstab to include new partition and choosing a relevant file-system

UUID=1de46881-1f49-440e-89dd-6c32592491a7 /var ext4 defaults 0 2

Reboot your system and you are done.Confirm that everything is working correctly and optionally remove old var directory by booting to some Live Linux system etc.

reboot

Source: https://linuxconfig.org/how-to-move-var-directory-to-another-partition


Creating a partition

Choose the disk base on previous command lsblk and use either fdisk or parted

fdisk /dev/sdX

Source: https://help.ubuntu.com/community/InstallingANewHardDrive