Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Recently I installed Ubuntu and Fedora on my system.

Each OS has its own partition and I made a data partition to save my personal files.

Now in Ubuntu when I open terminal its default location is Ubuntu's home folder but I want to change it to data partition. I also want to change my home directory. I mean when I type cd ~ I want to go to data partition.

Is this possible? If so, how can I do it?

I want new applications to default to the data partition not in my old home. And also change all folders location in home like Music, Downloads, etc to data partition.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Prerequisites

Finding the UUID of the partition

Run this command in the terminal

sudo blkid

You will get something like this

/dev/sda1: UUID="FA286F4C286F06CB" TYPE="ntfs" 
/dev/sda2: UUID="328E-CDB6" TYPE="vfat" 
/dev/sda3: LABEL="7programs" UUID="01CAB88B789D7370" TYPE="ntfs" 
/dev/sdb1: LABEL="TempBAKUP" UUID="EF54-7F8C" TYPE="vfat" 
/dev/sdb3: LABEL="New Volume" UUID="B62A57642A5720A3" TYPE="ntfs" 
/dev/sdb5: LABEL="7programs" UUID="01CAB88B789D7370" TYPE="ntfs" 

Find the data partition that you made earlier and note down the UUID

Making sure that the partition mounts at bootime

Duplicate your fstab file:

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

Open the original fstab in a text editor:

gksu gedit /etc/fstab

and add these lines into it

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

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


Using Usermod

Use this command to just change the homedir

usermod -d /media/home username

replace username with your username

Now move all of the files in /home/ to /media/home/ with this command:

cd / && sudo mv /home/* /media/home

Now, delete the old home folder

sudo rmdir /home --ignore-fail-on-non-empty

Sources:

https://help.ubuntu.com/community/Partitioning/Home/Moving

http://www.spiration.co.uk/post/1294/Unix-/-Linux-change-a-user%27s-home-directory---usermod

share|improve this answer
    
Very helpful answer. An alternative to using usermod would be to copy the data as above, and then change the fstab entry to mount the partition on /home rather than on /media/home (and then reboot). –  John S Gruber Aug 9 '12 at 15:40
    
@JohnSGruber Look at the edit history. I deleted that part for simplicity –  Amith KK Aug 9 '12 at 16:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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