D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Separate Home Partition

 

On 05/09/13 18:59, Neil Winchurst wrote:
> A little while ago I bought a new laptop. It was my first time with
> uefi and I had a few problems because it came with secure boot enabled
> and Win 8 (trial version only) installed. I had to call the help line
> to get that sorted. With all that going on I forgot to set up a
> separate partition for home.
>
> Now I am wondering if there is a way to change the partitioning so
> that I can have home separate while keeping the data intact. I have
> done some research. Plenty of advice about using gparted when
> installing a new distro but I cannot find anything about moving home
> intact to its own separate partition. Perhaps it can't be done?
>
> The idea is that, when I move to a newer version of my distro, I can
> just install the root files but keep my home files untouched. Is that
> feasible please?
>
> Or am I being over optimistic? If so I will remember to get it right
> next time!
>
> Thanks
>
> Neil
>

Hey, this is the helpline isn't it?

You can definitely do this post-install, whether or not it's a good idea
I'll leave as a discussion for others. I'm also not touching the "is it
good practice to have a separate home partition" issue either, as you
seem to have decided what you want to do and who am I to argue.

So, here we go:

0: Backup everything you care about
1: Boot a live distro (ideally gparted*)
2: Repartition your / partition down to whatever you like
3: Create new partition for /home in the empty space
4: Before rebooting, mount your old / partition and your new /home rw on
your live system
5: Edit the mounted /etc/fstab** file from your mounted hard drive to
reflect change
6: Move the entire /home from your old / to your new /home
7: Unmount all drives, reboot

* gparted from http://gparted.sourceforge.net/livecd.php
** editing fstab can vary hugely between systems - broadly speaking on
linux you can simply add a line like:

/dev/sda4    /home    ext4    defaults    0    2

You *will* need to edit this according to your specifications first
though: don't blindly put /dev/sda4 when your partition ID will probably
be different, and don't use ext4 as the fs type if it's incorrect,
obviously. Personally I would edit the options from default to at least
"errors=remount-ro,user_xattr" and don't forget to add "discard" if
you're using a SSD. The "/home" and "0 2" parts will be correct for you
though.

On *buntu-style systems, you shouldn't really refer to partitions by
their old /dev/sdX notation anyway: run "sudo blkid" and it will spit
out UUIDs for you to use instead, like so:

ghost@failbot:~$ sudo blkid
[sudo] password for ghost:
/dev/sda1: UUID="8bc2d3fe-351a-45ff-868d-8a152bbd0b72" TYPE="ext4"
/dev/sda5: UUID="e5736c02-8cc2-4cc6-8362-c58a372abade" TYPE="swap"
/dev/sdb1: LABEL="System Reserved" UUID="2E90891E9088EE21" TYPE="ntfs"
<snip>

Replace your fstab edit above with the correct "UUID=xxxxxxxx..." stanza
in place of /dev/sdaX. Your finished fstab line should end up looking
something more like:

UUID=70e0caf1-4331-4580-8539-7f7fb6062e83 /home      ext4     
errors=remount-ro,user_xattr 0 2

There is actually plenty of help online for this sort of operation if
you google, especially on the Ubuntu forums. It is actually possible to
do all of this as root, without even rebooting, but I don't recommend
that unless you're *extremely* confident.

As ever, ask more if you need pointers.

Regards

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq