Restore 2 Partitions
i have a back up image of a complete drive which contains 9 partitions. The back up was done with dd if=/dev/sda of=/dev/sdc.
Now I want to copy two of the partitions back to the original drive. How can I move to complete partitions? If I use dd if=sdc1 for example it only copies the contents of the partition but not the partition itself. I would like the entire partition moved so it can retain it's partition characteristics like UUID etc... Is there another tool i can use or am I using dd wrong??? |
|
Hello
Another good option in addition to the above recommendation would be to use FSArchiver. |
Hi
It looks like the OP has made abackup already and would like to get the 2 partitions back, Hope I'm reading that correct. If that is so then I think that you will have to dd the backup to somewhere then just dd the 2 partitions you want |
Quote:
Thanks... |
Quote:
From the second link you gave, this one doesn't seem to be right or maybe I'm doing something wrong. This is what i expected to happen; Quote:
I see they said it will create the partition. Is create the same as mirroring the existing partition meaning it will have the same UUID etc...? Also, what does this stuff mean at the end of the command? I've never been able to figure out when to use what so I never use any of them, "bs=4096 conv=notrunc,noerror". I go with the strait command and it hasn't failed me yet. |
Quote:
Quote:
|
Have a look at this might help explain some things
http://en.wikipedia.org/wiki/Dd_%28Unix%29 |
Quote:
|
Quote:
Quote:
|
gpt partitions also have a UUID - in addition to the UUID of the filesystem - but is rarely used in "normal" situations.
Be aware if you do restore a partition as you plan, if the original filesystem is still there (different partition) you will not be able to mount both as they will have the same UUID. |
Quote:
Thanks... |
My "lazy way" of cloning a drive is to copy the contents to a drive of the same size or bigger using dd.
I then do like the following: have the SOURCE and TARGET drives connected to a PC or something that runs linux. One way is to use a live linux system on a CD or USB stick. And Clonezilla is a very good live cloning system that can manage most drive cloning with ease, but one can also boot Clonezilla up and use the shell to manually do some operations. Clonezilla have a great support of different hardware, like raid controllers, LVM et cetera already set up for you. Ok. The drives are connected. Make sure they are not mounted in any way! command 'df' will show if they had been automounted. Then umount them If there are raid partitions on any of the disks, (SOURCE or TARGET), then the command 'cat /proc/mdstat' will show if the raid partions have been automatically loaded by the system. You will in that case want to stop the raid partitions. Lets say you want to clone sda to sdd, and 'cat /proc/mdstat' give you the following: Code:
Personalities : [raid6] [raid5] [raid4] [raid0] Recheck /proc/mdstat will to see that you stopped the raid set. You will not damage anything unless you stop the raid in the actual booted os that uses the raid. You will merely so to say "unmount" the raid set. So far, so good. You can check what partitions and filesystems you currently have on your disks by the commands: Code:
blockdev --report Code:
blkid Lets say that the TARGET drive already have some partitions on it. Then you will have to remove them first. Easiest way is to remove them with 'cfdisk' or 'fdisk' or whatever your prefer. If there are any DOS partitions, you will have to remove them, and then reboot to make sure the system forgets about them. (d*mned sneaky BIOS)! Check that the partiotions are all gone on /dev/sdd by the command: Code:
ls /dev/sdd* Then, to be paranoid, you can completely remove the partitioning and boot sector data from the target drive, through the following command, where we use /dev/sdd as the TARGET drive: Code:
dd if=/dev/zero bs=1k count=64k of=/dev/sdd (Dont forget the 'sync'. It makes sure the writes are flushed to the disks). Next step, when we have the SOURCE and TARGET drives online and unmounted, is to copy the partitions. Simplest way is to first copy over partition table and boot sector from the SOURCE, like the following where SOURCE is /dev/sda and TARGET is /dev/sdd Code:
dd if=/dev/sda bs=1b count=42 of=/dev/sdd Then open up the target drive in cfdisk, take a look, and then Write the contets (unchanged) to disk. Code:
cfdisk /dev/sdd If you have copied/created any DOS partitions you will have to reboot before the next step. You can now check that the partitioning has been copied from /dev/sda to /dev/sdd with: Code:
ls /dev/sda* /dev/sdd* Code:
dd if=/dev/sda of=/dev/sdd Code:
dd if=/dev/sda1 of=/dev/sdd1 Disks now have the same partitions, MBR, UUID's and disk volume id. Remember that strange things will happen if you connect both these disks to the same PC, or uses these two disks in two PCs, sinve they have the same UUIDs and disk volume ids. (Especially if you use Windows). Bear in mind that some PCs use the "dead space" between the first sector containing master boot record and partition table, and the first partition on disk for things like hibernation storage and other "under the hood handling", like for example the IBM/Lenovo Thinkpad laptops, so for a safe clone, just copy the entire drive. But i still think you should use either Clonezilla or R-Studio to copy the drive. Safer that way. |
Why back up a drive image to another drive. Why not back it up to a file. If you zero out free space, you can pipe the output of did through gzip, saving space. Image backups are fine after a fresh install, and that is when you have the most free space available. If you save an uncompressed image, you can use losetup to access a partition in it.
|
All times are GMT -5. The time now is 09:18 PM. |