Move /var to new disk

May 18th, 2024 – 4:40 am
Categorized as Computing Note and tagged as
Written by La Ecrivain

To add a new virtual disk and move the existing Linux partition to the new disk use the following process. The process assumes standard partitions without the use of Logical Volume Manager (LVM).

1. Backup the existing VM. One good way to do that is to clone the Virtual Machine and use the procedure on the new Virtual Machine.

2. Create the partition and format it.

$ mount /dev/sbd /mnt
$ shopt -s dotglob
$ rsync -aulvXpogtr /var/* /mnt
$ nano /etc/fstab

Add this line, replacing sdb and ext4 as necessary:

/dev/sdb /var ext4 defaults,noatime,nofail 0 2

Then

$ mv /var/ /var.old

Reboot and enjoy the new drive.