I needed to clone my laptop disk, but I didn’t do it right.
Last week, by chance, I run a SMART long test on my laptop disk and it
found two errors in one partition. I did a backup image of that
partition the same day using dd, and then I overwrote the partition: 285
new errors appeared.
I bought a new disk which arrived today.
Meanwhile, I cloned the entire disk, but I did a mistake: instead of
cloning the disk whole I cloned the partitions one by one, plus the mbr
(and the 63 next sectors) and also the extended partition.
Today I used dd to restore the partition table. My mistake is that the
procedure does not restore the logical partitions. Not knowing how to do
it, and not having access to write here and ask (I only have this laptop
here), I resorted to dd the entire original disk to the new disk.
The procedure worked, to the point that the first read error appeared
and dd stopped at partition 8. I then restored that partition from the
good copy on a backup disk.
Good enough for the moment, as that means I can use the laptop again.
But the logical partition 9 is not there. Look at the partition table of
the new disk:
> minas-tirith:~ # fdisk /dev/sda
> omitting empty partition (9)
>
> Command (m for help): p
>
> Disk /dev/sda: 500.1 GB, 500107862016 bytes
> 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
> Units = sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0xb4e583dd
>
> Device Boot Start End Blocks Id System
> /dev/sda1 2048 409599 203776 7 HPFS/NTFS/exFAT
> /dev/sda2 409600 333279231 166434816 7 HPFS/NTFS/exFAT
> /dev/sda3 950562816 976771071 13104128 7 HPFS/NTFS/exFAT
> /dev/sda4 * 333284490 950549984 308632747+ f W95 Ext'd (LBA)
> /dev/sda5 333284553 345863384 6289416 82 Linux swap / Solaris
> /dev/sda6 345863448 346265009 200781 83 Linux
> /dev/sda7 346265073 409175549 31455238+ 83 Linux
> /dev/sda8 409175613 935850509 263337448+ 83 Linux
>
> Partition table entries are not in disk order
>
> Command (m for help):
and now at the original disk:
> minas-tirith:~ # fdisk -l /dev/sdd
>
> Disk /dev/sdd: 500.1 GB, 500107862016 bytes
> 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
> Units = sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0xb4e583dd
>
> Device Boot Start End Blocks Id System
> /dev/sdd1 2048 409599 203776 7 HPFS/NTFS/exFAT
> /dev/sdd2 409600 333279231 166434816 7 HPFS/NTFS/exFAT
> /dev/sdd3 950562816 976771071 13104128 7 HPFS/NTFS/exFAT
> /dev/sdd4 * 333284490 950549984 308632747+ f W95 Ext'd (LBA)
> /dev/sdd5 333284553 345863384 6289416 82 Linux swap / Solaris
> /dev/sdd6 345863448 346265009 200781 83 Linux
> /dev/sdd7 346265073 409175549 31455238+ 83 Linux
> /dev/sdd8 409175613 935850509 263337448+ 83 Linux
> /dev/sdd9 935850573 950549984 7349706 83 Linux
>
> Partition table entries are not in disk order
> minas-tirith:~ #
As you can see, both disks are exactly the same, except for sda9 which
is “partially” missing. If I try to create it again from fdisk, I can
not set the same sectors as the original:
> /dev/sda8 409175613 935850509 263337448+ 83 Linux
>
> Partition table entries are not in disk order
>
> Command (m for help): n
> First sector (935852558-950549984, default 935852558): ^C
> minas-tirith:~ #
I want it to start on sector 935850573 and end on 950549984, so that I
can dd the backup image of the 9th partition. If it starts where fdisk
wants it will not fit.
So the first question is how can I recreate that 9th partition at
exactly the same size as the original (and why doesn’t fdisk let me do it).
The second question is for the next time: how should I recreate an
entire partition table so that both the primary partitions and the
logical partitions are recreated. As it is, my procedure does not
recreate the logical partitions.
I think that somewhere in sda8 it is stored a pointer to where sda9
starts, and sda9 stores somewhere its own size. As nothing of sda9 has
been written, the table is incomplete and fdisk complains of “omitting
empty partition (9)”. On the other hand, fdisk is probably using a
different alignment that it used when I created the disk some years ago,
but I do not see how to change it.
–
Cheers / Saludos,
Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))