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

Re: [debian-user] How to copy a laptop HD?



On Tue, May 20, 2008 at 3:07 PM, Jochen Schulz <ml@well-adjusted.de> wrote:
> Javier Vasquez:
>>
>> Do you suggest using "dd" instead?  Would it work even if the destine
>> partition is bigger (I read somewhere it works perfectly when source
>> and destine are the same size, but I never read it works perfectly
>> when destine is bigger)...
>
> Yes, it works. You have to resize your filesystems afterwards, but
> that's not a biggie.
>
>> What about the HD MBR?  I've tried already using "dd if=/dev/hda
>> of=~/full_mbr.bin bs=512 count=1 && dd if=~/full_mbr.bin of=/dev/sda
>> bs=446 count=1", but it didn't seem to work...
>
> Why do you only copy 446 Bytes back?

That's what I read is necessary, since the last 64+2 bytes of the 1st
512  bytes correspond to the partition table, which shouldn't be
copied over I believe.  An example of such warning can be found:

http://www.sysdesign.ca/guides/partitions.html
http://www.unix.com/unix-dummies-questions-answers/24885-how-copy-mbr-old-harddrive-new-harddrive.html

Well, I'm not sure anymore then...

>
>> I wouldn't know if
>> using count=2 to include the boot sector would work since the boot
>> partition is the 2nd one (the swap is the 1st one)...
>
> It doesn't matter where your boot partition is. You only need the MBR
> (the first 512 Bytes, AFAIK, which you already copied.)

Sure the whole 512 1st bytes are required?  I think they include the
partition table, which is what I tried to avoid, but I might be wrong,
:).

>> The thing is that as this is a laptop, and changing the HD on the only
>> IDE slot is getting less fun each time, I was thinking what would be a
>> good recipy to follow.  Maybe using dd for each partition, or for the
>> whole HD would work, although I find it hard to believe it would (the
>> partition tables at least should be different, since the difference in
>> sizes), but I just might be too skeptical, and using dd for the whole
>> HD is what works out of the box after partitioning the HD, :).
>
> No, you're right about your skepticism. dd'ing the whole disc will also
> copy the partition table which you probably don't want.
>
> You only need to:
>
> - Partition the new disk to your liking.
>
> - dd filesystems from old partitions to the new ones. Make sure to use a
>  big number for the block size like bs=1M or more. That will speed up
>  the process. While dd is working, you can send the dd process a USR1
>  signal (like 'kill -USR1 $pid') to make it print a report about its
>  current progress.
>
> - Copy the MBR using 'dd if=/dev/in of=/dev/out bs=512 count=1'.
>
> - Use resize2fs or whatever suits your filesystems to grow them up to
>  the capacity of their partition.
>
> - Swap disks and reboot.
>
> At least, that's how it should work in theory. :)
>
> J.


-- 
Javier


Reply to: