Graphic, Advertising and Web Design. 
Symsys Inform Blog HomeAIX Systems and Linux Support Specialists

Nod Antivirus Official NZ Reseller International Association of Web Master and Designers Cisco Certified Engineers Golden Web Award Winners Linux Spacialists Thawte SSL VS Security Partner

Symsys Ltd Text logo in the banner area



Over the years I’ve been a helpdesk agent, a telecommunications network administrator, an I.T. engineer, a .NET programmer, a web applications programmer and a Linux evangelist (The last one is a full time job but it doesn’t pay as well as the others). Needless to say that in these roles and over such a long period of time I’ve used my fair share of cloning programs and definitely used more than my fair share of partitioning tools. Clonezilla and GParted have really made an impression on me though.

Let’s just take a scenario where you might use these programs. You’ve installed your Linux Desktop machine, you used guided installation for partitioning, but you were clever enough to make home a seperate partition. Automatically Linux installers tend to assume (On guided partitioning) that you only need 7 - 8GB of space for the main operating system and gives the rest of the drive to swap and home. This is absolutely fine, until of course you install too many programs that require /usr/sbin /opt and /etc, at which point you find yourself quickly running out of space on your main partition and the rest of you’re entire disk is used up with free space.

So given this scenario what do you do? Well if you’ve got a free hard drive you could boot up a Live CD, mount your partitions, create new partitions on your second hard drive for  /etc, /var, /opt, /usr or any other folder that has a lot of data in it and could free up some space by moving the data there, then mounting them with fstab spreading your file system around another one or more disks. The problem with that is that you’re then using up another/more hard drive(s) and worse yet you’re also spreading your file system accross lots of different drives, some people actually choose to do this, it gives multiple points of failure instead of just the one, the problem though is what happens if the drive that holds your /etc /opt and /var folders dies while everything else stays in tact? Or what happens if on a boot up, one of these very important mount points fails. There are pro’s and con’s for it and against it as with everything. My personal choice if the primary drive was big enough, and I had a second drive to move data to temporarily would be ….

Create folders in /media for the data you need to move around, for example mkdir /media/TempHome, then (If your other drive is sdb with 1 partition, formatted as ext3 for example)

mount -t ext3 /dev/sdb1 /media/TempHome,


mkdir /media/TempHome/home/

cp -Rp /home/* /media/TempHome/home/

This will copy everything from the /home/ directory (Including other peoples home folders if it’s a multi-user system) to the second drive (sdb1, mounted at /media/TempHome) maintaining all permissions on files and folders so that the same command later, with locations swapped around, will bring everything back, without the need to mess around setting permissions back. The next thing to do is obtain a copy of clonezilla, and burn it to a disc as a bootable CD. Reboot with Clonezilla in the CD drive and once it boots up you have a very self explanatory guide to help you “Clone” your main hard drive (Probably sda or hda on most systems, but it can be different), effectively backing up your existing system, “as-is” without changing anything, to a different drive, network location or removable media as a clonezilla image. This is an important step in the process because when you’re playing with partitions you never know if it’s definitely going to work without breaking things and having that clonezilla image allows you to just boot back up into clonezilla upon finding your broken system, select the image, select the primary drive and hit restore.

So you’ve copied your /home data to a seperate hard drive, you’ve cloned your entire system “as-is” and saved the clone image to the second drive with the use of Clonezilla, what you need to do now, is change your existing partitions around to make them more usable and give your main system more space. Sounds easy right? Well it is. You should have already downloaded GParted (Although I didn’t tell you to yet you should have guessed :D) and burned it to disc. Stick the GParted CD in the drive and boot up your machine, you’ll automatically boot into a fluxbox interface and the GParted program will start automatically as well. From previous experience GParted doesn’t usually have a problem, deleting, re-sizing or adding new partitions, but everytime I’ve tried to move one, it’s failed on me, so my recommendation is to delete your home partition on /dev/sda6 in GParted(Remember you’ve copied your entire home folder to sdb already AND you’ve cloned the drive, so you’ve double backed everything up already in case of disaster), delete the swap partition as well if it’s in the same extended partition, then delete the extended partition, this shouldn’t take much time at all.

Next on the list is to enlarge your main partition (we’re assuming /dev/sda1) to an appropriate size, now regardless of what size your hard drive is, you don’t want to waste space, and unless you’re a software hoarder (I am) then you probably won’t need an sda1 partition any larger than about 50GB maximum. So let’s re-size that partition in GParted using the GUI, make it 50GB in size (50000MB), this can take a bit of time, as it tends to do two file checks while re-sizing (This is a good thing that lots of partition manipulators don’t do). Once it’s done we can go ahead and create a new extended partition that spans the entire free space on the drive. Next create a new SWAP partition, this needs to be EITHER twice the size of your RAM, so if you’ve got 1GB of RAM you should make SWAP 2GB but I usually just go for 2.5GB no matter what, if you’ve got less RAM you’re more likely to run out and if you’ve got more RAM then it won’t hurt because you’ve likely got a large hard drive anyway. Anyway, once you’ve created the partition, you’ll need to highlight it and choose swapon from the menus in GParted, this will activate the swap partition for your system to use.

Now that you’ve created swap you need to create your home partition again, obviously the size just needs to be the remaining space left on the hard drive, unless you want other partitions on it because you’ve got a 1TB drive or something. That should be set to ext3 when you format the partition. Next you can close the GParted GUI but don’t reboot yet. Click on the console icon on your desktop and type the following commands.

mkdir /media/Home/
mkdir /media/OldHome/

mount -t ext3 /dev/sda6 /media/Home/
mount -t ext3 /dev/sdb1 /media/OldHome/

cp -Rp /media/OldHome/home/* /media/Home/

Now working on the assumption (As we have been throughout) that you’re using sda as your main hard drive, it has /dev/sda1 as the primary partition, then an extended partition of /dev/sda2, then swap is /dev/sda5 (Remember the first LOGICAL partition on a hard drive is ALWAYS 5) and finally /dev/sda6 is going to be mounted as /home on your main system and you had two seperate partitions in the first place for home and your main system, this should be it and you SHOULD be able to reboot.

If however you didn’t have a seperate home partition in the first place and have been following this to perform specifically the task of creating a seperate home partition, you’ll still need to do the following before you reboot. You should now have all your data in the right place, with the right permissions and you should also still have the data backed up in both normal files and the form of a clonezilla image on that second hard drive, so we’re nearly finished. All you need to do now is edit you’re /etc/fstab file on your main system before booting into it, otherwise you won’t be able to login. So follow the remaining commands before rebooting.

mkdir /media/System

mount -t ext3 /dev/sda1 /media/System

cd /media/System/etc/

nano fstab

Then add the following line to it, to make sure it mounts your /home partition on boot:

/dev/sda6       /home           ext3    defaults        0       2

Be careful when editing /etc/fstab, make sure you have the correct partition number (/dev/sda6 for example) and make sure you have the right mount point (/home in this case) and the right file system (ext3 usually but occasionally people use ext2 or other file systems) and you should be fine.

Either way, hopefully you can see from the seriously low amount of command line actions required in this guide, Clonezilla and GParted are excellent tools for people who need to do all the technical stuff, but just aren’t strong on the command line or prefer something graphical, or even if you just don’t have the time to type all the commands, plus it’s far less risky to use a program specifically designed to only issue certain commands and does it with everything unmounted, than trying to unmount the right partitions at the right time, issuing all the commands by hand which could be proned to errors and you’ll still need something like Clonezilla to clone the drive instead of just copying it elsewhere anyway.

Filed under: Linux Reviews ... Comments (0)

Tags: , , , , , , , , , , , , ,


Enter your email address:

Delivered by FeedBurner