LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-18-2010, 06:19 AM   #1
ShadyCraig
LQ Newbie
 
Registered: Jan 2001
Location: UK - Midlands
Distribution: Redhat various
Posts: 29

Rep: Reputation: 15
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
 
Old 01-18-2010, 07:16 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Use "/sbin/vgmknodes" to create the /dev/dm-* nodes for the logical partition on the LVM volume. Then mount those nodes.
 
Old 01-18-2010, 10:36 AM   #3
ShadyCraig
LQ Newbie
 
Registered: Jan 2001
Location: UK - Midlands
Distribution: Redhat various
Posts: 29

Original Poster
Rep: Reputation: 15
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
 
Old 01-19-2010, 03:54 AM   #4
r0b0
Member
 
Registered: Aug 2004
Location: Europe
Posts: 600

Rep: Reputation: 49
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).
 
Old 01-19-2010, 06:47 AM   #5
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
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.

Last edited by jschiwal; 01-19-2010 at 06:54 AM.
 
Old 01-19-2010, 07:47 AM   #6
ShadyCraig
LQ Newbie
 
Registered: Jan 2001
Location: UK - Midlands
Distribution: Redhat various
Posts: 29

Original Poster
Rep: Reputation: 15
Thumbs up given up

Quote:
Originally Posted by r0b0 View Post
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 View Post
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
 
Old 01-21-2010, 02:03 AM   #7
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
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.
 
  


Reply

Tags
data, lvm, mount, recovery


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving LVM partition to larger hard drive blainehilton Fedora 2 11-20-2007 02:36 PM
LVM - recovering data after a disk failure. bogaurd Linux - Software 2 12-19-2005 11:34 AM
Recovering data from LVM Child of Wonder Linux - Hardware 5 11-12-2005 06:29 AM
Recovering NTFS partition off repartitioned hard drive jhayden Linux - Hardware 3 08-30-2004 10:51 AM
Recovering data from a failed hard drive. 2damncommon LinuxQuestions.org Member Success Stories 0 10-03-2003 11:16 PM


All times are GMT -5. The time now is 02:47 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration