LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   copying a hard drive (https://www.linuxquestions.org/questions/linux-newbie-8/copying-a-hard-drive-652024/)

grayFalcon 06-27-2008 06:15 AM

copying a hard drive
 
Hello everybody!

Just a (hopefully) simple question. I have Linux on a rather small drive. I'm getting a new drive. So now I'd want to copy my whole old drive to the first GB of the new drive and then expand them with gparted to fill the whole drive. I haven't been able to find anything nice for doing this yet (mostly, the tutorials for this effectively install a new minimal system on the new drive and copy the data - that's not what I see as an elegant way of doing this).

Is there some way to do this? Something along the lines of 'cat /dev/hda > /dev/hdb'?

Thanks a lot in advance!

pinniped 06-27-2008 07:04 AM

Why do things the hard way?

Is your computer new enough to support large HDs such as the one you plan to buy? If yes, then just format the new drive as you please. If no, then create a small partition at the start for the 'boot' directory and format the rest, taking care in the instructions below; you can copy everything as described except for the contents of '/boot' - they need to be copied to your special small partition.

1. mount the new disk - say at /mnt

2. copy the following directories (as 'root', to preserve permissions etc) using the "archive" option: cp -a
-- /root
-- /etc
-- /var
-- /usr
-- /lib (and lib64 if you have it)
-- /bin
-- /sbin
Then check your original system and see if there are a few other special files to copy, like 'vmlinuz', 'initrd' and other such in the top directory.

3. Create the following directories on the new HD:
/dev
/proc
/sys
/mnt
Check and create any other special directories specific to your distro.
Make sure the permissions/owner are all the same as the original.
Now, what goes into the /dev directory depends ... on many modern systems with udev, the directory simply has to exist; it is actually built from scratch as the initrd startup scripts run, but the directory needs to exist so that it can be used as a mount point. On older systems, you'd actually need to make a copy of the /dev directory using 'cp -a' as in step 2.

4. Set up the bootloader. Personally I find 'lilo' easier to set up in this case, but that's just because I never had time to really look at Grub.

5. Reboot and hope it all works. :) Otherwise, Live CD + chroot + fix up the bootloader and try again.

Duck2006 06-27-2008 08:54 AM

Use the DD commands, search LQ for the thread on the commands.

syg00 06-27-2008 10:02 AM

This being Linux, here's another option - hopefully not to confuse you too much.
*Don't* use dd - it has no concept of filesystems, or f/s errors. "dd" is fine when there are no errors - bloody disaster waiting to happen otherwise. How are you going to know the difference ???.

In the interests of keeping it simple, use a liveCD, and simply use "cp -a source destination"
The *whole* partition - no need to worry about pseudo filesystems, mount issues or anything. Just copy the lot.
Then simply fix up the boot-loader (and maybe fstab).
Done.

grayFalcon 06-27-2008 11:36 AM

Thanks a lot for all the feedback! I'd feel happier using dd, but I guess I don't want to spend the next weekend hunting down unreported errors during the copy process... So I guess I'll go with the cp -a.

Thanks a lot again!


All times are GMT -5. The time now is 02:20 AM.