0

I'm migrating from Windows to Linux but I have to keep a working Windows installation for backup. The source HDD is this:

$ sudo fdisk -l /dev/sdd
Disk /dev/sdd: 465,78 GiB, 500107859968 bytes, 976773164 sectors
Disk model: SDSSDH3500G     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: <ID>

Dispositivo Start Fine Settori Size Tipo /dev/sdd1 2048 206847 204800 100M EFI System /dev/sdd2 206848 468991 262144 128M Microsoft reserved /dev/sdd3 468992 430548991 430080000 205,1G Microsoft basic data /dev/sdd4 655828992 976771071 320942080 153G Microsoft basic data

I want to clone the first three partitions only to another HDD, preserving everything is needed to boot the O.S.

The easiest solution would be to clone the whole HDD and then remove the fourth partition, but unfortunately the destination HDD is too small.

Clonezilla doesn't allow to select which partitions to copy, unless you clone one-by-one, but for the reasons above I really don't want to create the partition structure manually.

In Cloning multiple partitions in Ubuntu and Is there a way to DD multiple partitions into one raw image file in such a way that it boots? there are answers that suggests to dd from sector 0 to the desired last one, but comments say it don't work.

Is there a reliable way to do such a "simple" job?

Lorenz Keel
  • 8,905
Mark
  • 507
  • You can clone individual partitions with GParted. Presumably restoration would be a repeat operation in the opposite direction. How large is the destination HDD. I don’t understand your comment about manually creating the partition structure. Hope this is helpful. – PonJar May 06 '20 at 09:02
  • The destination HDD is large enough to barely contains the first three partition but, right now, I don't have a third place where to put the largest partition. I need to copy the partitions directly from source to destination. – Mark May 06 '20 at 09:10
  • I meant, i don't want to create partitions with gparted or fdisk because I wasn't able to make the new HDD bootable! So I'm looking for a byte-to-byte copy (like dd should do) in order to avoid those problems. – Mark May 06 '20 at 09:12
  • Cloning with GParted is very much like a copy paste operation. You don’t have to set up the destination partitions, you just need unallocated space available. Try it on the small partition and you will see – PonJar May 06 '20 at 09:16
  • @PonJar, glad to know that! I'm trying as soon as possible. I didn't understand how it works, then. – Mark May 06 '20 at 13:49
  • @PonJar, well the problem is only the first and third partition (/dev/sdd1 and /dev/sdd3) are enabled for copy in GParted. I cannot do anything with the second one (/dev/sdd2). – Mark May 06 '20 at 14:04
  • The dd AKA "Data Destroyer" is for same size to same size copy. And with UEFI/gpt partitioning, you have GUID in primary gpt partition table at beginning of drive, backup partition table at end of drive and in each partition. If those get out of sync you have major issues. Or dd is only for full drive to full drive copy with gpt. The Microsoft reserved is an unformatted partition, so gparted does not like it. But it has to have the correct GUID partition type to be a Microsoft reserved. It is a required partition before first NTFS partition. – oldfred May 06 '20 at 17:08
  • @oldfred, so there is a procedure to restore those GUID? I mean, I can easily dd from 0 to the last available sector. In this way it should be ok for everithing but the backup at the end of the drive? Can I restore it manually? – Mark May 06 '20 at 18:02
  • I have seen some use gdisk, do not know details. You do have to leave 33 sectors at end of drive for backup gpt partition table. http://www.rodsbooks.com/gdisk/repairing.html – oldfred May 06 '20 at 18:36

1 Answers1

1

Try clone the entire disk with Clonezilla (in 'raw' mode - or whatever it is called) or dd and then delete the unnecessary partition with gparted. If your target disk is smaller then source -- don't worry, Clonezilla will just freeze in the end and the last partition on target will be broken. Just reboot and delete it anyway.

Copying partitions with gparted will not give you working bootloader.

Sergey K
  • 401
  • I've just tried with Clonezilla. I had to set some "expert" options to avoid the initial size check on the destination HDD. But it doesn't even begin and returns this error about the source HDD: unknown partition table. – Mark May 06 '20 at 17:59
  • I found the exact description of the process https://www.tecmint.com/linux-centos-ubuntu-disk-cloning-backup-using-clonezilla/ Look at steps 8, 11 and 12; did you do them exactly the same? – Sergey K May 06 '20 at 18:48
  • yes I did exactly the same. The only difference was I used the "expert" mode to skip the check of the destination size. After asking two times if I'm sure to destroy the destination HDD, it returns the error above - instead of talking about the bootloader. – Mark May 06 '20 at 19:03
  • Such method worked for me several times... So, if your source HDD is not broken, I suggest boot from live and use dd. There are other clonezilla-like utilities like g4l and similar, but they might not work as well... – Sergey K May 06 '20 at 20:44
  • the HDD is not broken at all! I'm using it everyday and I did an error check before. I asked my question to avoid a trial and error pattern. – Mark May 07 '20 at 14:22
  • Anyway, why should I boot from live? Both source and destination HDD are on USB adapters and not mounted. Are you suggesting to dd from 0 to the last sector of the third partition? – Mark May 07 '20 at 14:22
  • You are right, no need to load from live. First I would try dd as you say. – Sergey K May 08 '20 at 02:44