1 |
On 16 May 2011 07:31, Adam Carter <adamcarter3@×××××.com> wrote: |
2 |
> |
3 |
>> > To check my understanding - would it be correct to say that; |
4 |
>> > 1. Using dd to copy the first 512 bytes (MBR) is ALL that is needed to |
5 |
>> > setup the partitions - that is i wont need to run fdisk etc afterward. |
6 |
>> |
7 |
>> This is correct if you only have primary partitions. It will not copy the |
8 |
>> extended partition and any logical partitions in it. They reside in the |
9 |
>> first |
10 |
>> sector of the extended partition, which is not a boot sector, but contains |
11 |
>> the |
12 |
>> logical partition table. (I found this out the hard way!) |
13 |
>> |
14 |
>> Have a look at this to see how you can back up the extended partition |
15 |
>> tables |
16 |
>> with sfdisk (there's more than one of these, if you have more than one |
17 |
>> logical |
18 |
>> partition) : |
19 |
>> |
20 |
>> http://www.partimage.org/Partimage-manual_Backup-partition-table |
21 |
>> |
22 |
>> |
23 |
>> > 2. Using dd in this way of course will not update the kernel's knowledge |
24 |
>> > of |
25 |
>> > the partition table so a partprobe is necessary |
26 |
>> |
27 |
>> Yes, or a reboot. |
28 |
>> |
29 |
>> |
30 |
>> > 3. When using fdisk to write a partition table and exit, it calls a |
31 |
>> > re-read |
32 |
>> > of the partition table by the kernel so any changes should be ready |
33 |
>> > straight away. (there's a message about calling ioctl when it exits - so |
34 |
>> > i |
35 |
>> > guess that is the update) |
36 |
>> |
37 |
>> They are ready (i.e. written) but not yet read by the OS. Tools like |
38 |
>> gparted |
39 |
>> (part)probe the device to re-read the partition table after saving changes |
40 |
>> to |
41 |
>> disk. |
42 |
> |
43 |
> Thanks Mick. Great info, esp about the extended partitions. Fortunately, I |
44 |
> dont have any on this disk but good to know. |
45 |
|
46 |
OK, this is what I would do: |
47 |
|
48 |
dd over the MBR (bs=512 count=1). This will bring over the bootloader |
49 |
code and the primary partition table. Any primary partitions you had |
50 |
will be copied over, same number and same size. |
51 |
|
52 |
Then reboot. This will read the new primary partition table. |
53 |
|
54 |
Then run your dd command on the respective partition. It should not |
55 |
error out on the first bs, but I suggest that you also add |
56 |
conv=notrunc. and perhaps conv=notrunc,noerror. The notrunc is |
57 |
necessary to copy all sectors, otherwise dd will stop as soon as it |
58 |
reaches unused sectors and truncate the test of the copy. The noerror |
59 |
will make it carry on even if there are read errors. In this way what |
60 |
you get on the new disk should be identical bit by bit with what's on |
61 |
the old disk including empty space. |
62 |
|
63 |
Then you can use gparted and resize partitions, add new ones, etc. |
64 |
BTW do not resize ntfs partitions unless you have booted into them |
65 |
defragged them first. |
66 |
|
67 |
Let us know how it goes. |
68 |
-- |
69 |
Regards, |
70 |
Mick |