Skip to content

Instantly share code, notes, and snippets.

@iambryancs
Created June 5, 2023 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iambryancs/c44639325194eb179308717c6e631c1b to your computer and use it in GitHub Desktop.
Save iambryancs/c44639325194eb179308717c6e631c1b to your computer and use it in GitHub Desktop.
Move /var to another partition in Ubuntu

Move /var to another partition in Ubuntu

Create partition with fdisk or gparted

fdisk /dev/sdb
...
...

Create fs

Assuming target fs is ext4 and device is /dev/sdb1

mkfs.ext4 /dev/sdb1

Create temp mount point

mkdir /var2

Mount partition to temp mount point

mount /dev/sdb1 /var2

Copy current /var content to new

rsync -a /var/ /var2

Get UUID

Run blkid and copy the UUID of /dev/sdb1

Add /etc/fstab

UUID="<UUID from previous step>" /var ext4 defaults 0 2

Post

You can cleanup the old /var to free up space by mounting / to another location using a LiveCD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment