28 Feb 2010, 2:05pm
linux:

leave a comment




  • Anzeige
  • Moving home to it’s own partion (Ubuntu)

    We are going to move all accounts includ­ing their per­sonal data on a dis­tinct par­ti­tion. This rec­om­mended in case of sys­tem fail­ure to not loose any data.
    I have no idea, why the Ubuntu instal­la­tion wiz­ard does not do this by default — it should!

    This post is based on an arti­cle in Ger­man — I will mainly trans­late it, strip some plush and add some stuff to make life eas­ier and to reduce the risk of data loss. But be aware: to per­form any of those fol­low­ing things, you will need super user rights and you should feel some­what comfy with using the com­mand line. And of course, it might be pos­si­ble in cir­cum­stances unfore­seen, that you lose all your per­sonal data — but there are a lot of backup steps included below.

    Here we go: (con­sole input or state­ments are writ­ten in ital­ics)

    1. Prepa­ra­tion
      1. Cre­ate a backup: rsync –avx –progress /home <your backup destination>
      2. If you do not have a free par­ti­tion yet, I rec­om­mend GParted to cre­ate one (use sudo apt-get install gparted). I rec­om­mend ext3 for com­pat­i­bil­ity 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 par­ti­tion is big enough for your home folder! Try to remem­ber the size (get size: du –sh /home) of /home, you can use it later on to ver­ify your new home location.
      3. Get par­tion name sudo fdisk –l /dev/sda — e.g. /dev/sda7 — I will refer to this name as (name)
      4. Copy your cur­rent file sys­tem con­fig­u­ra­tion: sudo cp /etc/fstab /etc/fstab.new
      5. Get par­tion UUID of new par­ti­tion: sudo blkid — you will find a line about (name) stat­ing a UUID (quite a long hex string), I will refer to it as (uuid) — copy it.
      6. Edit /etc/fstab.new, add a new line at the end as fol­lows (the lay­out should fol­low pre­vi­ous lines — sim­ply copy one and adjust it):
        UUID=(UUID)  /home                ext3         defaults                    0 2
    2. Copy
      1. Sign off / Log out
      2. Switch to con­sole mode by press­ing Ctrl+Alt+F1
      3. Cre­ate a mount point for the new par­ti­tion: sudo mkdir /mnt/tmp
      4. Add par­tion: sudo mount (name) /mnt/tmp
      5. Copy home from the old loca­tion to the new par­ti­tion: 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 mount­ing worked: sudo mount| grep /home should print out some­thing like
            (name) on /home
          • Switch
              1. yet another home backup: sudo mv /home /home.bak
              2. cre­ate new home mount point: sudo mkdir /home
              3. cre­ate a backup of fstab: sudo mv /etc/fstab /etc/fstab.bak
              4. put updated ver­sion in place: sudo mv /etc/fstab.new /etc/fstab
              5. reboot and you should be done: sudo reboot

              Ok, that’s that. If every­thing 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 use­ful and I did not put in a mis­take or typo. Gimme feed­back! :)

              *name

              *e-mail

              web site

              leave a comment