LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Recovering data from a hard drive with LVM a partition (http://www.linuxquestions.org/questions/linux-software-2/recovering-data-from-a-hard-drive-with-lvm-a-partition-782945/)

ShadyCraig 01-18-2010 06:19 AM

Recovering data from a hard drive with LVM a partition
 
Hello all,

I have an external USB hard drive that I need to recover some data from, but I see from fdisk -l that the partition uses LVM:
Code:

[root@localhost ~]# fdisk -l /dev/sdd

Disk /dev/sdd: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdd1  *          1      19457  156288321  8e  Linux LVM
[root@localhost ~]#

I've followed various lvm tutorials all of which describe setting up lvm from fresh on empty disks. Unfortunately non mention how to 'install' new a drive that was previously set up with lvm.

I have had a go anyway and may have now lost my data. Here's what I've ended up with (the partition in question is sdd1):
Code:

[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name              /dev/sdd1
  VG Name              vg02
  PV Size              149.05 GB / not usable 1.31 MB
  Allocatable          yes
  PE Size (KByte)      4096
  Total PE              38156
  Free PE              12
  Allocated PE          38144
  PV UUID              HmVjPK-gHmG-LJqF-jy1c-fQwK-M1KL-t0MlKs

  --- Physical volume ---
  PV Name              /dev/sda2
  VG Name              VolGroup00
  PV Size              7.90 GB / not usable 23.41 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              252
  Free PE              0
  Allocated PE          252
  PV UUID              400PwS-P1j1-uQP0-2pNq-rqsL-DiNW-VYbM5j

Code:

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name              vg02
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                1
  Open LV              0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size              149.05 GB
  PE Size              4.00 MB
  Total PE              38156
  Alloc PE / Size      38144 / 149.00 GB
  Free  PE / Size      12 / 48.00 MB
  VG UUID              TSEAlK-3HlT-utMW-0JEm-n45l-Hgmb-Vu4u1E

  --- Volume group ---
  VG Name              VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                2
  Open LV              2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size              7.88 GB
  PE Size              32.00 MB
  Total PE              252
  Alloc PE / Size      252 / 7.88 GB
  Free  PE / Size      0 / 0
  VG UUID              BGOVZ1-5U0e-3ATo-XQLG-82l1-uuc8-hhaizP


Code:

[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg02/lv02
  VG Name                vg02
  LV UUID                c2Ztsz-7yak-N5W0-aYs1-xXZd-lXQO-kC3VOs
  LV Write Access        read/write
  LV Status              available
  # open                0
  LV Size                149.00 GB
  Current LE            38144
  Segments              1
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    256
  Block device          253:2

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                gbFYmV-F8uI-81R5-mYSg-p8KW-HNgo-V0R4hg
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                7.38 GB
  Current LE            236
  Segments              1
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    256
  Block device          253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                cCVgp7-5bXf-wfng-nyQO-e77D-aHgd-CBsI0B
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                512.00 MB
  Current LE            16
  Segments              1
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    256
  Block device          253:1

Code:

[root@localhost ~]# mkdir /media/sdd1/
[root@localhost ~]# mount /dev/vg02/lv02 /media/sdd1/
mount: you must specify the filesystem type
[root@localhost ~]# mount -t ext3 /dev/vg02/lv02 /media/sdd1/
mount: wrong fs type, bad option, bad superblock on /dev/vg02/lv02,
      missing codepage or other error
      In some cases useful info is found in syslog - try
      dmesg | tail  or so

I've tried mounting with other fstypes, but all give the same error.

Can anyone help me recover my data please?

Thanks,
Craig

jschiwal 01-18-2010 07:16 AM

Use "/sbin/vgmknodes" to create the /dev/dm-* nodes for the logical partition on the LVM volume. Then mount those nodes.

ShadyCraig 01-18-2010 10:36 AM

Hi jschiwal,

Thanks for your reply, unfortunately it didn't help on this occasion.

At first vgmknodes didn't seem to do anything, especially as nothing appears in /dev/dm-*, not even for the working LVM drives.

So I ran 'vgmknodes -v -v', part of the output is here:
Code:

      /dev/sdd1: lvm2 label detected
      Locking /var/lock/lvm/V_vg02 RB
      /dev/sdd1: lvm2 label detected
      /dev/sdd1: lvm2 label detected
      Removing /dev/vg02/lv02
      Linking /dev/vg02/lv02 -> /dev/mapper/vg02-lv02
      Unlocking /var/lock/lvm/V_vg02

So I guessed that my system uses /dev/mapper rather than /dev/dm-.

Next I tried 'mount /dev/mapper/vg02-lv02 /media/sdd1'', this failed as before, the same goes for using -t:
Code:

[root@localhost ~]# mount /dev/mapper/vg02-lv02 /media/sdd1/
mount: you must specify the filesystem type
[root@localhost ~]# mount -t ext3 /dev/mapper/vg02-lv02 /media/sdd1/
mount: wrong fs type, bad option, bad superblock on /dev/mapper/vg02-lv02,
      missing codepage or other error
      In some cases useful info is found in syslog - try
      dmesg | tail  or so

Thanks again,
Craig

r0b0 01-19-2010 03:54 AM

You are mounting the correct device (either path should work). I think the problem is either with broken filesystem (try fsck) or another filesystem type (try using mount without the -t option).

jschiwal 01-19-2010 06:47 AM

A quick check on a partition is to run "sudo file -s /dev/<device>". It will tell you what filesystem is on it. Then you can run fsck.<filesystem> to check the filesystem for errors.

Sometimes there is a filesystem in /dev/mapper/ and another such as /dev/dm-0.

Also look at "ls -l /dev/disk/by-uuid/" and follow the links. Using UUID=<UUID #> in /etc/fstab is preferable for external drives.

ShadyCraig 01-19-2010 07:47 AM

given up
 
Quote:

Originally Posted by r0b0 (Post 3831909)
You are mounting the correct device (either path should work). I think the problem is either with broken filesystem (try fsck) or another filesystem type (try using mount without the -t option).

Thanks robo, I tried mounting without the -t, but when that failed I tried using explicit types.

Quote:

Originally Posted by jschiwal (Post 3832049)
A quick check on a partition is to run "sudo file -s /dev/<device>". It will tell you what filesystem is on it. Then you can run fsck.<filesystem> to check the filesystem for errors.

Sometimes there is a filesystem in /dev/mapper/ and another such as /dev/dm-0.

Also look at "ls -l /dev/disk/by-uuid/" and follow the links. Using UUID=<UUID #> in /etc/fstab is preferable for external drives.

It never occurred to me to use 'file' in that way, that's really handy!

Unfortunately I think I have a stuffed file system :-( as 'file' doesn't come back with anything useful, and I think I've done everything correctly.

I'll have to read up on the UUID stuff as it didn't make sense on my system, the UUIDs in there weren't used by anything listed by pv/vg/lvdisplay. Thanks for the pointer though.

Thanks for your help but I'll give up on this now,
Craig

jschiwal 01-21-2010 02:03 AM

Be sure you use "file -s" on the logical volume. Using it on a Physical volume or volume group won't give you a filesystem.

If the logical volumes were used to create a raid array, then you may not have a filesystem on the logical volume.


All times are GMT -5. The time now is 08:33 AM.