Ubuntu – Cloning multiple partitions in Ubuntu

backupclonezillapartitioning

I am attempting to clone multiple partitions with either Clonezilla or dd without cloning the whole drive which consists of:

  • 1 – a boot partition
  • 2 – a home partition

Seen below is the original installation on a 128GB SSD, which I successfully cloned to a larger 250GB. This as a backup that I would later try to resize and shrink down. ORIGINAL INSTALLATION

Below is a photo of a working clone the operating system which is now about 41gigs in size total after being resized with Gparted.

enter image description here

I have tried to clone these partitions to my 64GB USB disk as a working portable backup , but have ran into some issues.

I have tried using:

sudo -s
dd if=/dev/sdb of=/dev/sdc & pid=$!
while kill -USR1 $pid; do sleep 1; done

This bit for bit cloning method tried to copy the unallocated space on the input drive, which obviously wont work because the output disk is much smaller.
In a second attmept I was able create a partition table on the destination disk that matched the source's sizes. I then tired to use boot repair and got teh following output:

http://pastebin.ubuntu.com/14503890/

Moving onto to Clonezilla options; normally a disk to disk would be my choice, but since the destination drive is smaller than the source, Clonezilla will not allow this.
I do see an option to copy ONE partition at a time using disk to disk option, but do not see how I might clone all three at once. I know there is an option to do this with saving as image but I want the USB to be bootable.

One way I can think of making this work would be to make an image of the partitions I want to clone using disk to image, then restoring the image to the 64GB USB disk later, but after trying this I ran into more errors.

After making an image of /dev/sdb/I attempted to restore the file but got this error about /dev/sdb2/ missing:

enter image description here (/dev/sdb is the target for this session)

So perhaps my image was ok, but that it didnt properly read the /dev/sdb2/ so I checked it with Gparted again and saw this following here:

enter image description here

I checked with Synaptic Package Manager to see, and I already have e2fsprogs v1.42.9-3 installed. So I did some reading and tried the following solutions that have worked for other people:

sudo fsck.ext4 -f /dev/sda6
sudo touch /forcefsck
Sudo reboot

this seemed to work temporarily, as after another reboot or two, the problem still persists. I am assuming now that during the device to image process in Clonezilla that my /dev/sd2/ was not read properly, as I can not even access this partition in Nautilus or Gparted. I am thinking that is may have been caused by the re-sizing of the drive, but can not be sure, as it will still allow me to boot to this installation.

I think I can actually clone these two partitions to image, and then restore them bu I need to address this problem of :

The following list of software packages is required for ext4
file system support: e2fsprogs v1.41+.

Could this have come from re-sizing the partition? If so, how come I am able to boot to this installation if it cant be read ?

Best Answer

Just dd the section of the disk that goes from the start of the disk to the end of the last partition.

In your case the last partition is /dev/sdb3, so:

  1. Find /dev/sdb3's end using sudo fdisk -l /dev/sdb (End column);
  2. dd the section of the drive that goes from the start of the disk to the end of /dev/sdb3 (let's assume that the end of /dev/sdb3 is on byte 50000000000 and that the target drive is /dev/sdc for the sake of the example): sudo dd if=/dev/sdb | head -c 50000000000 | sudo tee /dev/sdc