Re: Using dd to clone smaller drive to larger drive
good email addy
On Tue, 6 Dec 2005, Brian C wrote:
> /dev/hda is the Debian Sarge system, w/ 3 partitions.
> /dev/hdb is a new slightly larger drive w/ no partitions.
>
> /dev/hda may have a bad block or two, and so the plan is to clone it to
> the new drive, remove the old drive, move new drive to /dev/hda (primary
> master) and then run from the new drive.
>
> Can I just type (as root):
>
> dd if=/dev/hda of=/dev/hdb
yes you can.. but...
> and will that just work?
no ... it might not work ... because youwill be copying the suspect
bad data/bad block from the suspect bad disk onto the new disk
dd is low level and will ocpy anything .. including bad data
and sectors marked as bad by sw ( badblocks, etc ), but, it should
not copy tracks/sectors marked bad by the disk controller fw
- if you want to leave bad data behind
mount /dev/hdb1 /mnt/new-disk
tar cvfp old-disk-paritions /mnt/new-disk
sync
umount /mnt/new-disk
boot the new disk with a floppy or bootable cdrom
and rerun grub/lilo on the new disk
> Should I first set up the new drive with identical partitions to the old
> drive?
only if you know you won't outgrow the old paritions
if you used the dd command you suggest ( dd if=/dev/hda of=/dev/hdb )
you may or many not have "extra space"
> If so, what can I do with the extra space?
use it as spare .. make another partition with the rest of the
unused space
you will also have to watchout for the number of heads
on /dev/hda vs /dev/hdb when copying
- cylinder * heads * sectors is remapped into mumble-jumble
you may or many not be able to truncate the partitions on hdb
after you copied the smaller hda onto hdb
it's bad idea to truncate large partitons with say 100MB of free
space at the end of the partition and create a new 100MB partition
out of it .. if you're careful .. it will work for a while
> What will happen if dd encounters a bad block?
depends on how the "bad block" is marked
- marked by sw vs marked by firmware vs marked on the track itself
- all apps will skip around bad blocks marked by fw or hw
unless you make a custom-app.asm to read the badblocks itself
- lots of fun stuff to do
c ya
alvin
Reply to: