FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 05-20-2008, 08:47 PM
"Javier Vasquez"
 
Default How to copy a laptop HD?

Hi,

I have an old laptop with a 10G HD. I have it partitioned into a swap
partition hda5, an ext3 boot partition hda6, and an ext3 root
partition hda7 (all logical). I acquired an 80G HD, and through an
USB interface I have it partitioned the same way, only with bigger
root partition, .

I did a copy of the contents of each partitions, except by /proc under
root, into the new created ones, but I used "cp -a" instead of "dd".
This might have prevented copying the boot sector, necessary for the
boot sector probably...

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)...

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... 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)...

Any ways, I'm still on trials, but I haven't gotten grub to work yet.
I tried also "grub-install" on sda, but that doesn't seem to work, it
only does with chroot to the mounted root of sda and with a bind to
the mounted boot of sda, however partially since it doesn't get to
read stage2. Running manually grub over the chroot seems to overcome
the stage2 thing, but I still don't get grub to work after booting.

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, .

Please suggest, recommend, etc, .

Thanks,

--
Javier


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 05-20-2008, 08:55 PM
Lee Glidewell
 
Default How to copy a laptop HD?

Have a look at partimage. Specifically you might be interested in the
CloneZilla live distro. It's built specifically for the purpose of porting
installations between hard disks.

Lee

On Tuesday 20 May 2008 01:47:03 pm Javier Vasquez wrote:
> Hi,
>
> I have an old laptop with a 10G HD. I have it partitioned into a swap
> partition hda5, an ext3 boot partition hda6, and an ext3 root
> partition hda7 (all logical). I acquired an 80G HD, and through an
> USB interface I have it partitioned the same way, only with bigger
> root partition, .
>
> I did a copy of the contents of each partitions, except by /proc under
> root, into the new created ones, but I used "cp -a" instead of "dd".
> This might have prevented copying the boot sector, necessary for the
> boot sector probably...
>
> 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)...
>
> 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... 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)...
>
> Any ways, I'm still on trials, but I haven't gotten grub to work yet.
> I tried also "grub-install" on sda, but that doesn't seem to work, it
> only does with chroot to the mounted root of sda and with a bind to
> the mounted boot of sda, however partially since it doesn't get to
> read stage2. Running manually grub over the chroot seems to overcome
> the stage2 thing, but I still don't get grub to work after booting.
>
> 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, .
>
> Please suggest, recommend, etc, .
>
> Thanks,
>
> --
> Javier



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 05-20-2008, 09:07 PM
Jochen Schulz
 
Default How to copy a laptop HD?

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?

> 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.)

> 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.
--
After the millenium I will shoot to kill.
[Agree] [Disagree]
<http://www.slowlydownward.com/NODATA/data_enter2.html>
 
Old 05-20-2008, 09:27 PM
kellybelly
 
Default How to copy a laptop HD?

Check out this website:
www.crazytrain.com/dd.html
www.crazytrain.com/dd2.html

It contains very useful information on using dd to copy hard drives.

dd is a bit-by-bit copy of your hard drive, or a hard drive partition. It
will copy everything on the drive, included deleted files.



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 05-20-2008, 10:16 PM
Preston Boyington
 
Default How to copy a laptop HD?

Javier Vasquez wrote:
<snipped>


I have an old laptop with a 10G HD...and changing the HD on the only
IDE slot is getting less fun each time


i really like using a livecd for these things and my current favorite is
the gparted-clonezilla livecd. couple that with a usb laptop drive
enclosure and things will be much easier for you.


--
Arrant Drivel - really, it's just trash...
http://www.arrantdrivel.com/


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 05-20-2008, 10:27 PM
"Paul Johnson"
 
Default How to copy a laptop HD?

On Tuesday 20 May 2008 01:47:03 pm Javier Vasquez wrote:
> I did a copy of the contents of each partitions, except by /proc under
> root, into the new created ones, but I used "cp -a" instead of "dd".
> This might have prevented copying the boot sector, necessary for the
> boot sector probably...
>
> 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)...

You did it the right way the first time. dd only works with same-size block
devices anyway.

> 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... 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)...

Don't try to copy it, reinstall it. Less messy, less prone to failure.

> Any ways, I'm still on trials, but I haven't gotten grub to work yet.
> I tried also "grub-install" on sda, but that doesn't seem to work, it
> only does with chroot to the mounted root of sda and with a bind to
> the mounted boot of sda, however partially since it doesn't get to
> read stage2. Running manually grub over the chroot seems to overcome
> the stage2 thing, but I still don't get grub to work after booting.

You're on the right track, I remember getting it to work from approximately
that point, I just can't remember what I had to change to get it to work from
there.

--
Paul Johnson
baloo@ursine.ca

Explaination of .pgp part: http://linuxmafia.com/faq/Mail/rant-gpg.html
 
Old 05-20-2008, 11:00 PM
"Javier Vasquez"
 
Default 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


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 05-20-2008, 11:18 PM
"Javier Vasquez"
 
Default How to copy a laptop HD?

On Tue, May 20, 2008 at 4:27 PM, Paul Johnson <baloo@ursine.ca> wrote:
> On Tuesday 20 May 2008 01:47:03 pm Javier Vasquez wrote:
>> I did a copy of the contents of each partitions, except by /proc under
>> root, into the new created ones, but I used "cp -a" instead of "dd".
>> This might have prevented copying the boot sector, necessary for the
>> boot sector probably...
>>
>> 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)...
>
> You did it the right way the first time. dd only works with same-size block
> devices anyway.
>
>> 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... 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)...
>
> Don't try to copy it, reinstall it. Less messy, less prone to failure.

You mean grub-install it? I couldn't... For some reason grub doesn't
even find the stage1 file after running something similar to
"grub-install --root-directory /mnt/sda-boot /dev/sda". So I tried
chroot to /mnt/sda-root (I also made the bind between /mnt/sda-boot
and /mnt-sda-root/boot) and run "grub-install --root-directory /boot
/dev/sda" and it worked better but now the stage2 file is not found by
grub... So yet under chroot, I did a search for /boot/grub/stage2,
and it was found under (hd0,4) or (hd0,5), so then I did "root
(hd0,4)", and then setup (hd0), and it said it finished successfully,
but that was all a lie, since I rebooted and I had the same thing as
when copying the MBR, a whole lot of "grub" words filling up the
screen. So I have tried everything that had occurred to me and that
have read on the web, and at least just by "grub-install", or plane
grub, I don't seem to find a solution.

I you meant even more time consuming installing the distribution
again, just basic stuff to then override everything with the other
disk, except by the MBR and probably the /bott/grub directory, then I
don't feel pretty much up to it. I'd like to go other paths 1st, .


>> Any ways, I'm still on trials, but I haven't gotten grub to work yet.
>> I tried also "grub-install" on sda, but that doesn't seem to work, it
>> only does with chroot to the mounted root of sda and with a bind to
>> the mounted boot of sda, however partially since it doesn't get to
>> read stage2. Running manually grub over the chroot seems to overcome
>> the stage2 thing, but I still don't get grub to work after booting.
>
> You're on the right track, I remember getting it to work from approximately
> that point, I just can't remember what I had to change to get it to work from
> there.
>
> --
> Paul Johnson
> baloo@ursine.ca

I've heard something interesting, although as the destine HD is
bigger, I don't know if something might get wrong at the end any ways,
... Blank the bigger new disk, copy bit to bit the smaller old HD
(whole) into the newer bigger one (not sure if the copied partition
table would still work, but if all it does is leave free space after
the last partition, then that sounds OK, but I think that's not the
whole story since the cylinders shouldn't be the same, or at least at
thought so). Then if things worked, it would be a matter of resizing
the last partition, which is the root one, ... Not sure if that'd
work though...

Before trying this last thing I heard, I'd like to try then copying th
whole 512 1st bytes of the old HD, just in case that'd work (I
understand that'll inlcude the partition table though). Any ways,
just thinking about what to try next when I'm back home, ...


--
Javier


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 05-21-2008, 02:28 AM
Raj Kiran Grandhi
 
Default How to copy a laptop HD?

Javier Vasquez wrote:


You mean grub-install it? I couldn't... For some reason grub doesn't
even find the stage1 file after running something similar to
"grub-install --root-directory /mnt/sda-boot /dev/sda". So I tried
chroot to /mnt/sda-root (I also made the bind between /mnt/sda-boot
and /mnt-sda-root/boot) and run "grub-install --root-directory /boot
/dev/sda" and it worked better but now the stage2 file is not found by
grub... So yet under chroot, I did a search for /boot/grub/stage2,
and it was found under (hd0,4) or (hd0,5), so then I did "root
(hd0,4)", and then setup (hd0), and it said it finished successfully,
but that was all a lie, since I rebooted and I had the same thing as
when copying the MBR, a whole lot of "grub" words filling up the
screen. So I have tried everything that had occurred to me and that
have read on the web, and at least just by "grub-install", or plane
grub, I don't seem to find a solution.


Ensure that you have copies all the files from your existing /boot
partition to the new /boot partition. Then unmount your existing /boot
and mount the new partition at /boot. Then run grub-install /dev/sda.
You may want to fix the menu.lst file so that the groot points to your
new disk.


I always prefer this option instead of dd.


--

If you can't explain it simply, you don't understand it well enough.
-- Albert Einstein


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 05-21-2008, 05:33 AM
Jochen Schulz
 
Default How to copy a laptop HD?

Javier Vasquez:
> On Tue, May 20, 2008 at 3:07 PM, Jochen Schulz <ml@well-adjusted.de> wrote:
>>
>> 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...

Me neither. Without looking into the articles, I trust them more to
be correct about this than I trust myself on this matter. However, it
should still be an option to copy the MBR first and partition the drive
afterwards. But of course that leaves the question why it didn't work on
your first try.

Did you edit grub's menu list to reflect your partition changes?

J.
--
I have been manipulated and permanently distorted.
[Agree] [Disagree]
<http://www.slowlydownward.com/NODATA/data_enter2.html>
 

Thread Tools




All times are GMT. The time now is 01:44 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org