We are going to move all accounts including their personal data on a distinct partition. This recommended in case of system failure to not loose any data.
I have no idea, why the Ubuntu installation wizard does not do this by default — it should!
This post is based on an article in German – I will mainly translate it, strip some plush and add some stuff to make life easier and to reduce the risk of data loss. But be aware: to perform any of those following things, you will need super user rights and you should feel somewhat comfy with using the command line. And of course, it might be possible in circumstances unforeseen, that you lose all your personal data — but there are a lot of backup steps included below.
Here we go: (console input or statements are written in italics)
- Create a backup: rsync -avx –progress /home <your backup destination>
- If you do not have a free partition yet, I recommend GParted to create one (use sudo apt-get install gparted). I recommend ext3 for compatibility issues — but if you use Linux only, you can go for ext4 (please change ext3 to ext4 in step 1.6 in case) — make sure your new partition is big enough for your home folder! Try to remember the size (get size: du -sh /home) of /home, you can use it later on to verify your new home location.
- Get partion name sudo fdisk -l /dev/sda — e.g. /dev/sda7 — I will refer to this name as (name)
- Copy your current file system configuration: sudo cp /etc/fstab /etc/fstab.new
- Get partion UUID of new partition: sudo blkid — you will find a line about (name) stating a UUID (quite a long hex string), I will refer to it as (uuid) — copy it.
- Edit /etc/fstab.new, add a new line at the end as follows (the layout should follow previous lines – simply copy one and adjust it):
UUID=(UUID) /home ext3 defaults 0 2
- Sign off / Log out
- Switch to console mode by pressing Ctrl+Alt+F1
- Create a mount point for the new partition: sudo mkdir /mnt/tmp
- Add partion: sudo mount (name) /mnt/tmp
- Copy home from the old location to the new partition: sudo rsync -avx –progress /home/ /mnt/tmp
- Mount copy of home as new home: sudo mount (name) /home
- Check size of home folder — should be the same as in step 1.: du -sh /home
- Check mounting worked: sudo mount| grep /home should print out something like
(name) on /home
- yet another home backup: sudo mv /home /home.bak
- create new home mount point: sudo mkdir /home
- create a backup of fstab: sudo mv /etc/fstab /etc/fstab.bak
- put updated version in place: sudo mv /etc/fstab.new /etc/fstab
- reboot and you should be done: sudo reboot
Ok, that’s that. If everything works fine, you can delete the backup home sudo rm -rf /home.bak and the fstab backup sudo rm /etc/fstab.bak. Hope you found it useful and I did not put in a mistake or typo. Gimme feedback! 🙂