Penguin

A brief HOWTO on moving your '/home' folder to another partition (or back again).

REQUIRES INTEGRITY/READINESS/CONTINUITY CHECK ON PROCEDURE BEFORE GENERAL USE!!!


First off:

BACK UP IMPORTANT DATA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


Overview:

  • Move '/home' to a Temporary '/home' Partition
  • Format Old '/home'
  • Delete/Recreate Partition ('/home'_old and '/home'_new)
  • Move Your Data Back.

Lets do it!

  1. Create new '/home'_temp partition and format, then quick integrity check
    • 'cfdisk /dev/xxxx'
    • REBOOT!!! - is this really needed?
    • 'mkfs.ext3 -c /dev/xxxx'
    • REBOOT!!! - is this really needed?
    • 'fsck.ext3 -c /dev/xxxx' (Extra -c redundant from mkfs -c?)
  2. Move/redirect '/home'_old to temp partition/drive,

    • '<your-fav-text-editor-here> /etc/fstab'
    • Locate the line with '/home' in it.
    • Carefully remove the '/dev/xxxx...' at the beginning, and replace with that of your newly created temp partition.
    • SAVE!
    • This is where we mount our new temp dir:
    • 'mkdir /media/xxxx'
    • This mounts our temp EXT3 partition to our previously created mount point '/media...' etc:
    • 'mount -t ext3 /dev/xxxx /media/xxxx
    • Copies (recursively) our user data from old '/home':
    • 'cp -R /home/* /media/xxxx'
    • Check our copy worked OK:
    • 'diff -r /home/* /media/xxxx'
    • If any errors are output from the above step, they SHOULD? (NEEDS CONFIRMATION!!) be noted in the output from 'diff'.
  3. Delete/Reformat old '/home'
    • Remove original user(s) from the /home folder (stops the system getting confused later when we re-add them?!?)
    • 'userdel user1'...user2...etc'
    • Nuke old partition - make sure you delete the right one!!!
    • 'cfdisk /dev/xxxx'
    • REBOOT!!! - is this really needed?
    • Create new partition from free space from old one
    • 'cfdisk /dev/xxxx'
    • REBOOT!!! - is this really needed?
  4. Move/redirect user/data/mount-point back to original partition

    • Edit '/etc/fstab' to change your '/home' entry from '/home'_old to '/home'_new
    • SAVE!!
    • REBOOT!!
  5. Profit!!!

NOTES:

1) Turns out, if you log on as root/single user in recovery mode, you can put stuff from /home into /root - because when logged on as root, this is your /home folder? On Ubuntu at GRUB screen - hit ESC/select Ubuntu xxx.xx.xxx (recovery).

2) Every change/write in fdisk/cfdisk needs a reboot? Same for partition formatting?!?

3) Something I discovered:

After recreating /home, then doing an 'adduser xxx', then logging in as that user, my permissions had changed... I was running as a more restricted user than previously.

Turns out, apparently Ubuntu has the first non-root user account with additional 'special' permissions - seeing as I removed all users bar root, then recreated that first user, it took a reboot for that users permissions to come right...

4) I had a spare partition (1) (blank drive space) available, so I put my temporary '/home' there while I reformatted my old '/home' partition.

I pretty much did everything as 'root' user - I think I should be using SUDO, but I haven't grokked? that concept yet :-)