[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cloning hda to new internal disk (was Re: [debian-user] How to copy a laptop HD?)



On 05/20/08 21:50, Raj Kiran Grandhi wrote:
> Ron Johnson wrote:
>> Is there any way to directly clone /dev/hda to /dev/sdX, so that I
>> can then boot off of /dev/sdX?
>
> If you can boot some live system, you can just partition your new disk,
> mount them all, copy all your files over, fix /etc/fstab and
> I've tried doing what you suggest, but cp leaves absolute symlinks
>  still pointing to the original files on the source device.
>
>

Hey,
  You should be able to boot a livecd with both disks installed and
perform the copy. The easiest way would be to have the new disk have
the same partition layout, whether larger sizes or not doesn't matter.
  Create your partitions and you should then be able to directly dd
the partitions.

  e.g. Assuming the new partitions (on sdb) are >= the old ones (on sda) and
  sda1=/boot sda2=/ sda3=/home, all ext3.
  (need swap too, but don't need to copy it)
  Then something like this _should_ work[1]:

#  for i in '1 2 3';
  do dd if=/dev/sda${i} of=/dev/sdb${i} bs=1M
  resize2fs /dev/sdb${i}
done
# mount /dev/sda2 /mnt
# mount /dev/sda1 /mnt/boot
# mount -o bind /dev /mnt/dev
# mount -t proc none /mnt/proc
# chroot /mnt
# grub install /dev/sdb
# exit

  If you're adding the new disk rather than replacing the old one then
you'll have to edit grub's menu.1st to change the devices to sdb (prob
hd1), if it's using uuid's you'll have to do so anyway.
  There are plenty of grub tutorials around, easily found by searching
for 'restore grub windows' as windows is a common culprit for nuking
grub and the restore process is the same.

cheers,
Owen.

Footnotes:
--
[1] I'm not at a terminal, this is from memory, check & rtfm.


Reply to: