Unix & Linux: Moving /var, /home to separate partition (4 Solutions!!)

Опубликовано: 28 Июль 2026
на канале: Roel Van de Paar
548
4

👉 https://amzn.to/4aLHbLD 👈 You’re literally one click away from a better setup — grab it now! 🚀👑

As an Amazon Associate I earn from qualifying purchases. Unix & Linux: Moving /var, /home to separate partition


The Question: I am attempting to move some folders (such as /var and /home) to a separate
partition after reading this guide:
http://www.debian.org/doc/manuals/sec...
I was able to move one folder successfully following http://blog.oshim.net/
2011/10/how-to-move-var-folder-to-new-partition.htmlguide.
However, it doesn't seem to work for multiple folders, and all my folders are
dumped into the partition without proper folders.
I would like to mount /var, /home, and /tmp onto the separate partition; can
someone guide me on this?

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 77 people ==
1. First you need some unallocated space to create the partitions for each
mountpoint (/var, /home, /tmp). Use Gparted for this.
2. Then you need to create the filesystems for those partitions (can be done
with Gparted too) or use:
mkfs.ext4 /dev/sdaX
for example to create a new ext4 filesystem on the /dev/sdaX device (replace /
dev/sdaX with your own device)
3. Mount the new filesystem under /mnt
mkdir /mnt/var
mount /dev/sdaX /mnt/var
4. Go to single-user mode so that there is no rw activity on the directory
during the process
init 1
5. Enter your root password.
6. Backup data in var only (not the /var directory itself)
cd /var
cp -ax * /mnt/var
7. Rename the /var directory after your data has been transferred successfully.
cd /
mv var var.old
8. Make the new var directory
mkdir var
9. Unmount the new partition.
umount /dev/sdaX
10. Remount it as /var
mount /dev/sdaX /var
11. 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/sdaX /var ext4 defaults 0 0
12. Repeat steps 1-11 for /home and /tmp.
13. Finally return to multitasking mode.
init 5

== This solution helped 16 people ==
If you want to use them all on the same partition you can either use LVM or
three simple bind mounts.
To create a bind based solution you
1. create a partition with a filesystem
2. go to rescue mode (single user still needs some of the folders)
3. mount it as /mnt/data
4. Move all folders you want to move. Using cp and mv dir dir.old might be
safer, but since I did this after install it did not matter to me.
mv /home /mnt/data/
mv /var /mnt/data/
5. create appropriate bind mount entries in fstab, for example I have
UUID=01234567-89abc-def0-1234-567890abcde /mnt/data ext4
noatime,nodiratime,relatime 0 0

Binds
/mnt/data/opt /opt none
bind 0 0
/mnt/data/home /home none
bind 0 0
/mnt/data/usr /usr none
bind 0 0
6. reboot

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free... | Images: https://stocksnap.io/license & others | With thanks to user toffee.beanns (https://unix.stackexchange.com/users/..., user Stephen Rauch (https://unix.stackexchange.com/users/..., user mreithub (https://unix.stackexchange.com/users/..., user Jeff Schaller (https://unix.stackexchange.com/users/..., user froner (https://unix.stackexchange.com/users/..., user Fabian (https://unix.stackexchange.com/users/..., user cioby23 (https://unix.stackexchange.com/users/..., and the Stack Exchange Network (http://unix.stackexchange.com/questio.... Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.