Moving home to it’s own partion (Ubuntu)

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)

  1. Preparation
    1. Create a backup: rsync -avx –progress /home <your backup destination>
    2. 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.
    3. Get partion name sudo fdisk -l /dev/sda — e.g. /dev/sda7 — I will refer to this name as (name)
    4. Copy your current file system configuration: sudo cp /etc/fstab /etc/
    5. 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.
    6. Edit /etc/, 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
  2. Copy
    1. Sign off / Log out
    2. Switch to console mode by pressing Ctrl+Alt+F1
    3. Create a mount point for the new partition: sudo mkdir /mnt/tmp
    4. Add partion: sudo mount (name) /mnt/tmp
    5. Copy home from the old location to the new partition: sudo rsync -avx –progress /home/ /mnt/tmp
    • Test
        1. Mount copy of home as new home: sudo mount (name) /home
        2. Check size of home folder — should be the same as in step 1.: du -sh /home
        3. Check mounting worked: sudo mount| grep /home should print out something like
          (name) on /home
        • Switch
            1. yet another home backup: sudo mv /home /home.bak
            2. create new home mount point: sudo mkdir /home
            3. create a backup of fstab: sudo mv /etc/fstab /etc/fstab.bak
            4. put updated version in place: sudo mv /etc/ /etc/fstab
            5. 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! 🙂

            KDE vs. Gnome

            Now, my decision is final: KDE rules (though I actually prefer the look of Gnome 🙁 ).

            Simple reason: Gnome does not support drag-and-drop in combination with alt+tab (see bug tracker), but there might be hope with the upcoming Gnome 3.

            [Edit 2011-06-14: Indeed, drag-and-drop + alt-tab works since since Ubuntu 11.04 (did not try with 10.10). One major difference remains: Do you need a lot of configuration and customization options? And are you will to accept complex, maybe not that self-explaining menu structures for that? If yes, KDE is your choice, otherwise Gnome might make your life easier. See also this page for more details and screenshots.]

            In more detail: using drag-and-drop together with alt+tab key combination allows to work very efficiently. For example, while ordering my photos, I want to work on one of them — as I do this regularly, Gimp is opened already, but in the background — so what I do using KDE or MS Windows is, I grab the picture, switch to Gimp by using alt+tab and immediately drop the picture without moving the mouse at all – I am quite confident that this is the fastest way of opening a picture for editing. Some people advice to set Gimp as default application to open JPEGs, but I am not always editing pictures, most of the times I just want to view them.

            Using “Open With” on a JPEG file for sure is the common approach – but let’s compare it:

            • Drag-and-drop & alt+tab
              • Actions to be performed: mouse down + key down + key up + mouse up
              • In total: four fast steps
            • “Open With” solution (holding mouse down as improvement)
              • Actions to be performed:mouse down + moving to “Open With” + wait for sub-menu to open + move to sub-menu + mouse up
              • In total: two fast, three slow steps