Skip to content

Instantly share code, notes, and snippets.

@Th3On3
Forked from iambryancs/move-var-part-ubuntu.md
Created November 26, 2024 16:05
Show Gist options
  • Save Th3On3/9f6e8bfa9c375ea10fd6e8e33a28039a to your computer and use it in GitHub Desktop.
Save Th3On3/9f6e8bfa9c375ea10fd6e8e33a28039a 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