I would like to install another distribution but keep my home directory. Is there a way to move the home directory to a separate partition? I don't have an external hard drive available to back up my data. I would like to set up my partitions as suggested here.

  • 1
    You could always repartition and then restore /home from backup. You do have backups, don't you? – KeithB Aug 11 '10 at 12:35

Your question is distro-neutral, so if I mention anything specific that you don't have, just use the equivalent on your side.

I really recommend you buy an external for backups, trust me, losing your data is the worst. Proceed at your own risk - But if you can't get one, here's what you can do.

What you need

  • the size of your /home directory
  • free space, more than the size of your /home directory
  • disk partitioning tool, I recommend gparted

What to do

  • Check the size of your /home directory (the last result will be home total):

    du -h /home

  • Check if you have enough free space for the new partition:

    df -h

  • Install gparted

    sudo apt-get install gparted

You need more free space than the size of your /home directory. If you don't have the free space, then you won't be able to create that new partition, and need to move your data onto an external anyway.

If you have the space, use gparted to shrink your existing partition, and then create a new partition with the freed unallocated space. Once your new partition is ready, note it's /dev/sdax (use sudo fdisk -l to see this), and copy your /home files to it.

Using the partition in a new distro

You mentioned installing another distro, if you plan to override your current distro, then during installation you should be asked to setup partitions. At that point you can specify this partition as /home, choose not to format it, and all will be well, you can skip this next section.

If however you want your current distro to work with the new /home partition, follow this section:

Mount the partition in an existing distro

We have to tell your OS to use the partition as your new /home, we do this in fstab, but first let us find the UUID of this new partition:

ls -l /dev/disk/by-uuid

Cross reference your new partition's /sdax and copy the UUID of it, mine looks like 3d866059-4b4c-4c71-a69c-213f0e4fbf32.

Backup fstab: sudo cp /etc/fstab /etc/fstab.bak Edit fstab: sudoedit /etc/fstab

The idea is to add a new line that mounts the partition at /home. Use your own UUID, not the one I post here ;)

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
UUID=3d866059.. /home           auto    default         0       1

Save and restart, and test if the new partition mounts to /home. Run df -h to list all mounted partitions, /home should now be in that list.


  • It might be a good idea to familiarize yourself with fstab if you don't know it well. Just take your time and think about each step.
  • If you install a new distro, and use the same login name, your old /home files will automatically fall under your ownership.
  • This is not a trivial topic to cover in one post, but I think I got most of it. :)
  • I'm trying to use gparted, but I can't resize the / partition. Do you have any recommendations on how to resize the root partition? I might use Parted Magic to do it from a live cd. – vanillaike Aug 11 '10 at 23:23
  • 1
    Yes you would need to do it from a Live CD because the filesystem is mounted by the running OS. Ubuntu Live CD, Knoppix or Parted Magic will all work. – invert Aug 12 '10 at 14:00

The title of the post and your question caused some confusion to me. Do you want to separate your home into a partition, or do you just want to reinstall and keep the same home?

If all that you want is to reinstall the whole OS while keeping your home then you can backup your home into a place that will not be affected by the install, then restore it after that, together with a permission fix (use chown -R username:groupname to make sure ownership is correct).

If you want to follow some best practices and separate your home then here is the guide you need. It's written for Ubuntu, but I think the same thing goes for other distros.

  • sorry for the confusion. I'd like to separate my home into a partition – vanillaike Aug 11 '10 at 12:16
  • WARNING: The link in "permission fix" currently bounces one off to two different websites, the last of which prompts one to install Adobe Flash in a very dodgy looking installer dialog replica. – user66001 May 3 '13 at 22:48
  • I unlinked "permission fix" and copied in the advice from the original article, which I found archived. – mattdm May 6 '13 at 12:30

Assuming you have a separate partition already (and if you don't, you probably want to use gparted or something similar, to make one), you simply do the following (preferably as the root user):

 cp -R /home/whatever /path/to/destination
 mv /home/whatever /home/whatever.orig
 ln -s /path/to/destionation /home/whatever 

And then assuming that everything works the way it should (log in as the user and test)

 rm -rf /home/whatever.orig 

This copies the entire directory (and all the contents) to the destination mountpoint, renames the original home directory (in case something is screwed up in the process, then we can recover), creates a symbolic link from the new location to the original home directory (which everything (like /etc/passwd) is still pointing to), then assuming it worked, removes the backup copy we made, leaving the copy we put at the destination filesystem.

  • This isn't really using /home as the mountpoint for the new partition. It's just symlinking it. – Matthew Flaschen Aug 11 '10 at 3:47
  • It's effectively the same thing. Just because /home/username is a symlink doesn't mean that it won't work. If you want to put all user accounts on the other partition, just change the 'cp -R' line to do /home instead of /home/username – Matt Simmons Aug 11 '10 at 7:40

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.