LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Cant restore my hard drive disk properly (https://www.linuxquestions.org/questions/linux-desktop-74/cant-restore-my-hard-drive-disk-properly-837745/)

DuarteSilva 10-13-2010 04:04 AM

Cant restore my hard drive disk properly
 
Hi all, this is going to be my 1st entry in this forum so any mistake i may do forgivme for it.

NEWBIE ALERT :redface:

So here's my problem:

I made a backup of my hard drive to my external disk using the command dd i done it like this:

dd if=/dev/sda of=/mnt/usbdrive/test.img

the copy was made without any errors, after that i tried to "recover" my hard drive with the same command:

dd if=/mnt/usbdrive/test.img of=/dev/sda

and my problems started, sometimes the "recover" finished but then when i reboot the OS wasnt working properly other times the "recover" didnt even end.

My hard drive has several disk partitions and i need them all that's why i used /dev/sda insted /dev/sda1 .

Ty in advance

Ps- I dont have cd-rom drive

prayag_pjs 10-13-2010 04:28 AM

Hi,

There is nothing much to suggest you as we dont know exact problem, I mean "OS wasnt working properly" means what?

Was the external drive was of same size or of more size of original one?

And why don't you do directly this:

Quote:

dd if=/dev/sda of=/dev/sdb bs=512

DuarteSilva 10-13-2010 05:46 AM

i got some other question about this "recover", when im making the "recover" of my hard drive with the dd command from my flash disk how it will be with the OS? I mean all the configurations will be like the OS from the flash disk? Or they will be like the current OS? Will i have trouble with that?

Dont know if i make me to understand myself, rigth now im making a copy of my hard drive with that command line u gave me.

ty

DuarteSilva 10-13-2010 11:18 AM

after used dd if=/dev/sda of=/dev/sdb i had a error:

EXT3-fs error (device sda5): ext3_free_blocks_sb: bit already cleared for block 1249201

i believe its some error in my 5th partition...
any idea that this may be?

ty

gammahermit 10-13-2010 02:01 PM

First off dd isn't a good program to use for backups of an entire drive. It makes a byte for byte image of that disk. Which may sound good but it can cause problems and should only be used in certain situations and when you know what you are doing. It would be better to use a GUI program that will handle all the details for you or just tar which is how I do backups.

But anyways we need some more information. How big is the drive you are backing up? How many partition are on it? What is on them, an operating system or just data? How big is the flash drive you are saving the image to?

Quote:

i got some other question about this "recover", when im making the "recover" of my hard drive with the dd command from my flash disk how it will be with the OS? I mean all the configurations will be like the OS from the flash disk? Or they will be like the current OS? Will i have trouble with that?
Do you have a rescue linux distro installed on the flash drive? Well regardless the image will be an exact copy of whatever was on sda at the time you made the image. Whatever else in on the flash drive won't effect the image.


Quote:

after used dd if=/dev/sda of=/dev/sdb i had a error:
You don't want to run that exact command. Since it will copy the contents of the second hard drive onto the first. You want of= to be the image you made "test.img".

DuarteSilva 10-14-2010 04:38 AM

The drive Im backing up has 250 GB and it has 8 partitions, ther's a Linux OS, i will put the problem like this i need to have that OS and partitions in a USB hard drive for later use in other desktops that may have problems, my intention is to recover those desktops with problems all the desktops got the same functions/systems.
My USB drive has 160GB but from those 250 GB from my hard drive only 5 GB are being used from all partitions.
My flash drive is completly empty.

Question: Lets say i got something in the flash drive (sdb) and i do dd if=/dev/sda of=/dev/sdb , what will happen with the other things in there? And after i do that command if i do the if=/dev/sdb of=/dev/sda what will happen with the things that were already in the flash drive? They will also be replicated into the hard drive(sda)?

Ty for all the help

gammahermit 10-14-2010 07:45 AM

Okay I see what you want to do know. But you can't use dd to do it. dd will just copy the first 160GB of the 250GB hard disk to the flash drive. And it wont be the actual used space it will just be the first 160 billion bytes of data. Even if the data is just 00000000. dd does a byte for byte copy, it doesn't care if it is actual data or just padded zeros, it will copy it over.

Well it may still be possible to use dd if you really want to. You can compress the image you make with dd then copy it to the flash drive. According to the man page if you omit `of=` it will just write it to stdout. Then you can pipe that through bzip. So something like `dd if=/dev/sda | bzip2 -c > sda.bz` might work. Then to restore it you could do `bunzip2 -c sda.bz | dd of=/dev/sda`.

Note: I don't know if that would actually work but it is worth a try. I'm sure that there are programs to do what you want. If you do some googling you should be able to find something. I can't recommend anything since I've never used any.

DuarteSilva 10-14-2010 08:37 AM

I see, what can u tell me about tar command? it will make backups from the partitions also?

ty in advance

gammahermit 10-14-2010 09:22 AM

Taring only archives the files and directories not the filesystem or partition. So you would have to make a tarball (a tarball is just a tar archive compresses with gzip) of all the files in each partition. If you have 8 partitions you would have to make 8 tarballs for each of them. Then when you want to restore from the backups you would have to restore each tarball to the right partition overwriting the files. Unless there was a problem with the drive itself in which case you would first have to recreate all of the partitions then make a filesystem on each of them then mount them and finally unarchive the tarball in the correct mount point.

If you only had to backup one or two partition then tar would be a good way to do it. But since you have 8 it probably isn't the best solution.

DuarteSilva 10-14-2010 09:27 AM

Im going to try the ziped dd file then

dd if=/dev/sda | bzip2 -c > sda.bz from what i understnad this will make a ziped image file from all my hard drive in my main partition?

kilgoretrout 10-14-2010 11:57 AM

Try using something like Clonezilla; it's a lot easier to use and can clone an entire hard drive to a single image file like you want:

http://clonezilla.org/

DuarteSilva 10-15-2010 03:30 AM

It seems i made it done +/- properly, with the dd commnad piped with zip to make the backup, after I deployed the backup and i had some erros, but then i runed the fsck command in all partitions and the desktop started to work properly, dunno if is the best/fast way do make and deploy backups.

Any more advices/sujestions are welcome, mybe i will try the clonezilla.

Ty for evrything
THis forum rocks! :cool:


All times are GMT -5. The time now is 03:37 PM.