LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-27-2008, 07:15 AM   #1
grayFalcon
Member
 
Registered: Jan 2003
Distribution: Debian
Posts: 69

Rep: Reputation: 15
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!
 
Old 06-27-2008, 08:04 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
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.
 
Old 06-27-2008, 09:54 AM   #3
Duck2006
Member
 
Registered: Sep 2006
Distribution: Ubuntu 8.04 Hardy Heron LST
Posts: 346

Rep: Reputation: 33
Use the DD commands, search LQ for the thread on the commands.
 
Old 06-27-2008, 11:02 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,832

Rep: Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820
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.
 
Old 06-27-2008, 12:36 PM   #5
grayFalcon
Member
 
Registered: Jan 2003
Distribution: Debian
Posts: 69

Original Poster
Rep: Reputation: 15
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
copying a hard drive with dd gothicbob Linux - Newbie 2 08-18-2007 09:53 AM
Copying files from internal Hard drive to USB 2.0 Hard Drive is NOT Behaving tubatodd Ubuntu 4 02-19-2007 05:32 PM
copying OS to new hard drive slackhack Linux - General 13 06-03-2006 03:30 PM
Needing help copying large hard drive to smaller drive sdubble Linux - Software 1 02-21-2006 01:06 PM
Copying from one hard drive to another Cirdan Linux - Hardware 3 01-08-2006 07:00 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration