LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 06: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, 07: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, 08: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, 10:02 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
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, 11:36 AM   #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



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 08:53 AM
Copying files from internal Hard drive to USB 2.0 Hard Drive is NOT Behaving tubatodd Ubuntu 4 02-19-2007 04:32 PM
copying OS to new hard drive slackhack Linux - General 13 06-03-2006 02:30 PM
Needing help copying large hard drive to smaller drive sdubble Linux - Software 1 02-21-2006 12:06 PM
Copying from one hard drive to another Cirdan Linux - Hardware 3 01-08-2006 06:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:24 PM.

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
Open Source Consulting | Domain Registration