-   Linux - General (
-   -   Restore LVM disk from image, made by dd (

tolsty7 07-09-2010 01:27 AM

Restore LVM disk from image, made by dd
I hav LVM:


  LV      VG        Attr  LSize  Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup01 -wi-a- 145.03g
  LogVol01 VolGroup01 -wi-a-  3.91g

And backup of LogVol00, that was made like this:

dd if=/dev/mapper/VolGroup01-LogVol00 bs=64K | gzip -c |  > /mnt/usb/backup.img.gz
when i try to:

gunzip -c /mnt/usb/mapper_VolGroup01-LogVol00.img.gz | dd of=/dev/mapper/VolGroup01-LogVol00 conv=sync,noerror bs=64K
there is no errors, but when i try to mount recovered partition, i see an error:

# mount /dev/mapper/VolGroup01-LogVol00 /mnt-user/00/
mount: wrong fs type, bad option, bad superblock on /dev/mapper/VolGroup01-LogVol00,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

I need that partition alive. Please, help me with it.

rayfordj 07-10-2010 06:07 PM

Did you find anything useful in syslog or check dmesg output as suggested when the mount failed?
When I tried this and checked dmesg output it reports: EXT3-fs: no journal found.
(You did not specify what filesystem was on your .img.gz so I went with ext3.)

Edit 1:

dd if=/dev/VolGroup01/LogVol00 bs=64K | gzip -c > /mnt/usb/backup.img.gz

gzip -d -c /mnt/usb/backup.img.gz | dd of=/dev/VolGroup01/LogVol00 conv=sync,noerror bs=64K

mount /dev/VolGroup01/LogVol00 /mnt-user/00/


dd if=/dev/VolGroup01/LogVol00 bs=64K | gzip -c > /mnt/usb/backup.img.gz

gzip -d -c /mnt/usb/backup.img.gz > /mnt/usb/backup.img

dd if=/mnt/usb/backup.img of=/dev/VolGroup01/LogVol00 conv=sync,noerror bs=64K

mount /dev/VolGroup01/LogVol00 /mnt-user/00/

Not sure why decompressing first and then using dd on decompressed .img to place it on the LV works while the decompression to stdout and pipe to dd fails, but worth a shot to see if it works for you if you have the ~145.03g free somewhere to stage it.

Edit 2:

OK, the bs=64K seems to be what is breaking it for me. When I use bs=512, while it takes substantially longer, I do not get 'No space left on device' and I am able to successfully mount the filesystem on it.

syg00 07-10-2010 06:38 PM

That looks suspiciously like you are over-writing a lv on a running system ... :eek:
I'm thinking you'll need to rescan those (LVM) devices - search here on LQ for pvscan and vgscan (and vgchange).

rayfordj 07-10-2010 07:15 PM

Try this first:

gunzip -c /mnt/usb/mapper_VolGroup01-LogVol00.img.gz | dd of=/dev/mapper/VolGroup01-LogVol00 conv=sync,noerror bs=512
If that does not work and you have the space to stage the dd img somewhere before writing it to /dev/VolGroup01/LogVol01, try the steps in my previous post under "SUCCESS".

tolsty7 07-12-2010 02:00 AM

A have a lot of place for decompress images on /mnt/usb. The problem should be in dd-ing worked system drive. I have to made a snapshot if i want to backup without freezing my server, but i did not.

All times are GMT -5. The time now is 11:59 PM.