Migrating /home and other apparent issues
First of all, it would appear that your root partition at /dev/mapper/xubuntu--vg-root
is not configured in /etc/fstab
. That will need to be fixed. Second, your /boot
partition is rather small. Be diligent about removing old kernels or you will have problems installing updates once your /boot
partition gets filled to 100%. Creating a larger boot partition and putting home on a separate drive altogether can be easily accomplished with manual partitioning during install. See how to go about that in my post here if you're interested, but it only applies to new installations.
I should be able to help you with the migration and getting your root partition back into /etc/fstab
. Since you've indicated that you've already made changes to one or more of these files, I'll assume that you already know how to edit files as root or with sudo. You'll need to make any file changes mentioned below in this way.
Grabbing a system image:
We're going to be making some significant system changes. If you have a "working" system right now, you should use a tool like Clonezilla to grab a system image to restore from in case anything gets really messed up! While this isn't absolutely necessary, I strongly advise it!
Fixing /etc/fstab
:
Edit /etc/fstab
and add a line at the top that reads as follows:
/dev/mapper/xubuntu--vg-root / ext4 errors=remount-ro 0 1
Without that line, your computer won't even boot.
Migrating /home
:
There are a few parts to this. You must move all of your documents to the external drive. You must update your /etc/crypttab
file so that your system can decrypt your external drive during boot. This means you're going to have to enter a password to decrypt your internal disk and then you'll have to enter another password to decrypt your external disk. There are ways to unlock two disks while providing only one password, but I won't get into that here. If you want to know more about that read here and here. You must also update /etc/fstab
so that your system knows how to mount your home directory. Finally, you need to update your initramfs.
- Copy the contents of your home directory to the external drive. In a terminal, run the following, changing the path to the external drive as necessary. Each of these commands could take several minutes to run.
- Create hashes to be used later for verifying integrity of copied files. It's not absolutely necessary, but it's nice to be able to confirm that nothing got corrupted while being copied.
sudo find /home -type f -exec md5sum '{}' >> $HOME/checksums.md5 \;
- Copy everything in your home directory to your external drive
sudo cp -ar /home/. /media/$USER/My_external_drive
- If you created checksums of all your files, go ahead and check them. If you were logged into your account, be aware that some files may naturally change between the point of creating checksums and checking the copied files. If there were any failures, just make sure they aren't important files.
cd /media/$USER/My_external_drive
sudo md5sum -c checksums.md5 | grep "FAILED"
- You'll also need to delete everything from
/home
so it can be used as a mount point, but we don't want to do that from your local xubuntu install. We'll wait until we're ready to reboot and use a live CD/USB for that.
- Updating
/etc/crypttab
:
Open /etc/crypttab
for editing and add the following line, replacing the x's with the actual values of the UUID for your LUKS partition on your external drive.
luks_home UUID=39af7a74-xxxx none luks,discard
- Updating
/etc/fstab
to include the new /home
partition:
Open /etc/fstab
for editing and add the following line to the end
/dev/mapper/luks_home /home ext4 defaults 0 2
- Update your initramfs
sudo update-initramfs -k all -u
Things to check:
Your /etc/fstab
file should now look something like this:
/dev/mapper/xubuntu--vg-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=f2c4a3ef-longstringofnumbers /boot ext2 defaults 0 2
/dev/mapper/xubuntu--vg-swap_1 none swap sw 0 0
/dev/mapper/luks_home /home ext4 defaults 0 2
Your /etc/crypttab
file should now look something like this:
sda5_crypt UUID=4426b1a1-longstringofnumbers none luks,discard
luks_home UUID=39af7a74-xxxx none luks,discard
If you find any problems with the /etc/crypttab
file and you make changes, be sure to run the update-initramfs
command again from point 4.
Reboot into live OS
Once you're sure you have everything you need copied over, it's time to erase everything from /home
so it can be used as a mount point. Get your live CD/USB, and boot from it.
dev=$(sudo lsblk | grep -B1 "sda5_crypt" | grep -oP "sd[a-z]\d\b" | awk '{print "/dev/"$1}')
sudo cryptsetup luksOpen $dev internal_crypt
sudo mount /dev/mapper/xubuntu--vg-root /mnt
- Now your old home partition should be located at /mnt/home. Let's delete everything inside
sudo rm -fr /mnt/home/*
Reboot into local installation:
At this point, you're ready to reboot. With your old home directory emptied out, shutdown the live OS and reboot into your system. Your system should now ask for two passwords, one to decrypt the internal drive and one to decrypt the external drive. Assuming you enter both of these correctly, your system should boot up, and your home directory should reside on your external drive.
Verifying that the external drive is being used as /home
:
If everything is pretty much where you left it in your home directory, you're golden. You can type mount | grep "/home"
into a terminal window. It should show that your LUKS partition on your external drive is mounted at /home
.
/etc/crypttab
to include the external disk, and you would have to update/etc/fstab
so that it mounts your/home
directory from the external disk. Once all of that is done, you should probably runsudo update-initramfs -k all -u
. If you don't know how to do all of this, update your question with the output ofsudo lsblk
,cat /etc/fstab
,sudo cat /etc/crypttab
, andsudo blkid
, and I or someone else might be able to provide more detailed steps.