LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Transfer data from one HD to the other?? (https://www.linuxquestions.org/questions/linux-hardware-18/transfer-data-from-one-hd-to-the-other-542416/)

jiml8 04-01-2007 07:25 PM

You are doing something wrong, indeed.

On your new HD, just build the partitions. Then, in your current /mnt, make the mountpoints for the new HD, such as /mnt/hdb2 and so forth.

Then copy the contents from your current / to the appropriate partition on the new HD; for instance cp / /mnt/hdb2.

Don't worry about /home, /, /sys, /mnt, or anything else; just copy the entire contents of one partition to the appropriate replacement on the other drive.

After you have done this and copied the MBR, then shut off the machine, move the HD, and everything will take care of itself. Your new drive which was hdb will be recognized as hda, your mountpoints will all be right, and the system will just boot.

Just make sure that, if you are booting off the second partition on your current boot drive, you copy / to the second partition on the new drive. If you copy / to some other partition on the new drive, then you'll have to edit your copied grub menu.lst to point to the proper partition before moving the drive.

It really does work that way. Think about it.

Biggen 04-02-2007 08:45 AM

Quote:

Originally Posted by jiml8
You are doing something wrong, indeed.

On your new HD, just build the partitions. Then, in your current /mnt, make the mountpoints for the new HD, such as /mnt/hdb2 and so forth.

Then copy the contents from your current / to the appropriate partition on the new HD; for instance cp / /mnt/hdb2.

Don't worry about /home, /, /sys, /mnt, or anything else; just copy the entire contents of one partition to the appropriate replacement on the other drive.

After you have done this and copied the MBR, then shut off the machine, move the HD, and everything will take care of itself. Your new drive which was hdb will be recognized as hda, your mountpoints will all be right, and the system will just boot.

Just make sure that, if you are booting off the second partition on your current boot drive, you copy / to the second partition on the new drive. If you copy / to some other partition on the new drive, then you'll have to edit your copied grub menu.lst to point to the proper partition before moving the drive.

It really does work that way. Think about it.

Ok, I think I have a little better understanding of what I am doing now. I created three partitions on hdd (my new drive) to mirror the partitions on hda. hda1 -> hdd1 (swap), hda2 -> hdd2 (/), and finally hda3 -> hdd3 (/home). I was going to put swap in the middle, but for right now I don't want to have to mess with GRUB. I need to get this figured out first.

Mount points were created as follows - hdd1 -> (just swap of course), hdd2 -> (/mnt/hdd2), and hdd3 -> (/mnt/hdd3).

I won't be able to use KDE as I have a video card problem in this machine so I'll have to stick with command line. So I'll have to use the "cp" command. I am pretty sure I want to use "cp -a" as that looks like it preserves time stamps and such.

So when I get to the office this morning I will do a "cp -a / /mnt/hdd2" and then "cp -a /home /mnt/hdd3". Finally I use dd to copy the MBR to the new drive with "dd if=/dev/hda of=/dev/hdb bs=446 count=1".

Shut down the machine, move the drives around so that hdd is now hda and boot up. Everything should work!! I'll report back if all went well! I appreciate your help! If you don't mind looking over this to make sure it all looks good.

Rodman

jiml8 04-02-2007 09:03 AM

that should work. Just be sure you are doing the copy as root. Also don't forget the -r option on the cp so that it will recursively copy directories.

Biggen 04-02-2007 09:11 AM

Quote:

Originally Posted by jiml8
that should work. Just be sure you are doing the copy as root. Also don't forget the -r option on the cp so that it will recursively copy directories.

One more thing, Jim, before I start it. I know you said that I don't need to use a live distro to boot up and do the copy with. But if anything is written to a directory behind and after cp has copyied it over to hdd, won't I be missing that info? Should I kill crond at least to make sure that isn' running?? Anything else should I kill to try and make sure that I'm not missing anything??

Oh, and it isn't the "-a" option I want, I re-read the man page and it looks like I want "cp -rp". That should do it.

jiml8 04-02-2007 09:38 AM

In my first post on this thread I stated that killing cron would be a good plan. Not strictly necessary, but if a cron job runs and changes things while you are copying, you will indeed have an inconsistency between copies. Usually this won't matter, but then, it depends on what the cron is doing, now doesn't it.

You can, of course, just use a live CD distro. Me, I usually don't bother.

I commonly backup my / using the dd command to make a partition image. All I ever do is start the backup then go drink a cup of coffee (in other words, I don't touch the mouse or keyboard, stop all multimedia, etc). I never have any trouble, and I usually mount and browse the iso before gzipping it just to be sure it is OK.

Biggen 04-02-2007 09:55 AM

Quote:

Originally Posted by jiml8
In my first post on this thread I stated that killing cron would be a good plan. Not strictly necessary, but if a cron job runs and changes things while you are copying, you will indeed have an inconsistency between copies. Usually this won't matter, but then, it depends on what the cron is doing, now doesn't it.

You can, of course, just use a live CD distro. Me, I usually don't bother.

I commonly backup my / using the dd command to make a partition image. All I ever do is start the backup then go drink a cup of coffee (in other words, I don't touch the mouse or keyboard, stop all multimedia, etc). I never have any trouble, and I usually mount and browse the iso before gzipping it just to be sure it is OK.

Excellent! I'm downloading a live distro now. Using cp didn't work to well as it gave me errors on some files (i.e. resource busy or permission denied) even running as root. I'm guessing this is becuase those files are currently in use perhaps?? Dunno... I'll report back when I fire it up with the live CD and give it the cp commands then...

jiml8 04-02-2007 10:35 AM

Actually, I was just reading up on grub (if that is your bootloader) and I think that probably you'll need to reinstall grub on the new drive after copying it if you use the cp command.

Turns out that the MBR for grub has the absolute physical address of the second stage grub program hardcoded into it. When you use cp to copy the /boot sector from / to the new HD, it seems unlikely that the stage 2 program will wind up in the exact same physical location on the new HD as the old one.

To reinstall grub, after swapping your hard drives boot into either a rescue CD or into a live CD distro. From a shell command line, as root, enter the command: grub

This will give you a command line in the grub program. Enter the command: "root (hd0,1)" (with no quotes). Grub will respond telling you what the file system on the partition is.

Then enter the command "setup (hd0)" . This will cause grub to rewrite the MBR with the proper information.

Then enter the command "exit" to exit grub.

Biggen 04-02-2007 10:57 AM

Quote:

Originally Posted by jiml8
Actually, I was just reading up on grub (if that is your bootloader) and I think that probably you'll need to reinstall grub on the new drive after copying it if you use the cp command.

Turns out that the MBR for grub has the absolute physical address of the second stage grub program hardcoded into it. When you use cp to copy the /boot sector from / to the new HD, it seems unlikely that the stage 2 program will wind up in the exact same physical location on the new HD as the old one.

To reinstall grub, after swapping your hard drives boot into either a rescue CD or into a live CD distro. From a shell command line, as root, enter the command: grub

This will give you a command line in the grub program. Enter the command: "root (hd0,1)" (with no quotes). Grub will respond telling you what the file system on the partition is.

Then enter the command "setup (hd0)" . This will cause grub to rewrite the MBR with the proper information.

Then enter the command "exit" to exit grub.

Interesting. Ok, here is where I am now. I am finishing up copying "/" to hdd2. Taking a while but that is normal since its a few gigs in size.

I'm still going to need to use dd correct? As in dd if=/dev/hda of=/dev/hdb bs=446 count=1? Or will re-installing grub override this so this isn't necessary?

w_r_cromwell 04-02-2007 11:05 AM

Your running system can only have one / and etc just as you said except that you can have more than one swap partition. I have never used ore than one swap partition but it is supposed top be okay (something i found while looking up something else). While the new drive is recognized as hdb you can mount the partitions as anything you like as long as you can remember which partition will be used for each of the original partitions and then copy your files there. After you have done all of your copying and taken care of mbr and moved the jumper on the new drive and plugged it into the appropriate cable the system will recognize it as hda and will mount the partitions according to the instructions it copied over from your first drive (now resting on the shelf). The partitions will be mounted on the same mount points that were used for them in the original system. The mount points are determined by the running system and not by what was used when the drive was recognized as hdb.

Bill

PS: Do I feel silly or what! I missed the whole second page of replies before I posted this. I'll leave it here anyway.

jiml8 04-02-2007 12:06 PM

reinstalling grub will write the proper MBR. Hence you won't have to copy the old one using dd.

Biggen 04-02-2007 01:33 PM

Quote:

Originally Posted by jiml8
reinstalling grub will write the proper MBR. Hence you won't have to copy the old one using dd.

Ok, I reinstalled GRUB and everything seemed to go just fine. I Then rebooted and everything looked like it was going well until I got to:

Quote:

fsck.ext3: No such file or directory while trying to open /dev/hdd3
fsck.ext3 /dev/hdd3 failed (status 0x8) Run manually
fsck failed for at least one filesystem (not /)
Please repair manually and reboot
It looks as if something is trying to access a hard drive at hdd. Now when I partioned the drive using Yast2, it automatically added mount points in FSTAB I believe (/mnt/hdd2) and (/mnt/hdd3). I wonder if this is causing the problem. I wonder if removing any entries to hdd from FSTAB would fix this...

Biggen 04-02-2007 01:48 PM

It worked!!!

Jiml8, if you were close by I'd take you out for a beer!! :-)

I had to end up deleting the entries in the fstab as Yast2 added them automatically when it formatted the drive. Went just as easily as you said, re-installing GRUB was a breeze with your instructions.

Thanks a lot man. Now as soon as my other 80GB drive comes in I can setup RAID 1 in the system. I'm going to be doing hardware RAID so it should be farily simple to set that up (I hope anyway!).

Thanks again, bud!

Quakeboy02 04-02-2007 01:52 PM

Quote:

Now as soon as my other 80GB drive comes in I can setup RAID 1 in the system. I'm going to be doing hardware RAID so it should be farily simple to set that up (I hope anyway!).
Are you buying a RAID controller? The one on your motherboard is a sofware raid.

Biggen 04-02-2007 02:06 PM

Quote:

Originally Posted by Quakeboy02
Are you buying a RAID controller? The one on your motherboard is a sofware raid.

I bought one from 3Ware. From all the research I've done, setting up software RAID looked like a total pain in the ass. From what I have read, hardware RAID is much easier as it is transparent to Linux...

jiml8 04-02-2007 02:52 PM

I am in phoenix az and I love beer.


All times are GMT -5. The time now is 11:24 AM.