If you’re running low on space or setting up a more efficient Linux system, moving your /home
directory to a separate partition or disk is a smart move. It keeps user data separate from system files, making upgrades and backups simpler. Here’s a step-by-step guide to do it safely.
Why Move /home
?
- Separate user data from system files
- Simpler OS reinstalls and upgrades
- Improved disk space management
- Easier backups and recovery
What You’ll Need
- A new partition or disk ready to use
- Root or sudo access
- A reliable backup (always have one)
Step 1: Prepare the New Partition or Disk
First, find the new disk or partition using:
lsblk
If the new disk isn’t formatted yet, format it with a Linux filesystem (e.g., ext4):
sudo mkfs.ext4 /dev/sdXn
Replace
/dev/sdXn
with your actual partition name.
Create a mount point:
sudo mkdir /mnt/newhome
Mount the new partition:
sudo mount /dev/sdXn /mnt/newhome
Step 2: Copy /home
to the New Location
Use rsync
to preserve permissions, symlinks, and ownerships:
sudo rsync -avx /home/ /mnt/newhome/
Double-check the contents with:
ls /mnt/newhome
Step 3: Update /etc/fstab
Find the UUID of the new partition:
sudo blkid /dev/sdXn
Edit /etc/fstab
:
sudo nano /etc/fstab
Add a line like this at the end:
UUID=your-uuid-here /home ext4 defaults 0 2
Replace your-uuid-here
with the actual UUID from blkid
.
Step 4: Finalize the Move
Before rebooting, rename your current /home
and mount the new one:
sudo mv /home /home.bak
sudo mkdir /home
sudo mount -a
If all went well:
ls /home
You should see your users’ home directories.
Step 5: Reboot and Clean Up
Now reboot:
sudo reboot
If everything works fine, you can delete the old /home
backup:
sudo rm -rf /home.bak
Troubleshooting Tips
- If something goes wrong, you can restore the old home with:
sudo rm -rf /home sudo mv /home.bak /home
- Double-check
fstab
syntax. A bad line can prevent your system from booting.
Final Thoughts
Moving /home
to a separate partition is a one-time effort that pays off with better organization and peace of mind. Just remember to back up, double-check each step, and never rush.
Got questions or hit a snag? Drop a comment below.
Leave a Reply