Although you can use dd to copy from disk to disk or even from disk to partition, I would recommend against it when the drive sizes are different.
Normally the best option is either dump/restore or tar. It takes a bit more work but is well worth it.
Below is an outline of the steps needed to do what you ask as well as an optional step #4 to use dump and restore in place of dd.
I have not tested the code below as written. I believe it will do substantially what you are asking but
THERE ARE NO WARRENTIES OF ANY KIND. I would recommend that you test and or double check each of the steps before comming yourself.
1.
Code:
dd if=/dev/zero of=/dev/hdb count=2 bs=1024
# Clear the boot record of the new drive
2.
# Gets a list of partitions to create
3.
# Create partitions on the new drive.
4. The dd example is first
Code:
for each in `fdisk -l | grep Linux | cut -c9-10| awk '{printf($1" ")}'
do
dd if=/dev/hda${each} of=/dev/hdb${each}
done
OR
Code:
for each in `fdisk -l | grep Linux | cut -c9-10| awk '{printf($1" ")}'
do
mkdir /mnt/${each}
mke2fs /dev/hdb${each}
mount /dev/hdb${each} /mnt/${each}
dump -0f - /dev/hda${each} | (cd /mnt/${each}; restore -rf -)
umount /mnt/${each} ; rmdir /mnt/${each}
done
5. Mount the partition with the boot kernel.
6. Copy /etc/lilo.conf to /tmp/new_lilo.conf file on the
first drive and change the boot line from hda to hdb
and the location of the image file (and initrd) to
its location under the mountpoint from #5.
7. Run lilo -C /tmp/new_lilo.conf
Cheers
man(1) is your friend