![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Dark Roasted Ubuntu
![]() |
HowTo: Transfer your bootable Ubuntu installation between hard drives
Maybe you're moving to a bigger/faster/quieter hard drive. Or just want a complete backup. Or maybe you're cloning systems in order to get closer to world domination, it doesn't matter. This is a guide to clone the contents of one hard drive to another.
Basically, use dd to clone your hard drive. The hard drive/partition you are cloning to will need to be formatted first. It's recommended you dd to an identical partition for optimal results. If you're upgrading to a larger hard drive, create a partition the same size as the old partition first, follow this guide then use the Live CD to resize the new partition. It is possible to dd a smaller partition into a larger partition, but results differ. If you can get both plugged in at the same time (maybe you have two internal slots, or an internal slot and an external hard drive case) then it's simply a case of finding the two in /dev and running Code:
sudo dd if=FROM of=TO Code:
sudo dd if=/dev/hda1 of=/dev/sda1 If you can only mount one at a time, you'll need to dd to an image, and then dd to the next hard drive. Code:
sudo dd if=FROM of=/location/of/image/save/file.raw Code:
sudo dd if=/location/of/image/save/file.raw of=TO Code:
sudo dd if=/dev/sda1 of=/home/user/image.raw Code:
sudo dd if=/home/user/image.raw of=/dev/sda1 Then you have a clone of your hard drive. You need to boot from a Live CD with the clone in a computer in order to install/fix grub on the MBR. To do this:
Code:
fsck Enjoy your new hard drive! (of course, now it's bootable, you may choose to move it elsewhere, or store it safely if it's just a back up. The old one will work just the same, as if nothing had happened) Variations of this: (will be updated often) If you're going out, and want to leave dd copying your stuff around while you go, you can set your computer to shut down afterwards. sudo only lasts 15 minutes, so to do this you'll need a root terminal. Simply open a normal terminal and type Code:
sudo su Code:
dd if=FROM of=TO && shutdown -h now
__________________
Remember when you were young? You shone like the sun. Now there's a look in your eyes, like black holes in the sky. Shine On You Crazy Diamond. Topical Matt: home | the iphone alternatives Last edited by Old Pink; November 3rd, 2007 at 05:08 PM.. |
|
|
|
|
|
#2 |
|
First Cup of Ubuntu
![]() Join Date: Nov 2007
Beans: 1
|
Re: HowTo: Transfer your bootable Ubuntu installation between hard drives
A couple points:
In the last example, where it uses the "dev" command I think you mean dd. Be very careful with dd. Make sure the "if=" and "of=" files are pointing at the correct partitions. dd will cheerfully overwrite partitions without warning. If there's any chance of errors on your disk, use the noerror and sync flags on dd. For example, Another way to copy a data from one partition to somewhere else is "cp -a". This works on mounted file systems, not raw partitions. For "cp -a" to work, the target partition must already have a file system on it. Assuming we want to copy from /mnt/hda1 to /mnt/sda2, The v flag causes cp to list all the files as it copies them. |
|
|
|
|
|
#3 |
|
Dark Roasted Ubuntu
![]() |
Re: HowTo: Transfer your bootable Ubuntu installation between hard drives
Thanks, fixed the "dev" thing, was tired and wrote this quickly.
Also, the "cp" command is great for some things but for this I'd recommend dd. You can't guarantee it will be bootable, certain things (like /dev /mnt /tmp and /media) can get in the way, file permissions aren't kept, not everything can be moved whilst in use and lots of files can get confusing. dd makes the move alot more simple.
__________________
Remember when you were young? You shone like the sun. Now there's a look in your eyes, like black holes in the sky. Shine On You Crazy Diamond. Topical Matt: home | the iphone alternatives |
|
|
|
|
|
#4 | |
|
Skinny Extra Sweet Ubuntu
![]() Join Date: Jun 2006
Location: UK, East Anglia
Beans: 3,076
Ubuntu 9.10 Karmic Koala
|
Re: HowTo: Transfer your bootable Ubuntu installation between hard drives
Actually, they are, so long as you use the -a flag as ManInTheLake says. I've used cp several times to clone/move whole partitions and it has always worked.
Quote:
|
|
|
|
|
|
|
#5 | |
|
Dark Roasted Ubuntu
![]() |
Re: HowTo: Transfer your bootable Ubuntu installation between hard drives
Quote:
Whatever, it's personal preference. This is dd specific, and people are offered cp as an alternative when they scroll to the replies. I may add it to "variations" at a later date
__________________
Remember when you were young? You shone like the sun. Now there's a look in your eyes, like black holes in the sky. Shine On You Crazy Diamond. Topical Matt: home | the iphone alternatives |
|
|
|
|
|
|
#6 |
|
Skinny Extra Sweet Ubuntu
![]() Join Date: Jun 2006
Location: UK, East Anglia
Beans: 3,076
Ubuntu 9.10 Karmic Koala
|
Re: HowTo: Transfer your bootable Ubuntu installation between hard drives
You mention everything in one neat image - or words to that effect. Have you tried using tar? That's my preferred method for archiving/cloning/copying partitions now. As you say - one image, and a nicely compressed one too.
There is one problem - Ubuntu's use of UUIDs in fstab. Of course, they will have changed if you've moved your installation from one HD to another using tar or cp, so you have to edit fstab. I've never used dd. Is the UUID preserved or is this something you need to add to your howto? |
|
|
|
|
|
#7 |
|
Way Too Much Ubuntu
![]() Join Date: May 2006
Beans: 241
Ubuntu 9.04 Jaunty Jackalope
|
Re: HowTo: Transfer your bootable Ubuntu installation between hard drives
While it's pretty cool that you can do these things from the command line, I'd still like to recommend the excellent GParted LiveCD.
|
|
|
|
|
|
#8 | ||
|
Dark Roasted Ubuntu
![]() |
Re: HowTo: Transfer your bootable Ubuntu installation between hard drives
Quote:
Quote:
__________________
Remember when you were young? You shone like the sun. Now there's a look in your eyes, like black holes in the sky. Shine On You Crazy Diamond. Topical Matt: home | the iphone alternatives |
||
|
|
|
|
|
#9 |
|
Way Too Much Ubuntu
![]() Join Date: May 2006
Beans: 241
Ubuntu 9.04 Jaunty Jackalope
|
Re: HowTo: Transfer your bootable Ubuntu installation between hard drives
I'm not knocking your nice how-to, it's just that with age I've come to appreciate the simplicity of point-and-click, not having to memorize or print a list of cli commands. Each to his own, I guess.
|
|
|
|
|
|
#10 |
|
5 Cups of Ubuntu
![]() Join Date: Nov 2007
Location: Tacloban City Philippines
Beans: 29
Ubuntu 9.10 Karmic Koala
|
Re: HowTo: Transfer your bootable Ubuntu installation between hard drives
can i dd a windows partition? lets say the entire windows drive c
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|