SEARCH

How-To Geek

How to Create a Separate Home Partition After Installing Ubuntu

image

Ubuntu doesn’t use a separate /home partition by default, although many Linux users prefer one. Using a separate home partition allows you to reinstall Ubuntu without losing your personal files and settings.

While a separate home partition is normally chosen during installation, you can also migrate to a separate home partition after installing Ubuntu – this takes a bit of work, though.

While Installing Ubuntu

Creating a separate home partition while installing Ubuntu is easy.  Choose the “Something Else” installation option to use a custom partition layout and create multiple partitions. Set the mount point for one of your partitions as / – which will contain the root file system – and the mount point of another partition as /home. When you install Ubuntu in the future, you can set your old home partition as /home again – but make sure to uncheck the Format checkbox or your files will be deleted.

image

After Installing Ubuntu

If you don’t create a separate home partition while installing Ubuntu, you don’t have to reinstall Ubuntu from scratch. To migrate to a separate home partition after installation, you’ll have to create a new partition (which may require resizing your existing partitions), copy the files from your existing home directory to that partition, and tell Ubuntu to mount the new partition at /home.

Step 1: Create a New Partition

If you have some free space, this step is easy. If you don’t, you’ll have to resize your system partition and create a new partition in the free space. Follow our guide to resizing Ubuntu partitions to complete this step. If you have free space or don’t need to resize a system partition, you can just install GParted and create the partition without restarting from a live CD – you’ll want to create an ext4 partition.

image

Step 2: Copy Home Files to New Partition

Ubuntu makes it easy to mount the new partition – just click it under Devices in the file manager. After you do, click the Go menu and select Location to view its mount point.

image

Launch a terminal and run the following command to create a copy of your current /home directory on the new partition, where /mount/location is the location of your mounted partition:

sudo cp -Rp /home/* /mount/location

You’ll see an error about a .gvfs directory – this is normal; you can ignore it.

image

You should check the new home directory to verify it contains your files. However, we won’t be deleting the old home directory just yet.

image

Step 3: Locate the New Partition’s UUID

The long, random-looking string above is actually the partition’s UUID, and we’ll need it to add the partition to our fstab file, which tells Linux where to mount partitions when it boots. You can also locate the partition’s UUID by running the following command in a terminal:

sudo blkid

image

Step 4: Modify the fstab File

Before modifying our fstab file, we should create a backup copy that we can restore, just in case:

sudo cp /etc/fstab /etc/fstab.backup

Next, run the following command to open the fstab file in gedit. You can also use another text editor, if you prefer.

gksu gedit /etc/fstab

Add the following text to the fstab file on a new line, replacing the _____ portion with the full UUID of your new home partition from the sudo blkid command above:

UUID=_____     /home     ext4     nodev,nosuid     0     2

image

Save the file after adding the line.

Step 5: Move Home Directory & Restart

From a terminal, run the following command to leave your home directory, move your current home directory to a placeholder location, and create a new, empty home directory which your new partition will be mounted at:

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

image

Reboot your computer after running this command. You can restart with the following command:

sudo shutdown -r now

Clean Up

After restarting your computer, you should be able to log in normally. Ubuntu is now using the separate home partition. After making sure that everything went okay and you still have all your files in your /home directory – just in case – you can you can remove your /home_old directory to free up space:

sudo rm -rf /home_old

Chris Hoffman is a technology writer and all-around computer geek. He's as at home using the Linux terminal as he is digging into the Windows registry. Connect with him on Google+.

  • Published 06/17/12

Comments (9)

  1. MJ

    I was thinking about this just yesterday! U read my mind! Thanks for this useful how-to.

  2. aminsir

    this post is useful for me thanks.

  3. Ian

    This article will clearly put off any newbies with it’s complex command line instructions. Is Ubuntu really this nerdy? Is there a simpler way? Is a separate partition only for techies?
    If this is for techies, they probably know this already.

  4. Kiko

    Try doing this in windows…lol

    The nice thing about Linux is you have options….You don’t have to do anything as a newbie, just install Linux Mint and be done. This is a very well written and documented procedure. Yes advanced but nice article to those who are comfortable with trying line commands and in my opinion FUN to try, just back up your home directory in Linux sand if it fails reinstall…. As I said try that in windows!!!

  5. Kiko

    P.S. Works perfect!!!

  6. Chiefree

    Thanks.

  7. Rick S

    Hey Ian,,,
    Not all of it is that nerdy. lol. Thing is, you are in control of your computer and you don’t have to use this feature but it is nice to be able to do a reinstall and have all your files sitting there waiting for you.

    I suggest trying Ultimate Ubuntu. I didn’t bother with the home partition stuff. I like it way better that the other Ubuntus. You will too. And if you screw it up the fix is free.

    Here are some of the pros. It’s free.
    It’s fast.
    No virus attacks or malware or spyware.
    You just turn it on and it works. Sometimes when our connection goes bad it
    will connect when Windows won’t.
    It downloads faster than my Windows computers.
    It checks and repairs itself.
    Keeps your brain from getting out of shape by learning how to install
    a home partition. But you don’t have to learn that to have a nice running
    computer.
    Lots of good info like this article.

    And the cons. You can still be hacked.
    Harder to find somebody to help you.
    Harder to set up dial up and you need an external dial up modem for laptops.
    Different names for things than Windows so it’s hard to find stuff at first.
    You hate it till you learn. lol.

    Sure hope some of you try it. It’s not for everybody but some of you will enjoy it.
    Sorry for being partly off subject.

  8. Brandon

    Ian, its significantly easier to do this DURING the ubuntu install and doing it that way doesn’t require any commandline, this is a bit more complex because its converting an existing install.

  9. duso28

    Worked on Centos 6 for me thnx!

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!