[ale] duplicating the partition layout?

Joe Steele joe at madewell.com
Mon Oct 22 15:51:48 EDT 2001


I had meant to say something about this when I saw the earlier post, 
but I forgot. :(

If you have extended partitions, there are additional partition 
tables which you must duplicate.

Here's a sample disk layout using fdisk ('p' command):
--------
Disk /dev/hda: 32 heads, 63 sectors, 6978 cylinders
Units = cylinders of 2016 * 512 bytes

   Device Boot   Begin    Start      End   Blocks   Id  System
/dev/hda1            1        1        3     2992+  83  Linux native
/dev/hda2            4        4     6978  7030800    5  Extended
/dev/hda5            4        4       69    66496+  82  Linux swap
/dev/hda6           70       70     6978  6964240+  83  Linux native
--------

If we enter expert mode ('x' command), the 'p' command gives this:
--------
Disk /dev/hda: 32 heads, 63 sectors, 6978 cylinders

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl   Start    Size ID
 1 00   1   1    0  31  63    2      63    5985 83
 2 00   0   1    3  31  63 1023    604814061600 05
 3 00   0   0    0   0   0    0       0       0 00
 4 00   0   0    0   0   0    0       0       0 00
 5 00   1   1    3  31  63   68      63  132993 82
 6 00   1   1   69  31  63 1023      6313928481 83
--------
Of course heads and cylinders are numbered beginning with 0, sectors 
begin with 1.  Each sector contains 512 bytes, and for this disk, 
each head contains 63 sectors, and each cylinder contains 32 heads.  

The main partition table is stored at H/S/C=0/1/0.  The first 
partition follows it at the beginning of the next head, 1/1/0.  

But this disk has two other partition tables. Pointers to those 
additional tables are listed with the 'e' command in expert mode:
--------
Disk /dev/hda: 32 heads, 63 sectors, 6978 cylinders

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl   Start    Size ID
 2 00   0   1    3  31  63 1023    604814061600 05
 5 00   0   1   69  31  63 1023  13305613928544 05
 6 00   0   0    0   0   0    0       0       0 00
--------
The second partition table is at H/S/C=0/1/3.  The table's offset (in 
sectors) from the beginning of the disk is (C * 32 + H) * 63 + S - 1 
= 6048.  Looking back at the output of the 'p' command, you see this 
table is sandwiched between the end of the first partition and the 
start of the fifth.

The third partition table is at 0/1/69.  The table's offset from the 
beginning of the disk is 139104.  The table is sandwiched between the 
end of the fifth partition and the beginning of the sixth.

To completely duplicate the partitioning from hda to hdb (assuming 
the disks have identical geometries):

dd if=/dev/hda bs=512 count=1 of=/dev/hdb
dd if=/dev/hda bs=512 count=1 of=/dev/hdb skip=6048 seek=6048
dd if=/dev/hda bs=512 count=1 of=/dev/hdb skip=139104 seek=139104

The more partitions you have, the more complicated this method of 
duplication is likely to get.

--Joe




-----Original Message-----
From:	Robert L. Harris [SMTP:Robert.L.Harris at rdlg.net]
Sent:	Monday, October 22, 2001 12:33 PM
To:	Joseph A Knapka
Cc:	Robert L. Harris; Atlanta Linux Enthusiasts
Subject:	Re: [ale] duplicating the partition layout?


Odd...

Just did this and I get something odd.  My source disk has 8 
slices (not my choice).  

1-3 linux primary
4   extended
5-8 linux logical



After the dd command my target drive has this:
1-3 linux primary
4   extended
5   unknown (some very strange cylinder numbs also).


?


Thus spake Joseph A Knapka (jknapka at earthlink.net):

> "Robert L. Harris" wrote:
> > 
> > I have to duplicate a bunch of disks.  They need identicle partition
> > layouts.
> > 
> > I don't want to dd if=/dev/sda of=/dev/sdb since we're only actually
> > using 2 of the 18 gigs right now.
> 
> dd if=/dev/sda of=/dev/sdb bs=512 count=1
> 
> ought to do it. You just need to copy the first 512 bytes.
> 
> Cheers,
> 
> -- Joe 
> # "You know how many remote castles there are along the
> #  gorges? You can't MOVE for remote castles!" - Lu Tze re. Uberwald
> # Linux MM docs:
> http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html



:wq!
---------------------------------------------------------------------------
Robert L. Harris                |  Micros~1 :  
Senior System Engineer          |    For when quality, reliability 
  at RnD Consulting             |      and security just aren't
                                \_       that important!
DISCLAIMER:
      These are MY OPINIONS ALONE.  I speak for no-one else.
FYI:
 perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list