One 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.
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.
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.
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
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.
Copyright © Train Signal Inc. All Rights Reserved.
Michel Says:
February 2nd, 2010 at 11:09 am
Great article.
Congratulations!
Heather Ackmann Says:
February 2nd, 2010 at 11:48 am
Nice article, Veronica. Thanks!
Zach Says:
February 2nd, 2010 at 11:50 am
Well done. I’m not a Linux user but I feel like I could create a separate home partition in Ubuntu now!
Veronica Says:
February 2nd, 2010 at 12:13 pm
Thanks Michel.
Demetrius Glass Says:
February 2nd, 2010 at 12:14 pm
will their be a video training for Ubuntu linux?
Eric Says:
February 2nd, 2010 at 12:38 pm
Very well done! Thanks a lot Veronica.
Kasia Grabowska Says:
February 2nd, 2010 at 12:39 pm
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
Demetrius Glass Says:
February 2nd, 2010 at 12:52 pm
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?
Kasia Grabowska Says:
February 2nd, 2010 at 2:32 pm
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:
February 2nd, 2010 at 6:32 pm
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
Kasia Grabowska Says:
February 3rd, 2010 at 10:36 am
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:
February 3rd, 2010 at 3:48 pm
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:
February 4th, 2010 at 3:29 pm
Thanks everyone, glad you enjoyed the article.