Diff for "Partitioning/Home/Moving"


Differences between revisions 23 and 24
Revision 23 as of 2010-04-12 23:35:15
Size: 6159
Editor: 78-105-201-166
Comment: made a bit more use of coding brackets so people could see what actions to take more easily
Revision 24 as of 2010-04-13 01:18:50
Size: 6727
Editor: 78-105-201-166
Comment: Tidied up finding the uuid and gave it a separate section
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
== Find the uuid of the Partition ==
Ok, to find the uuid reference to the partition that is going to be the /home on a [[https://help.ubuntu.com/community/UsingTheTerminal#Starting%20a%20Terminal | command-line]] please enter this command
{{{
sudo blkid
}}}
Some older releases of Ubuntu might not have that command so this could be used instead
{{{
sudo vol_id -u <partition>
}}}
for example
{{{
sudo vol_id -u /dev/sda3
}}}

Line 20: Line 35:
Ok, please get to a command-line
These commands should;
1. Create a backup of fstab. Replace "DateToday" with today's date so you can find the right back-up easily if you do need to use it later.
2. Open the standard text-editor to edit fstab. Note that Kubuntu uses "kate" & Xubuntu uses "mousepad" instead of "gedit" you could use a different text-editor if you prefer.
Line 22: Line 40:
sudo cp /etc/fstab /etc/fstab.DateToday
Line 29: Line 48:

You should replace the ?'s with the UUID of the intended /home partition.

The UUID can be found with:
{{{
 sudo vol_id -u <partition>

}}}

eg
{{{
 sudo vol_id -u /dev/sda3
}}}

or
{{{
sudo blkid
}}}
(Apparently the vol_id command is not part of the Ubuntu 9.10 - Karmic Koala )
Replace???????? with the UUID number of the intended /home partition.

Why this guide is superior to the others

If you don't care about this topic, just skip to the next section where the guide starts.

I wrote this guide simply because I found some flaws in the other guides that I read, and I wanted to record my findings for future reference. I'm posting (and updating a bit) here for the benefit of others. Here are the reasons I originally wrote this guide:

  • Partition and setup fstab first
    • There are guides that use mount commands to do the initial partition mounting, and then setup fstab after you have moved your /home. If you mess up your fstab, then when you reboot, your system will lose track of your /home files. Setting up fstab first and using sudo mount -a to mount the partitions avoids this problem.
  • Use rsync to move the files
    • There is lot's of debate about which command to copy your files to the new /home partition. This debate stems from a time in the past when cp was not able to do it properly (I think it skipped files?). cp was not designed to be a powerful backup tool. The fix, then, was to use a combo of find and cpio (See section 8.3.5). cp has had improvements since, but why not use rsync, a tool that is designed for backups like moving your /home, and much more. Rsync is not only able to copy over all the files, but is also able to maintain other characteristics of the file, like permissions, ownership, and timestamps.

The Guide

Setting up /home on a separate partition is beneficial because your settings, files, and desktop will be maintained if you upgrade/reinstall/use a different distro. This works because /home has a subfolder for each user's settings and files. Also, fresh installs for linux typically like to wipe whatever partition they are being installed to, hence the need to put /home on a different partition.

Setup Partitions

This is beyond the scope of this page. Try here if you need help. Memorize or write down the location of the partition, something like /sda3 or /hda3. Its been suggested to use either ext2 or ext3 over vfat. Using vfat is not supported and may fail, since vfat does not support permissions.

Find the uuid of the Partition

Ok, to find the uuid reference to the partition that is going to be the /home on a command-line please enter this command

sudo blkid

Some older releases of Ubuntu might not have that command so this could be used instead

sudo vol_id -u <partition>

for example

sudo vol_id -u /dev/sda3

Setup Fstab

These commands should; 1. Create a backup of fstab. Replace "DateToday" with today's date so you can find the right back-up easily if you do need to use it later. 2. Open the standard text-editor to edit fstab. Note that Kubuntu uses "kate" & Xubuntu uses "mousepad" instead of "gedit" you could use a different text-editor if you prefer.

sudo cp /etc/fstab /etc/fstab.DateToday
gksu gedit /etc/fstab

and add these lines into it

# (identifier)  (location, eg sda5)   (format, eg ext3 or ext4)      (some settings) 
UUID=????????   /media/home    ext3          nodev,nosuid       0       2 

Replace???????? with the UUID number of the intended /home partition.

The Fstab location should be a temporary one - we are to mount the temporary location and copy the existing home to it. (/media/home is assumed in the rest of the guide). If /media/home does not exist yet, then you should create it with the command:

sudo mkdir /media/home

Now, mount the partition with:

sudo mount -a

Check that you can copy files over, at least as root (ie with sudo).

Copy /home to the New Partition

sudo rsync -axS --exclude='/*/.gvfs' /home/. /media/home/.

The --exclude='/*/.gvfs' prevents rsync from complaining about not being able to copy .gvfs, but I believe it optional. Even if rsync complains, it will copy everything else anyway. (See here for discussion on this)

Make the Switch

Here is the point of no return. If the previous two steps worked, you should have no troubles. The data in /home now exists in 2 places and we need fstab to point to the new one. so again on a command-line

gksu gedit /etc/fstab

and now edit the lines you added earlier to delete the /media part. This should make /media/home into /home as follows

# (identifier)  (location, eg sda5)   (format, eg ext3 or ext4)      (some settings) 
UUID=????????   /home    ext3          nodev,nosuid       0       2

Rename your /home directory:

sudo mv /home /old_home

Re-create a /home directory with (this is because the next steps need the location to already exist):

sudo mkdir /home

It seems that this guide fails at this point (under 9.04) because sudo fails as it can not find the config files it needs to check the users sudo permissions. This is because /home no longer exists. To fix this I needed to start a shell as root (su command and supply the root password) and create the new /home. - Roger Morton

Edit fstab so that your new home partition actually points to /home (ie. by changing /media/home to /home)

gksudo would not launch gedit (for the same reason sudo failed above I suspect) so I was forced to use vi to edit my fstab. And I hate vi. - Roger Morton

and finally, remount the partition with:

sudo mount -a

I recall that this failed too. I think because home is already mounted - even though we have renamed it. umount /home failed because /home was in use by the GUI. In the end I had to reboot and bring up the recovery console as root and fix the mess. So bottom line - I don't think this is such a good guide. Needs further work and testing. - Roger Morton

Reboot to ensure that currently running programs use the new /home

After a reboot

If everything is working, great, you can delete /old_home. If things aren't working, you can undo by moving your /old_home back to /home, and delete the line you added to fstab.

Technical Notes and Resources

Rsync was chosen over cp and find|cpio because it seemed to maintain permissions.

http://ubuntu.wordpress.com/2006/01/29/move-home-to-its-own-partition/

http://ubuntuforums.org/showthread.php?t=46866

Partitioning/Home/Moving (last edited 2015-11-13 13:16:06 by 80)