1

I'm tring to back up the partition table of a Linux Ubuntu 10.04 LTS.

Actually I'm making the tests with Virtualized machines (VirtualBox). And I have one source system in a virtual disk, another virtual machine as the rescue system, and another empty virtual disk with the same size exactly than the source system disk.

So, running the rescue system I mount the source system disk and user this command for making the partition table backup:

sfdisk /dev/sdb –d > /backup/sdb-part-table.sf

And the file gets generated and saved with this output message:

Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.

Once I Have the partition table file I unmount the source disk and mount the backup empty disk.

I try to use this command:

sfdisk /dev/sdb < /backup/sdb-part-table.sf

Then I try again to restore the parition table but gives me this error:

Checking that no-one is using this disk right now ...
OK

Disk /dev/sdc: 265 cylinders, 255 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdc1   *      0+    245-    246-   1973248   83  Linux
/dev/sdc2        245+    265-     20-    155649    5  Extended
/dev/sdc3          0       -       0          0    0  Empty
/dev/sdc4          0       -       0          0    0  Empty
/dev/sdc5        245+    265-     20-    155648   82  Linux swap / Solaris
New situation:
Units = sectors of 512 bytes, counting from 0

Device Boot    Start       End   #sectors  Id  System
/dev/sdc1   *      2048   3948543    3946496  83  Linux
/dev/sdc2       3950590   4261887     311298   5  Extended
/dev/sdc3             0         -          0   0  Empty
/dev/sdc4             0         -          0   0  Empty
/dev/sdc5       3950592   4261887     311296  82  Linux swap / Solaris
Warning: partition 1 does not end at a cylinder boundary

sfdisk: I don't like these partitions - nothing changed.
(If you really want this, use the --force option.)

So Finally I user force to make the restoration and seem to work:

sfdisk --force /dev/sdb < /backup/sdb-part-table.sf

Getting this result:

Checking that no-one is using this disk right now ...
OK

Disk /dev/sdc: 265 cylinders, 255 heads, 63 sectors/track
Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdc1   *      0+    245-    246-   1973248   83  Linux
/dev/sdc2        245+    265-     20-    155649    5  Extended
/dev/sdc3          0       -       0          0    0  Empty
/dev/sdc4          0       -       0          0    0  Empty
/dev/sdc5        245+    265-     20-    155648   82  Linux swap / Solaris
New situation:
Units = sectors of 512 bytes, counting from 0

Device Boot    Start       End   #sectors  Id  System
/dev/sdc1   *      2048   3948543    3946496  83  Linux
/dev/sdc2       3950590   4261887     311298   5  Extended
/dev/sdc3             0         -          0   0  Empty
/dev/sdc4             0         -          0   0  Empty
/dev/sdc5       3950592   4261887     311296  82  Linux swap / Solaris
Warning: partition 1 does not end at a cylinder boundary
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

But, when I move the backup to the new file system witch seem to be alright, the system do not start, I have a black screen as if no OS where installed in the backup machine, comparative of Partition Tables are equal in the working source disk and in the backup not-working disk.

Mbr backup is already done and installed. I've tried to install after and before the partition table restoration.

So, any idea of how can I make it work?

Thanks in advance, and have a nice week :D

2 Answers 2

0

Did you tried a lower level approach? For example, using dd if=/dev/sdc of=mbr.sav bs=512 count=1, which will do exactly what you are expecting, that is to say backing up the first 512 bytes of your HDD to mbr.sav? To restore backup, invert if and of arguments values.

2
  • 2
    That only gets the primary partitions however, /dev/sdc5 would be missed
    – stew
    Mar 12, 2012 at 15:01
  • Of course; I forgot the extended partitions.
    – Penegal
    Mar 13, 2012 at 7:58
0

The previous answer was actually really close; you only backed up the partition table. The partition table is PART of the first sector. The other thing in the first sector is the bootloader.

However, if you do copy the first sector exactly, and not your /boot partition exactly, you can easily get cases where the code in the first sector jumps to an address that doesn't have the needed file. In which case, boot up some relevant media, and reinstall the bootloader (I think Ubuntu even has a helper for that on their media).

You must log in to answer this question.

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