Ken Barber wrote:

> On Wednesday 15 September 2004 6:09 pm, Bob Miller wrote:
> 
> > No.  dd only works if the new filesystem is exactly the same size as
> > the old.
> 
> Which means that it would always work, since dd always makes the new 
> filesystem the same size as the old one.
> 
> I wonder if you mean that it only works if the new drive is the same size as 
> the old?  If so, you're wrong.  dd works fine as long as the new drive is 
> equal to or bigger than the old one.

What I meant is, if the new drive is bigger or has different geometry,
copying all the partitions (or the whole disk) with dd will waste
space.  Since Jason bought a 40 GB drive to replace a 30 GB drive, I
assumed he didn't want to throw the extra 10 GB away.

Here's the long-winded explanation.

The first sector on a disk contains the partition table.  The
partition table describes the disk's geometry: how many sectors are in
a track, how many tracks in a cylinder, and how many cylinders on the
disk.  This is all fictitious -- the "logical" geometry in the
partition table is unrelated to the disk's physical geometry, except
that the total number of logical sectors is about the same as the
physical number of sectors (without exceeding it).

Partitions contain filesystems (among other things).  Each filesystem
has one or more special sectors called superblocks (that's what Unix
and Linux call 'em.  Microsoft probably calls them something else.)  A
superblock describes the geometry of the filesystem: how big it is,
how big its logical sectors are, where the inodes are and how big they
are, etc.  (Inodes are data structures that describe individual files
and directories.)

The dd command makes an exact copy of a sequence of sectors on a disk.
It doesn't know anything about partition tables, partitions,
superblocks, inodes, or anything else.

If you copy a partition using dd, the new filesystem will have the
exact same layout as the old.  If the new partition is smaller, then
the filesystem will be corrupted.  If the new partition is bigger,
then the additional space is wasted.  You can fix up a too-small
filesystem using resize2fs (if it's ext2 or ext3), but the filesystem
data structures won't be optimized for the new disk size.

If you copy a whole disk using dd, dd will overwrite the destination
disk's partition table, effectively giving the new disk exactly the
same size, geometry, and partitioning as the old.  Once again, that
means any extra space on the new disk is wasted.

I personally always use a new disk as an excuse to refine my
filesystems' layout and sizing, so I create all-new partitions and
filesystems and copy files onto them.  Usually, I get a new disk
because the old one was full, I haven't had one go bad in several
years (knock wood).

Ken, I know you already know all this.  I didn't explain it all to
Jason the first time around because he sounded like he just wanted to
get his laptop working again.

-- 
Bob Miller                              K<bob>
kbobsoft software consulting
http://kbobsoft.com                     [EMAIL PROTECTED]
_______________________________________________
EUGLUG mailing list
[EMAIL PROTECTED]
http://www.euglug.org/mailman/listinfo/euglug

Reply via email to