Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

My Experience: Copying To A New Hard Drive


  • Please log in to reply
7 replies to this topic

#1 Joedude

Joedude

  • Members
  • 337 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Sutton Coldfield, West Midlands, England
  • Local time:11:11 PM

Posted 29 July 2007 - 03:38 PM

Story:

Old: 80 Gb Maxtor IDE old and suffering from overheating damage. Makes the "thunk" of a slowly dying head swing-arm. Occaisionally locks the puter up, sometimes fails to read entirely. Disk has the following partitions: 47 Gb FAT32 WinXp (for the missus), 1 Gb SWAP, 5 GB / Ext2 and a 24 Gb /home EXT2

New: Bought a 250 Gb Maxtor.

Method: in Ubuntu, using a terminal, "dd" and Gparted.

Originally, I formatted the new hard drive as such (using gparted):
100Gb Fat32
1 Gb SWAP
10Gb / Ext3
121Gb /home Ext3

This became, as you may or may not know, hdb. I then began to use the dd command:
sudo dd if=/dev/hda1 of=/dev/hdb1

I didn't realize nor anticipate there would be a problem until I had done them all (quite a timely process).
After some quick math, I found "dd" had copied them over + left me a little gift! If hda1 was say 90% full, then it made sure the new partition was as well. ie: hda1 was only 47Gb, but ws 90% full. I formatted (as you can see above) hdb1 for 100Gb, yet it was still 90% full after the copy...

I couldn't find any help on the topic. Asked one of my favorite forums, got a direction to head, but not an answer. That's actually the point where I did the math and found the %'s. So, now, I've done it this way and it worked fine:

deleted all partitions from hdb1.
create and format hdb1 to the exact specifications of hda1 using gparted (same file system ame size, location as far as I could see, shouldn't matter).
then I used dd
sudo dd if=/dev/hda1 of=/dev/hdb1

which worked exactly right, copying the partition over with perfection in size and quality.
Then resized hdb1 to the desired size using gparted.

repeat this for any additional partitions.


Yeah, maybe a little over complicated, but it worked like a charm that way. Just thought I should share. When I get to it, I'll post how changing the new hard drive from slave to master went and how well reinstalling GRUB will go.

In case you don't know, copying the MBR over is a bad idea unless you have an exact same new hard drive with the exact same geometry. Otherwise, there could be flags, permissions and address problems within the drive.

The best way is to slave the new drive(maybe not the best, but the way I do it), copy over from the old, put the new one as master and install GRUB/LILO (whatever bootloader you like).
If someone tells you to su rm -rf /
DON'T DO IT!!!!
Be in the know, Bash smart!

BC AdBot (Login to Remove)

 


#2 thekingof7

thekingof7

  • Members
  • 24 posts
  • OFFLINE
  •  
  • Local time:05:11 PM

Posted 31 July 2007 - 11:57 PM

I would have just used Hiren's bootdisk, and copied over everything using one of the many hdd tools available.

#3 Joedude

Joedude
  • Topic Starter

  • Members
  • 337 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Sutton Coldfield, West Midlands, England
  • Local time:11:11 PM

Posted 01 August 2007 - 02:21 AM

logical. I could have just used the maxblast disk as well. However, it doesn't recognise ext* or swap partitions. I actually wanted to do it manually was the main thing, using only the tools included in Linux. It has been accomplished now, as soon as I get some days off, I'll do the grub reinstall. I honestly should have read more on the subject befor I tried it. Normally, I just do a clean install as I keep little of actual value on my pc. But, this time, I was determined to accomplish it this way. I'm curious to see how WGA and WGP react afterwards.
If someone tells you to su rm -rf /
DON'T DO IT!!!!
Be in the know, Bash smart!

#4 thekingof7

thekingof7

  • Members
  • 24 posts
  • OFFLINE
  •  
  • Local time:05:11 PM

Posted 06 August 2007 - 12:06 AM

The nice thing about Hiren's though is that it seems to have no problem with most of the standard linux file-systems. I used it with Ext2 and 3, and I'm pretty sure XFS works with it as well.

#5 Joedude

Joedude
  • Topic Starter

  • Members
  • 337 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Sutton Coldfield, West Midlands, England
  • Local time:11:11 PM

Posted 07 August 2007 - 03:30 AM

I checked on the most recent version of maxblast and it now supports ext* file formats...go figure. Anyway, grub reinstall worked like a charm.

sudo grub

find /boot/grub/stage1

root (hd?,?) ***where ?,? is the result posted by the previous command***

setup (hd0)

quit

Didn't work. Kept getting error 15 on reboot (File system unreadable/findable). So I tried this:

sudo mkdir /mnt/root

sudo mount -t ext3 /dev/sda6 /mnt/root

sudo mount -t proc none /mnt/root/proc

sudo mount -o bind /dev /mnt/root/dev

sudo chroot /mnt/root /bin/bash

sudo grub

find /boot/grub/stage1

root (hd?,?) ***Where ?,? is the result posted  by the above command***

setup (hd0)

quit

Worked like a charm. I really don't understand all the fuss about reinstalling the bootloader. That may look a lot, but it is as easy as it reads. Don't be afraid to piddle with it and be brave enough to install your windows second ;-)
If someone tells you to su rm -rf /
DON'T DO IT!!!!
Be in the know, Bash smart!

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:04:11 PM

Posted 08 August 2007 - 11:15 PM

Thank you for sharing. Good job sticking with it. :thumbsup:

#7 Joedude

Joedude
  • Topic Starter

  • Members
  • 337 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Sutton Coldfield, West Midlands, England
  • Local time:11:11 PM

Posted 09 August 2007 - 11:50 PM

Thanx. Those are two ways to do it from a live CD. A third option (which a freind told me was much easier) is o boot from a rescue disk, let it mount all of the partitions. Then:

# chroot /mnt/sysimage
# grub-install

If someone tells you to su rm -rf /
DON'T DO IT!!!!
Be in the know, Bash smart!

#8 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:04:11 PM

Posted 12 August 2007 - 07:55 PM

It may be much easier, but doing it the way you did allowed you to poke around in the guts a little.I just finished installing Embperl on a system where it really shouldn't have worked. I know a ton more about apache and mod-perl than I did 4 hours ago. :thumbsup:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users