1

I decided to re-install Kubuntu (I was trying many different Ubuntu types) to have a clean OS.

I have a partition for Windows (NTFS), another for home (ext4), a third for the Kubuntu OS (ext4), plus the swap partition.

However, the new installation made a new home directory under / , so how do I point /home to the old separate home partition to access my files?

  • 1
    If you did an auto install did it also create a new / (root)? Or if you used something else, you should have mounted /home but NOT ticked the format box to reuse it. – oldfred Nov 9 '14 at 16:25
1

The official answer is documented at https://help.ubuntu.com/community/Partitioning/Home/Moving, from which I will extract the things you haven't already done. It's OK to copy the commands you see below, then switch to the shell prompt and paste them in with Ctrl-Shift-V

1) Find the UUIDs of the Partitions: The UUID (Universally Unique Identifier) reference for all partitions can be found by opening a command line (or shell prompt), then type the following to make a file with a list of all your UUIDs:

blkid > uuid-list.txt && cat uuid-list.txt

2) Back up and edit fstab: This is a file Kubuntu uses to decide what partitions to mount at boot time. The following commands, also executed from a shell prompt, will duplicate your current fstab, append the year-month-day to the end of the file name, compare the two files and open the original for editing.

2A) Duplicate your fstab file:

sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)

2B) Compare the two files to confirm the backup matches the original:

cmp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)

3) Open the original fstab in a text editor from the shell prompt:

gksu kate /etc/fstab

and add these lines into it

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

and replace the "????????" with the UUID number of your intended /home partition.

4) Save and Close the fstab file, then type the following command from the shell prompt:

sudo mkdir /media/home

This command creates a new directory, later used for temporarily mounting the new partition. At the end of the procedure this directory can be removed.

5) Now reload the updated fstab file with this shell prompt command:

sudo mount -a

to mount the desired home new partition as /media/home. We will edit the fstab again later so this arrangement of the partition is only temporary.

6) Copy /home to the New Partition: Next we will copy all files, directories and sub-directories from your current /home directory into 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 and, even if rsync complains, it will copy everything else anyway. (For more detail, see http://ubuntuforums.org/showthread.php?t=791693)

7) Check Copying Worked: You should now have two duplicate copies of all the data within your home directory; the original being located in /home and the new duplicate located in /media/home. You should confirm all files and directories copied over successfully. One way to do this is by using the diff command:

sudo diff -r /home /media/home

8) Prepare fstab for the switch: We now need to modify the fstab again to point to the new partition and mount it as /home. So again on a command-line

gksu kate /etc/fstab

and now edit the lines you added earlier, changing the "/media/home" part to simply say "/home" so that it looks like this:

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

Then, press Save, close the file but don't reboot just yet.

9) Moving /home into /old_home: Backing up your old home, just in case things have not gone completely smoothly, is best done right now. Here is how:

As long as you have not rebooted yet, you will still see 2 copies of your /home directory; the new one on the new partition (currently mounted as /media/home) and the old one still in the same partition it was always in (currently mounted as /home). We need to move the contents of the old home directory out of the way and create an empty "placeholder" directory to act as a mount point for our new partition.

Type the following string of commands in to do all this at once:

cd / && sudo mv /home /old_home && sudo mkdir /home

By default, when you open a terminal window it places you within your home directory. Typing cd / takes us to the root directory and out of home so we can then use the sudo mv command to essentially rename /home into /old_home, and finally create a new, empty /home placeholder.

With your fstab now edited to mount your new partition to our /home placeholder and the original /home now called /old_home, re-load the updated fstab

sudo mount -a

10) Deleting the old Home: You can delete your old home directory with:

cd / sudo rm -r /old_home

Be careful with the above command as mistyping it could result in the deletion of other files and directories.

| improve this answer | |
0

you need to change your fstab file to point to the home partition. to do so , do the following.

open terminal and type sudo blkid

note the UUID of the partition that you want to use as /home directory.

now edit the fstab file by typing sudo nano /etc/fstab and add a new entry there like the below

UUID=_____ /home ext4 nodev,nosuid 0 2

Fill in the blanks with the UUID of your partition that you noted down earlier.

Now type the following

cd / && sudo mv /home /home_old && sudo mkdir /home

This will move the present /home directory to /home_old and create a blank /home directory. reboot your system and you should be able to use your ext4 partition as your new /home.

If you don't want to reboot, a simple sudo mount -a would do the trick.

word of caution: all user level setting are stored in /home directory. so doing the above will reset every setting that you might have done.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.