Tuesday, June 23, 2026

A separate /home directory

As someone who has been using Linux from its early days, I used to keep my home directory on a separate partition so that I did not lose data or have to recustomise stuff when I had to reinstall Linux. Back then, Linux was not very compatible with new hardware, and I often had to reinstall Linux to find a distro that worked or suited me. Or when upgrading.
 
Then, Linux became easier to use, easier to install, easier to upgrade.
 
And I grew complacent.
 
And panicked when the triple upgrade (Debian 12 to 13, LMDE 6 to 7, Proxmox VE 8 to 9) failed and my main PC went into an endless reboot loop. Thankfully, I had a snapshot prior to the upgrade, and rolled back without any issues (so far).
 
Still, given that I need to upgrade to Proxmox VE 9 and LMDE 7 soon, I really want to be able to keep my home directory intact. Luckily, I have an old SSD that used to hold my OS that can be used for migrating my home directory.
 
First, I formatted that disk and created a ext4 partition on it. It shows as 
/dev/sda1
on my system. 
 
Then, I rebooted my system, and at the grub screen, pressed 'e' to edit the boot options, changing splash to 3, then F10 to boot into the console. 
 
I started by mounting the spare SSD. 
sudo mkdir -p /mnt/new_home
sudo mount /dev/sda1 /mnt/new_home
 
Then, I used rsync to transfer data in archival mode.
sudo rsync -aAvx /home/ /mnt/new_home/ 
 
It was now time to mount the SSD as the new  home directory. First, it needs to be unmounted.
sudo umount /mnt/new_home

Then, I renamed my old home directory. 
sudo mv /home /home_old 
 
Finally, I mounted the SSD as my  home directory.
sudo mkdir /home
sudo mount /dev/sda1 /home
 
The last step is to edit /etc/fstab, and for that, I needed the UUID of the partition.
sudo blkid /dev/sda1
 
This gave me a string (which I will call MY_UUID here). I used this string to edit /etc/fstab by adding this.
UUID=MY_UUID /home ext4 defaults 0 2  
 
Then, I rebooted the system. Running
lsblk
showed this:

Now that the home directory is separated, I can afford to do a fresh install of LMDE 7! That would be the next task when I have some spare time.
 

No comments: