Wednesday, November 21, 2007

Mounting LVM Disk using Ubuntu livecd

Mounting is an easy process to do, provided the filesystem type you are using is supported. What happen when you have an LVM formatted disk, and you need to mount it because the disk cannot be booted and a hell lot of valuable data kept inside?? Do not worry, because the solution is here.......

1. Get a live cd, for example, Ubuntu. For this article, I use Ubuntu 6.06 (I cannot find any latest version of ubuntu at my place)

2. Boot using the live cd. Search for these tools: lvm2. If the cd do not have it, install it.
# apt-get install lvm2

3. To make sure the harddisk is recognised, you can use fdisk
# fdisk -lu

4. Once installed, run pvscan to scan all disks for physical volume. this to make sure your LVM harddisk is detected by Ubuntu
# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [74.41 GB / 32.00 MB free]
Total: 1 [74.41 GB] / in use: 1 [74.41 GB] / in no VG: 0 [0 ]


5. After that run vgscan to scan disks for volume groups.
# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2


6. Activate all volume groups available.
# vgchange -a y
2 logical volume(s) in volume group "VolGroup00" now active

7. Run lvscan to scan all disks for logical volume. You can see partitions inside the hard disk now active.
# lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [72.44 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit

8. Mount the partition to any directory you want, usually to /mnt
# mount /dev/VolGroup00/LogVol00 /mnt

9. You can access the partition in the /mnt directory and can backup your data

52 comments:

  1. This is exactly the solution I was searching for, and it worked a treat. Thanks. Please leave this page up for others!

    ReplyDelete
  2. Hi thanks for this post. For some reason I add to load a driver manually after having installed the lvm2 package:

    $ modprobe dm-mod

    Otherwise you get the following:

    $ lvscan
    /proc/misc: No entry for device-mapper found
    Is device-mapper driver missing from kernel?

    ReplyDelete
  3. Thanks a lot, for the post and anonymous for the comment about modprobe dm-mod!

    At first, I got a couple of lines like:

    ubuntu@ubuntu:~$ sudo vgchange -a y
    /proc/misc: No entry for device-mapper found
    Is device-mapper driver missing from kernel?
    Failure to communicate with kernel device-mapper driver.

    and lvscan gave problems as well:
    Failure to communicate with kernel device-mapper driver.
    Incompatible libdevmapper 1.02.20 (2007-06-15)(compat) and kernel driver
    inactive '/dev/tmp/tmp' [2.00 GB] inherit


    After sudo modprobe dm-mod, it worked like a charm.

    ReplyDelete
  4. Thanks a lot, for the post and anonymous for the comment about modprobe dm-mod!

    At first, I got a couple of lines like:

    ubuntu@ubuntu:~$ sudo vgchange -a y
    /proc/misc: No entry for device-mapper found
    Is device-mapper driver missing from kernel?
    Failure to communicate with kernel device-mapper driver.

    and lvscan gave problems as well:
    Failure to communicate with kernel device-mapper driver.
    Incompatible libdevmapper 1.02.20 (2007-06-15)(compat) and kernel driver
    inactive '/dev/tmp/tmp' [2.00 GB] inherit


    After sudo modprobe dm-mod, it worked like a charm.

    ReplyDelete
  5. Great post indeed, and thank you 100 times for the 2nd post! This helped med alot.

    ReplyDelete
  6. Thanks a lot you guys for all the comments. Learned a lot from the comments

    ReplyDelete
  7. This post has been immensely helpful. I can now see my LVM filesystem in Thunar File Manager and can access the files... with one small caveat. The one directory that I really need access to has an X on the folder and tells me permission denied. Anyone have any ideas?

    ReplyDelete
  8. rfinn, if you log in as root or just use the "sudo" command, it ignores the permissions and lets you look at the file (and also to change its permissions, if you so desire).

    ReplyDelete
  9. AnonymousMay 06, 2008

    What a lifesaver! Thanks for the information. Adding modprobe dm-mod (per one of the comments) between steps 1 and 2 did the trick for me. Thanks to your post, I retrieved all data I thought I was never going to be able to from an lvm disk.

    ReplyDelete
  10. Many thanks for the posting....
    It helps me a lot to restore and move my company's old files to new server...
    really works...
    thanks

    ReplyDelete
  11. thanks for modprobe dm-mod ....

    ReplyDelete
  12. Thanks a lot! It was very useful for me

    ReplyDelete
  13. Sweet!

    This worked like a charm and allowed me to access a ton of information I had stored on a LVM partition.


    Thanks a million.

    ReplyDelete
  14. anon delived
    modprobe dm-mod
    is what i needed

    ReplyDelete
  15. nice post

    ReplyDelete
  16. "After sudo modprobe dm-mod, it worked like a charm."


    Bacon SAVED!!!! thanks

    ReplyDelete
  17. Thank you for this, within 5min I got what I wanted.

    ReplyDelete
  18. Lifesaver. Where do I donate!?

    ReplyDelete
  19. So many thanks for this tip! It worked just fine. Please leave it for others too.

    ReplyDelete
  20. thanks a lot , I was looking for this .

    You can do all things using GUI tool too. "logical volume manager" package from ubuntu.

    ReplyDelete
  21. Excellent! Exactly what I needed.

    ReplyDelete
  22. very helpful post, thank you.

    ReplyDelete
  23. two thumbs up! thanks!

    ReplyDelete
  24. it's 8 hours i look for it !
    thank you verrrrrrrrrry much ;)

    ReplyDelete
  25. Hello, Thanks by your Post, I follow all successfully, but, in the las step say:

    # /bin/mount /dev/VolGroup00/LogVol00 /disco2/
    mount: debe especificar el tipo de sistema de ficheros

    can you helpme please? regards wualfred

    ReplyDelete
  26. Hello, Thanks by your Post, I follow all successfully, but, in the las step say:

    # /bin/mount /dev/VolGroup00/LogVol00 /disco2/
    mount: debe especificar el tipo de sistema de ficheros

    can you helpme please? regards wualfred

    ReplyDelete
  27. thx ! exactly what I need. Good job.

    ReplyDelete
  28. Thanks very much for this great tutorial. I followed the instructions exactly as posted and it worked like a charm. Keep up the good work.

    by Mike A.

    ReplyDelete
  29. Thank you so much for posting this, it was very helpful. I did have some issues with permissions when I was trying to get the data off the old LVM partitioned disks. I was able to fix it with chmod and chown commands run under sudo, and remember to use the -R switch so that the new permissions will be applied to all sub folders and files recursively.

    THANKS AGAIN!!!

    ReplyDelete
  30. AnonymousJuly 07, 2011

    Thank you very much !!!

    ReplyDelete
  31. AnonymousJuly 19, 2011

    Beautiful. Thank you very much. nothing like screwing up the boot sequence on an lvm locked drive.

    ReplyDelete
  32. Thank you so much

    ReplyDelete
  33. Many thanks, please keep the post.

    ReplyDelete
  34. Great concept chosen in this post, which seems to be really helpful to everyone to improve their knowledge.

    ReplyDelete
  35. Thanks for sharing the nice thought with the readers..

    ReplyDelete
  36. This was really usefull for me. Thanks very much!

    ReplyDelete
  37. Just wanted to convey my appreciation for what I learned from this article. I look forward to learning more on this website.

    ReplyDelete
  38. Thanks man, this works fine!

    ReplyDelete
  39. Thanks. I was pulling my hair out trying to figure this out. Surprised there's not more guides out there on this.

    ReplyDelete
  40. TKS, YOU SAVE MY LIFE!

    ReplyDelete
  41. Hey guys, i want to ask for help in mounting logical volume. I followed the instructions above and from others sites. But my problem is on mussing volume groups. when I run pvscan,pvs, pvdisplay, the VG field is empty. When I run lvscan and vgscan, No volume groups found message would be return. Hope you will help me. I have been researching this for two days now. Thanks.

    ReplyDelete
  42. Hi Jan Mark Salarda,

    if your pv is not available, u need to create it first using pvcreate command, followed by vgcreate command and then lvcreate to create logical volume. You then need to format it out to whatever file system you desire, before you can mount it to any directory that you wish.

    Hope that helps :)cf c

    ReplyDelete
  43. Thanks for reply.
    My physical volumes are available.
    Pvs command will return two PV. But VG field is empty on the two PV result. I'm thinking of creating a new VG then adding the existing PV.
    But my concern is if my deleted will be deleted if I'm going to do it. Will my data be deleted? Thanks

    ReplyDelete
  44. This saves a huge time of mine for reinstallation..thanks a lot!! simply superb!

    ReplyDelete
  45. Thanks a lot!!!!

    Really helped me!!!

    ReplyDelete
  46. The ubuntu 13.04 to 13.10 boned up my LVM array. This saved my stuffs!

    ReplyDelete
  47. Happy to see your blog as it is just what I’ve looking for and excited to read all the posts. I am looking forward to another great article from you.

    ReplyDelete
  48. Your guide is still useful in 2014! An update to grub 2.0 left my system unbootable. So I booted with a Live CD, but I couldn't mount my root partition, which is in LVM. Then I found your page, installed lvm2 as you described, and ran all the lvm commands pvscan, vgscan, etc, and it all worked perfectly - I can mount and browse the partition now. Next task: repair the GRUB damage.

    ReplyDelete
  49. Janos from HungaryJanuary 09, 2015

    Thanks for this excellent solution.

    ReplyDelete
  50. Thanks for all your efforts that you have put in this.Very interesting information.I would like to do all the information

    Computer Repairing Services In Delhi

    ReplyDelete