I have 2 HDD drives in my computer. At the moment second drive is mounted as /media/storage.

How can I move my user data from /home to /media/storage/home?

Can I just move the data over there and then simply symlink it back?

up vote 29 down vote accepted

If you want to just move your home directory i.e /home/your-username then simply copy your home directory to other partition and then use System->Administration->Users & Groups to open user settings dialog. Click on the keys icon to authenticate your self

alt text

After that select the user that you want to change and click properties, go to advanced tab

alt text

change the home directory to new directory i.e the directory that you copied to other partition.

  • 2
    Indeed. it is a great way to easily change the home directory location of a specific user. While reading the question, I was understanding that this would have been for the /home directory globally. In this case, you could create the partition on the other device, manually move all files there and then change the device for the mount point in /etc/fstab file itself. – jfmessier Jan 13 '11 at 13:09
  • 1
    @jfmessier: you should make that an answer rather than a comment! – Skizz Jan 13 '11 at 15:19
  • 1
    If you're copying your home directory with 'cp' on the command line, you'd better use 'cp -rPa *' : r for recursive, P for not following links, a for preserving ownership and permission flags. – drevicko Feb 28 '12 at 11:20
  • 1
    Unity in 13.04 has no "Users & Groups", just a "Users" setting that does not include these options. Can you mention the corresponding terms for Unity in 13.04? – Torben Gundtofte-Bruun Aug 8 '13 at 21:57
  • If your using Ubuntu 12.04 or greater the option to use the GUI method may not be available, at least for me it's not. I had to use this method found here: help.ubuntu.com/community/Partitioning/Home/Moving – toystory Feb 13 '14 at 0:24

Moving HOME from command line

To avoid side effects while working in a graphical, environment we should perform all actions to move HOME from a terminal with Ctrl+Alt+F1.

Temporarily mount the new partition:

sudo mkdir /mnt/tmp
sudo mount /dev/sdb1 /mnt/tmp

assuming /sdb1 is the new partition for HOME

Copy HOME to the new location:

sudo rsync -avx /home/ /mnt/tmp

We then may mount the new partition as HOME with

sudo mount /dev/sdb1 /home

to make sure all data are present. Easiest is to delete the old /home at this point (you could do this later but then you will have to boot a live system to see the old home):

sudo umount /home  #unmount the new home first!
rm -rf /home/*  #deletes the old home

Make HOME permanent

We need to know the UUID of the new partition for the fstab entry seen from:

sudo blkid

Note or copy/paste the correct UUID to edit your fstab with

sudo nano /etc/fstab   #or any other editor

and add the following line at the end:

UUID=<noted number from above>    /home    ext4    defaults   0  2

Take care to choose the appropriate filesystem here, e.g. ext3 if ext3 formatted

Reboot

After a reboot, your /home resides on the new drive having plenty of space.

  • 1
    Did not work for me. – corev Sep 27 '11 at 2:30
  • 1
    I recommend logging out of the profile you want to move, you then can also use the distribution tools like usermod for this task. – LiveWireBT Feb 10 '13 at 10:39
  • It worked! Thanks. Can I remove /mnt/tmp after reboot? – e9t Sep 13 '15 at 6:39
  • @e9t: it is only a mount point we had created to be able to temporarily mount our HOME. It is possible to remove this mount point but it will do no harm (and may be safer) to just keep it. If for any reason you still want to remove it please take extra care to not have anything mounted there (otherwise you risk to irreversibly delete all data you had mounted to /mnt/tmp). – Takkat Sep 13 '15 at 6:57
  • I followed these instructions for my server and now I cannot access to it via SSH (Permission denied (publickey) :(:(:( – Khue Apr 18 at 11:14

The official detailed procedure is here on the Ubuntu help wiki


Find the UUID of the Partition

sudo blkid

Set up Fstab

sudo -H gedit /etc/fstab 

and add these lines into it

UUID=????????   /media/home    ext4    defaults    0  2 

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

Save and close the fstab file, then type the following command:

sudo mkdir /media/home

Copy /home to the new partition

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

Check copying worked

sudo diff -r /home /media/home -x ".gvfs/*"

Note: You can also expect to see some errors about files not found. These are due to symbolic links that point to places that don't presently exist (but will do after you have rebooted). You can ignore these - but check out anything else.

Preparing fstab for the switch

sudo -H gedit /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:

UUID=????????   /home   ext4    defaults     0  2 

Moving /home into /old_home

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

Reboot or Remount all

Reboot or remount all with this:

sudo mount -a
  • 10
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Eliah Kagan Jan 6 '13 at 0:51

Indeed. it is a great way to easily change the home directory location of a specific user. While reading the question, I was understanding that this would have been for the /home directory globally. In this case, you could create the partition on the other device, manually move all files there and then change the device for the mount point in /etc/fstab file itself

ok, the only way I found this would work is to create another user, give it admin authority, logoff the main id, logon with the new id and then use usermod command.

protected by Community Jul 18 '16 at 1:00

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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