Restoring disk after hardware failure

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

Restoring disk after hardware failure

Postby mackowiakp » Aug 23rd, '15, 15:30

I have to restore content of 480 GB SSD broken disk to new one 240 GB (smaller). I have ISO files created usin "dd" of /root (aprox 20 GB on previous disk) and /home (20 GB too on previous). All the rest of previous 480 GB SSD HDD was used for user data as separate partition mounted to /home/user_dir,. I have a copy of this files too (aprox 30 GB).
So how can I restore /root and /home partitions and make disk bootable? The third partition I can restore just by creating new one and simply copy user data files. Please advice me because it is my wife laptop :cry:
Linux is like wigwam. No Windows, no Gates but Apache inside

WARNING ! The administrator has the right to refuse to install WINDOWS, invoking the conscience clause
mackowiakp
 
Posts: 660
Joined: May 23rd, '13, 07:32
Location: Gdynia, Poland

Re: Restoring disk after hardware failure

Postby jiml8 » Aug 24th, '15, 00:11

For the future, I recommend that you study https://forums.mageia.org/en/viewtopic.php?f=41&t=5957this thread and implement the backup system it describes. This will keep your data safe, in a fashion that is independent of the size of the disk on which that data resides, and restores are dead simple.

To deal with your current situation, you need to open those images you created with dd. Exactly HOW you open them depends on exactly how you took them. It would be helpful if you could provide that information (the exact dd command you used).

Assuming, for the moment, that you took those images as partition images, then the following should work.

Attach the drive containing the dd image, then mount it to some mountpoint:
Code: Select all
mount -o loop -t ext4 /path/to/myddimage.iso /path/to/mymountpoint

This, of course, presumes that the filesystem on the dd image is ext4. Modify as necessary.

If this worked, then you can cd into mymountpoint and directly access all the files that are there.
Now, IF you took this information as a complete disk image, the problem is somewhat more complicated. In this event, proceed as follows:

First, find the partition in the image you wish to mount:
Code: Select all
parted myddimage.iso unit b print

Then assign it to a loop device:
Code: Select all
losetup -o<starting byte of partition from previous command> /dev/loopN myddimage.iso

where the N in loopN is a number from 1 to 8 (typically) representing an unused loop device that you intend to use for this.

Then, mount the partition:
Code: Select all
 mount /dev/loopN /path/to/mymountpoint


You may now cd into mymountpoint and see your data.

Later, unmount this guy like this:
Code: Select all
umount mymountpoint
losetup -d /dev/loopN
jiml8
 
Posts: 1254
Joined: Jul 7th, '13, 18:09

Re: Restoring disk after hardware failure

Postby jiml8 » Aug 24th, '15, 00:15

Actually, if you did use dd to take a disk image, and both / and /home were at the front of the old drive, then you can just use dd to lay that image onto the new drive and it shouldl work fine. If you imaged the entire older drive, then any partitions that end after the end of the new drive or begin after the end of the new drive will be messed up and may or may not be accessible, but the / and /home partitions would be available.
jiml8
 
Posts: 1254
Joined: Jul 7th, '13, 18:09

Re: Restoring disk after hardware failure

Postby mackowiakp » Aug 24th, '15, 10:02

I created ISO file using script below. Script create compressed ISO file, count md5 sum and copy file to my home server:

Code: Select all
for i in 1 5 7
do
dd if=/dev/sda$i bs=10M conv=notrunc | gzip -c > /home/maciek/back/RSYNC/piotr_sda$i.iso.gz && md5sum /home/maciek/back/RSYNC/piotr_sda$i.iso.gz | awk '{ print $1 }' > /home/maciek/back/RSYNC/piotr_sda$i.iso.gz.md5 && ncftpput -u user -p password server /home/media/disk-2/ /home/maciek/back/RSYNC/piotr*
rm -f /home/maciek/back/RSYNC/piotr_sd*
done
Linux is like wigwam. No Windows, no Gates but Apache inside

WARNING ! The administrator has the right to refuse to install WINDOWS, invoking the conscience clause
mackowiakp
 
Posts: 660
Joined: May 23rd, '13, 07:32
Location: Gdynia, Poland

Re: Restoring disk after hardware failure

Postby doktor5000 » Aug 24th, '15, 19:23

They are not .iso images simply because you give them the ending .iso, they are still simple partition images (and in the case usually they get the ending .img).

And as they are .gzip compressed, mounting them directly is quite a bit harder then uncompressed images.
You should definitely read http://unix.stackexchange.com/questions ... on-the-fly to switch your backup process.

It also contains a link to a workaround so you could directly loop-mount your partition images:
https://blogs.gnome.org/muelli/2012/10/ ... pped-file/
Or try archivemount: http://linuxaria.com/howto/how-to-mount ... ile-system
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18059
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest