Skip to content

Instantly share code, notes, and snippets.

@iain17
Created August 6, 2017 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iain17/585495d6637c79390bb70011d5e273f8 to your computer and use it in GitHub Desktop.
Save iain17/585495d6637c79390bb70011d5e273f8 to your computer and use it in GitHub Desktop.
move var directory to different disk
  1. Find the disk

lsblk

2.Then create a filesystem on it

sudo mkfs.ext4 /dev/vdb

3.Mount the new filesystem under /mnt

sudo mkdir /mnt/var
sudo mount /dev/vdb /mnt/var

4.Copy the data

cd /var
sudo cp -ax * /mnt/var

5.Rename the old var (for the time being)

cd /
sudo mv var var.old
sudo mkdir var
  1. Unmount and remount as /var
sudo umount /dev/vdb
sudo mount /dev/vdb /var

#Edit /etc/fstab file to include the new partition, with /var being the mount point, so that it will be automatically mounted at boot.

/dev/vdb       /var     ext4    defaults    0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment