Wiki Ubuntu-it

Indice
Partecipa
FAQ
Wiki Blog
------------------
Ubuntu-it.org
Forum
Chiedi
Chat
Cerca
Planet
  • Pagina non alterabile
  • Informazioni
  • Allegati

Versione 4 del 19/09/2010 17.18.40

Nascondi questo messaggio

BR Indice()

HomeSpostarePartizioneDedicata

The Guide

Setting up /home on a separate partition is beneficial because your settings, files, and desktop will be maintained if you upgrade, (re)install Ubuntu or another distro. This works because /home has a sub-folder for each user's settings and files which contain all the data & settings of that user. Also, fresh installs for linux typically like to wipe whatever partition they are being installed to so either the data & settings need to be backed-up elsewhere or else avoid the fuss each time by having /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. Its been suggested to use either ext2, ext3 or ext4 rather than vfat or ntfs. Using vfat is not supported and may fail, since vfat does not support permissions. Ntfs has an advantage of being journalised, like ext3 & ext4 but it can also be read easily by Windows. It is a lot less stable than ext3 or ext4 so it is really a question of stability compared with easy access for Windows. If you don't dual-boot with Windows or have plenty of hard-drive space then staying with very much safer ext3 or 4 is the obvious choice.

Find the uuid of the Partition

The uuid reference to all partitions get to a command-line to try this

sudo blkid 

Alternatively, for some older releases of Ubuntu the "blkid" command might not work so this could be used instead

 sudo vol_id -u <partition>  

for example

 sudo vol_id -u /dev/sda3  

Now you just need to note down (copy&paste into a text-file) the uuid of the partition that you have set-up ready to be the new /home partition.

Setup Fstab

These commands should;

  1. Creates a backup of fstab. The "$(date +%Y-%m-%d)" at the end automatically (and quite cleverly) gives the file today's date backwards.
  2. Compares fstab with the new back-up just to be certain it's good.
    • Opens the standard text-editor (gedit) in Ubuntu to edit fstab. Note that Kubuntu uses "kate" & Xubuntu uses "mousepad" instead but you could use any text-editor you have installed if you prefer.

{{{ sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d) cmp /etc/fstab /etc/fstab.$(date +%Y-%m-%d) 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 will 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  

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)

Check Copying Worked

The data in /home now exists in 2 places but we need to check that it looks about right. If it looks approximately the same then it is probably completely right.

A Sneaky Safety Manoeuvre

So you now have 2 copies of your /home folder. The new one on the new partition and the old one still in the same partition it was always in. The problem is how to delete the right one!! Since we are still using the old /home 'just' rename your current /home folder:

{{{ cd / sudo mv /home /old_home }}}

Now re-create a new blank /home directory just in case it has all gone wrong!

{{{ cd / sudo mkdir -p /home/user }}}

Now if things have gone wrong then the system will boot into what appears to be a fresh install with all your data missing. In fact, of course, there are still 2 copies of it all :)

Make the Switch

We now need to modify the fstab again to point to the new /home and mount it properly. 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 }}}

and finally, remount the partition with:

 sudo mount -a  

Does it all still look fine? Can you still access your files & folders from the "Places" menu? Reboot to ensure that currently running programs use the /home that is on the new partition.

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


CategoryNuoviDocumenti