Clonezilla: Copying and restoring partitions on the same HDD
Steven Shiau had asked me how I solved one of my problems while using Clonezilla. Therefore, I am going to post a response/tutorial on this website.
If you want a quick view of something you can do with the knowledge in this tutorial, then scroll ALL the way down to the end of this individual posting.
By the time you're done with this tutorial, you ought to be able to do this:
Partition 1 ---copy to---> Partition 3
As with anything that involves messing with the hard drive disc (HDD), backup anything and everything you can before playing with the HDD. I hold no responsibility if you screw up your harddrive or anything else. Do this at your own risk.
Partition 3 ---restore to---> Partition 1
Before continuing, I'm hoping you've got multiple partitions on your HDD. This tutorial was meant for one HDD. In this tutorial, it hopes that you have an empty partition or else a good amount of free space available on the HDD, which needs to be larger than the amount of data used up by the partition you want to copy. If you don't have that free partition, I suggest making it with GParted.
A person has a distribution using the Linux kernel (Kubuntu in this case). Kubuntu is located on partition "hda1." This partition is one of many that is on the HDD. The person wants to copy the contents of this partition and move them to a different partition on the same HDD.
An unfortunate part of Clonezilla is that it has the habit of backtalking to the user and saying the most obvious things.
hda1 (Kubuntu) ---> hda3 (blank with empty space)
Regardless, however, there is another way to copy a partition. This way is through the originally intended way: The Textual User Interface (TUI).
When the user first tried using Clonezilla with the command-line interface to copy the partition to hda3, it said that it could not copy the partition because the hard drive was already mounted.
"Well, of course it's already mounted!" said the user. "No duh!"
For some odd reason, copying the partition wasn't the same as it was with Windows XP. This could have been something to do with the hardware she was using, or it could have been an entirely different reason.
First off, a person needs to have an extra partition on the HDD. That partition has to be larger than the partition being copied.
For instance, if the partition being copied is 4GB with 15GB space left, then it would be wise to have a blank partition is that is sized at 5GB.
I'm sure you could get away with having the partition at 4GB. However, you never know how well the compression will work.
Your partition table doesn't need to look just like that. You could have an extended partition and save to a partition on the extended layout. You just need to follow some of the basics: free space, file-system, etc.
HDD = 80 GB
hda1 = 15GB total with 4GB used
hda2 = 2GB (swap space)
hda3 = 5GB (blank partition with EXT3 format)
With that being said, Clonezilla doesn't copy the entire contents of the drive. In other words, all of the space not being used will not be copied. There may be ways to still copy everything even the blank space; however, I am not aware of such details at the moment.
Also, it is suggested that you format the "blank" partition with the same file-system you are copying. This may or may not help, but it is the method I use. I said "blank," because formatting the partition with a file-system seems to take up some space. You'll want to take that into account when copying materials from one partition to another.
With more of the details out of the way, the next few steps is to simply copy the partition with the TUI to a different partition. Using the TUI isn't too difficult, so I won't go into too many details about that.
One of the things that will happen is that it will request you give the copied material a name. I suggest you give it a name according to date, operating system, and partition. I also suggest you use a hyphen between the date, operating system, and partition. Crunch each of the details together and you'll only be using two hyphens.
Now that you've backed up the partition, you'll need to decide what you will do next.
The whole idea of backing up the partition is for data recovery. In the situation that you mess with the drivers, x configuration, or something else and lose control, then you'll probably want a good data recovery option.
If you're in the mood for playing dice, you could take the next steps at data recovery:
The next few steps will include you deleting the partition with the operating system. Therefore, I highly suggest you backup by alternative means anything you care about.
For the next few steps, you'll be using GParted. I suggest GParted, because it comes with the Clonezilla-Live CD.
1. Delete the partition you just copied.
Do not delete the other partition that has the copied information, which is the one with the compressed image.
1a. Use GParted to delete the partition you copied.
1b. Reboot the computer
TIP: Use the Force VESA GParted if you keep getting annoyed by the available options.
2. Reboot the computer and go into the command-line interface.
I can't exactly remember the correct way to get into the command-line interface. I think a person needs to use the following: sudo su
You need to get into root or something like that.
3. For the next bit of information, more detail needs to be covered.
Some HDDs are different, and they often assign different names to the partitions. If you don't know which partition is which by now, you should go to GParted and review them. Copy down the name of each partition. Take a snapshot if you can and print it out.
type the following:
hit enter (or return) or whatever people call it these days
mount /dev/hda3 /home/partimage
now hit enter or return.
/opt/drbl/sbin/ocs-sr -l en -p poweroff --no-fdisk restoreparts 070707-kubuntu-hda1 "hda1"
A slight explanation of the code:
If you don't know what mount means, then search, Google, or use Wikipedia for it. I will say that backing up and restoring is different when using NTFS and Linux. This tutorial was meant for Linux.
That tells it to give output in the language of English.
That tells it to use the power option of poweroff after doing its tasks. You could use reboot instead of the word poweroff. This would make the computer reboot.
This tells the computer to NOT format the disk.
All of this assumes your partition is blank with empty space.
This isn't the pseudo-blank type of partition I was talking about before. There is no file-system to the new, blank partition: hda1
This is pretty much a given. It tells the computer to restore the parts. In this case, it should be "part." The part being restored is described in the next field.
This part is the name of the image you created from copying hda1 and put onto hda3.
In case you're curious, the quotation marks are suppose to be there. This is the partition the image/part is going to be restored to. It has to be this partition. You have to restore data to the partition that was copied. There may be some workarounds, and I suggest you read the Clonezilla forum for that. I think I read about only one.
And that's pretty much it. Now, if you screw up after that operating system install, you don't have to sit around waiting a good hour to put it all back in. Nor do you have to reinstall that other Linux OS once more. A good 5GB compressed image tends to decompress within 10 minutes. Compare that to a 20 or more minutes install and you'll notice that restoring from a compressed image is a much better, faster, axiologically and pragmatically enlightening choice.