Subscribe to the TST RSS Feed

How to Create a Separate Home Partition in Ubuntu Linux

Veronica HenryOne of the joys of being a Linux user is the flexibility. Virtually every aspect of your system is customizable. Testing and tweaking desktop managers, compiling a new kernel, fearlessly contributing through trial and error, to the open source movement. Yet, all this flexibility is not without its perils.

It’s happened to us all at some point. We’ve tinkered ourselves into a technical abyss rife with grub errors, system freezes, or black screens of death-our systems fried. When all attempts at recovery fail, we sigh, break out our LiveCD and reinstall. While devastating, the pain can become compounded if you have not properly backed up the data residing in your /home directory.

 

Advantages of a Separate Home Partition

The general consensus among Linux enthusiasts is that the /home directory should be placed on its own partition. There have even been proposals that this be made a part of the default installation process.

The separation accomplishes two things: facilitates cleaner, simpler Linux upgrades and provides a safe haven for your data in the event of a problem with your primary Linux partition. As a side benefit, if you run multiple Linux flavors (i.e. Fedora, openSUSE, Mint, etc.), you’ll be able to use the same /home partition for each of these.

Ubuntu Linux operates on a 6 month release cycle. Clicking the upgrade button in the synaptic package manager will upgrade your distribution – albeit, with varied results. Some upgrades work flawlessly, while others are plagued with problems. Consequently, many agree that a clean install is the preferred option.

A clean install does exactly what the name implies, wiping the hard drive during the installation process. One can easily back up their data and then restore it, but this step can be eliminated if /home is on a separate partition.


Creating a Separate Home Partition in Ubuntu

Convinced? Wondering how to make the change on your existing Ubuntu installation? Great! Without further ado, we’ll walk through the simple steps to repartition your drive, moving your /home directory to its own partition.

It is important to note, that while these steps (or the many variations on them) have been successfully performed many times over, the potential for data loss exists.

It is imperative that you backup your data before you begin. You can use an external drive, online storage systems like Ubuntu One or Dropbox or whatever solution you choose. But I can’t stress the importance of this step enough.

  1. Assuming you’ve backed up your data, you’ll need to boot from your LiveCD. Why? Basically, because you can’t alter a partition if it’s mounted. So, after booting, select your language, and then select: try Ubuntu without installing.
  2. There are several partition managers available, but for this tutorial, we’re going to be using the Gparted partition manager. From the application menu, click on:

    System > Administration > Gparted

     
    How to Create a Separate Home Partition in Ubuntu Linux

  3. When Gparted loads, you’ll see a graphical depiction of all the partitions on your hard drive. You’ll need to decide which partition you want to resize to create space for /home.

     
    How to Create a Separate Home Partition in Ubuntu Linux

  4. Right click the partition you choose and click, Resize/Move

     
    How to Create a Separate Home Partition in Ubuntu Linux

  5. As most important data is stored at the beginning, or the left side of the partition, I suggest you resize from the right side. In terms of size, needs vary depending on the user, but allocate as much room as you can for /home.

    Use your mouse and drag left, to resize the partition and then click, Resize/Move.

     
    How to Create a Separate Home Partition in Ubuntu Linux

  6. You should now have a space called unallocated. This will be the home of your new partition. Select this space with your mouse and click on Partition > New from the menu.

    Now select the filesystem you want, ideally, this should match your existing file system , ext3 or ext4.

    *make note of your partition names, we’ll need these later.

     
    How to Create a Separate Home Partition in Ubuntu Linux

  7. Click Apply twice.
  8. Click Close, then Quit.
  9. Now we’ll need to tell Ubuntu how to use the new partition. Open up a terminal and type the following commands:

    To mount the new partition, (for this example, assuming partitions sda1 and sda2 and file system ext3, yours may be different):

    sudo mkdir /old
    sudo mount -t ext3 /dev/sda1 /old
    sudo mkdir /new
    sudo mount -t ext3 /dev/sda2 /new

    Now backup the old /home and move to the new partition:

    cd /old/home
    find . -depth -print0 | cpio –null –sparse -pvd /new/
    sudo mv /old/home /old/home_backup
    sudo mkdir /old/home

    Tell Ubuntu to use the new partition as /home:

    sudo cp /old/etc/fstab /old/etc/fstab_backup
    gksudo gedit /old/etc/fstab

    This will open fstab in Gedit, now type the following:

    /dev/sda2 /home ext3 nodev,nosuid 0 2

  10. Save the Gedit file, exit and reboot. Viola, you should now be using your new separate /home partition!

 

When Things Go Wrong …

Inevitably, things go wrong. What should you do, you ask?

The Ubuntu forums and IRC channel are an excellent resource. However if you’d like to skip the troubleshooting and start over, type these commands to restore things to their previous configuration:

sudo mkdir /recovery
sudo mount -t ext3 /dev/sda1 /recovery
sudo cp -R /recovery/home_backup /recovery/home
sudo cp /recovery/etc/fstab_backup /recovery/etc/fstab

Creating a separate /home partition may seem like more trouble than it is worth, but in the end, can save you countless hours of exasperated troubleshooting on Ubuntu’s next update.

This isn’t an exercise you should undertake lightly. However, knowing your data is safe and sound is a powerful incentive. Still, as hardware failure looms ever possible, it is best to develop and stick to a consistent backup schedule.


 

Related Posts:

Tags: ,


 

13 Responses to “How to Create a Separate Home Partition in Ubuntu Linux”

  • Michel Says:

    Great article.
    Congratulations!

  • Heather Ackmann Says:

    Nice article, Veronica. Thanks!

  • Zach Says:

    Well done. I’m not a Linux user but I feel like I could create a separate home partition in Ubuntu now!

  • Veronica Says:

    Thanks Michel.

  • will their be a video training for Ubuntu linux?

  • Eric Says:

    Very well done! Thanks a lot Veronica.

  • Hi Demetrius,

    At the moment we have Linux+ training that covers the fundamentals of all linux systems, including some info about Ubuntu. Take a look at the course outline and let us know if you have any questions: http://www.trainsignal.com/CompTIA-Linux+-Training-P53.aspx

    Kasia

  • Hi Kasia,

    Thank you for responding and i do see the training. i do have one more question. when will the training for windows 7 be available? and do you plan to have more SQL training?

  • Hi Demetrius,

    Thanks for the questions! Our Windows 7 training is currently in production, Dave Shackelford is working on it. At the moment I don’t have a release date yet, but it’s scheduled for mid Q2.

    Our next SQL Server 2008 training will be available by the end of February, it will be an advanced course in SQL Server administration. It is scheduled to be released on Feb 23rd, but this date might change slightly.

    In either case, if you’re on our mailing list you will get an email notifying you of when the new courses come out.

    Let me know if there’s anything else you need!

  • Henry Says:

    I know you have Linux plus training which I studied and felt pretty dry. What I was hoping is hand on linux basis (just like windows xp course) where you setup a server and clients and then use then as what you would normally do in the production enviroment. That would be a great traing for users who need and want to learn Linux but doesn’t know where to start. I suppose anyone can download open source Linux and install and play with it. But I can assure you that this will not help for job interview or in production enviroment where you have to setup dhcp, dns, nat and so forth and interact with client machines. How would backup/recovery work, and windows machine use samba share and cups printing will be fun to learn between typical windows system and production linux servers and clients. There are so much Linux video out there already. But what they are trying to teach is how to setup something and never really a complete pictures. I know how to setup something, but how does client work with this configuration. How does client user dns, dhcp and a slew of other services? Can you setup a home folder on the client, how about shared folder for multiple users access? Really, I would love to see those in action which what Trainsignal do it best: senerio based hand on training. It would be worthwhile and help lots of people of learn the basis of Linux which seems to popular more than ever. And you can go from Linux server side trainig video and advance user would love it too.

    I really do hope trainsignal consider basic Linux for Linux newbie like up. And please don’t worry about the certification stuff. You already have the video for that and let certificate persuer worry about that.

    I hope this make sense.

    Sincerely,

    Henry

  • Hi Henry,

    Thank you for the very detailed suggestion — you’re absolutely right, there is a need for Linux training that’s hands-on, covers all of the important fundamentals, and offers scenarios to show how all of it can be applied in the real world. What a great suggestion!

    I just forwarded your entire message to our Product Development team and hopefully we can get this training going in the next few months. I’ll try to keep you updated on the progress.

    Thanks again Henry!

    Kasia

  • Mel Says:

    Great article. The last time I did anything with Linux was forever ago. Gee, this is a whole lot nicer. Thanks for the update.

  • Veronica Says:

    Thanks everyone, glad you enjoyed the article.

Leave A Comment: