4

I would like to clone a single partition off of my current HDD to a newer, larger SSHD. The partition that I would like to clone is running Linux Mint 17.1. Using a bootable Clonezilla USB, I have been able to clone the entire old disk to a new disk, but the Mint partition is preceded by a large, messy Windows 8.1 partition. The Windows 8.1 partition is failing on the HDD, however, so I only want to keep the Mint partition.

Could I do this with Clonezilla, GParted, dd, or some combination?

2
  • Clonezilla should also allow you to clone partitions and not only whole disks. I am not sure, but also GParted should allow you to copy partitions to unallocated space. dd should be possible, but if you are not very carefully, you can make a mess out of both of your disks. Better use Clonezilla or maybe GParted.
    – Byte Commander
    Jun 16, 2015 at 12:19
  • How would I do this with Clonezilla? Using the partition-local partition option, I am not able to target the new drive. I think it's because the new drive is completely unallocated and has no partitions set up.
    – errolflynn
    Jun 16, 2015 at 14:50

4 Answers 4

3

Don't know what an sshd is (related to storage) ... did you mean SSD?

There are 50+ different ways to do this.

  • dd
  • ddrescue
  • partimage
  • clonezilla
  • fsarchiver
  • gparted
  • rsync
  • any normal backup/recovery too

So the best answer for you will depend on your skillz with any of the above commands AND how good you are in correcting the /etc/fstab after the restore to a new disk is completed. If you know fstab, grub-install, update-grub and blkid well, any of these tools are trivial.

Anyway, the man pages for any of those tools explains how to use them. Also, don't forget to create the partitions on the target disk for swap too. It would be smart to use GPT (not MBR) formating if your situation allows that. If there isn't any Windows involved on the new system, go for it - use GPT and be happy. Windows only allows GPT if UEFI boot AND a 64-bit OS.

Of course, we are having to make hundreds of assumptions about your setup here - if you use LVM, encryption, or anything strange like booting off xfs or zfs partitions, then all bets are off.

To get more exact suggestions, post the output from sudo parted -l please. Have both disks connected when running it.

The general steps are:

  • Boot off a liveCD (disto or Rescue Disk)
  • Create the partition table on the new disk (GPT recommended)
  • Create the desired partitions on the disk

    • /boot
    • /
    • /home
    • others .... /var /opt, ....
    • swap
  • Size each as desired, but be smart. Also, it is smart to leave some leftover space that can be added later to partitions that need it.
  • use the listed tools to copy over the data ... I'd probably use ddrescue. sudo ddrescue source target Use the partition device for both sides. Something like /dev/sda20 /dev/sdb34 (those are NOT correct for your situation)
  • mount the new disk to a temp location - /mnt is good
  • edit the /mnt/etc/fstab to point partitions to the correct place using either the path to the partition or a LABEL or a UUID
  • install grub onto the new disk - lots of howtos for that (should include a chroot cmd and may include multiple mount commands)
  • reboot - disconnect the liveCD before the 2nd boot happens Be happy.

Again, if you want better help with more details, post the output from the requested cmd.

BTW - you can safely delete the Windows partitions, assuming the old disk will be left in the computer. That isn't clear.

4
  • SSHD is a hybrid drive. A normal HDD with rotating disks plus a flash technology (SSD-like) cache memory. Read wikipedia: en.wikipedia.org/wiki/Hybrid_drive
    – Byte Commander
    Jun 17, 2015 at 11:29
  • Model: ATA WDC WD5000BPKT-7 (scsi) Disk /dev/sda: 500GB Sector size (logical/physical): 512B/4096B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 41.1MB 41.1MB primary fat16 diag 2 41.9MB 830MB 789MB primary ntfs 3 830MB 454GB 453GB primary ntfs boot 4 460GB 500GB 40.5GB extended 5 460GB 494GB 34.2GB logical ext4 Model: ASMT 2105 (scsi) Disk /dev/sdb: 1000GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags
    – errolflynn
    Jun 17, 2015 at 23:58
  • That's messy. I have no rep, so I can't post a screen shot. There are 5 partitions on the disk at /dev/sda of msdos partition table type. I only want to copy partition 5, which is contained within partition 4. The disk at /dev/sdb connected by USB is completely empty sans an msdos partition table.
    – errolflynn
    Jun 18, 2015 at 0:03
  • To clone only 1 partition, I would use gparted. That is a Linux GUI tool. You'll need to manually create the target partition on the new disk.
    – JohnP
    Nov 22, 2017 at 2:40
3

You will need to have both partitions mounted, for instance on /old and /new. Then use the rsync utility:

rsync -aruv /old/* /new/

If the old partition is your root system, you will want not to copy over the contents of some directories. Just exclude them, such as:

rsync -aruv /* /new/ --exclude=/dev/* --exclude=/proc/* --exclude=/run/* --exclude=/sys/* --exclude=/tmp/* --exclude=/new

Do not forget that last one! (Been there, done that. ;-) ).

HTH

2
  • Would /dev/sdc1 or /media/usb be the mount point?
    – errolflynn
    Jun 16, 2015 at 14:49
  • /dev/sdc1 would be the target partition on the device. /media/usb could very well be the mount point, though usually you will find /media/<username>/<volumename> The mount command (with no parameters) will tell you if it has been mounted automatically.
    – ALAN WARD
    Jun 16, 2015 at 15:19
0

For example you want to clone /dev/sda1 ext (linux) partition to /dev/sdb disk.

First Install gparted and gddrescue.

Then use gparted to create /dev/sdb1 partition with the same size as /dev/sda1 or larger.

Then use the following commands in terminal to clone partition and expand filesystem:

sudo ddrescue -B -v -d -n --force /dev/sda1 /dev/sdb1 ~/ddrescue_clone_sda1-sdb1.log
sudo ddrescue -B -v -d -r 2 --force /dev/sda1 /dev/sdb1 ~/ddrescue_clone_sda1-sdb1.log
sudo e2fsck -f -y -v -C 0 /dev/sdb1
sudo resize2fs -p /dev/sdb1

Commands explanation:

  1. Clone partition without retrying to read bad blocks
  2. If there was errors of reading (bad blocks) with first command (see log file), this one will try to read them 2 times more.
  3. Check filesystem on the cloned partition.
  4. Enlarge the filesystem to partition size.

And don't forget, if you cloning boot partition you need to set boot flag after cloning. And install grub.

You can set the boot flag for /dev/sdb1 in gparted.

To install grub on new /dev/sdb disk run these commands:

sudo mount /dev/sdb1 /mnt
sudo grub-install --root-directory=/mnt /dev/sdb
sudo umount /mnt
0

I got it to work using the above -icds and leaving the default -r resize but I did have to create the partitions first on the target drive (first one being FAT32) , roughly sized the same as the source partitions, and in the clonezilla expert mode those above settings appear, there is also a partition setting for do not overwrite the target partition table... etc.. and I chose resize partition table proportionately. that way I got past the OP message. Been using CZ for years and recommending it, and I never knew any of these tricks. expecting more computer rabbit hole hell, it booted up straight off like the source. sometimes you have to win in these things. and it ought not to matter, but source and target machines were Ryzen 5 CPU's and same model and brand. AND even though I only created 4 partitions on the target drive, it wrote correctly 5 partitions to it. so now I am not sure if I tried to do it on a single or no partition target with the option for proportional partition table.

1
  • ideally Clonezilla would ask at size problem failure and ask if user would like to choose the nuclear option. just do it.
    – pierrely
    Mar 11 at 8:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .