S
S
Sergey2014-01-13 08:02:49
linux
Sergey, 2014-01-13 08:02:49

How to mount LVM from an external drive?

So, there is a server with Linux (Ubuntu 12.04), the disk is marked with LVM.
There is a second physical disk, it also has LVM
How to mount this second disk without losing data?
Various pvs/pvscan/lvscan/lvmdiskscan/vgimport and others do not see volumes on the second disk.
In fact, before reinstalling the OS, both physical disks were in the same volume group.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Usov, 2014-01-13
@bondbig

Use kpartx (kpartx -a /dev/...) then vgscan.
if the VG names match, then it's better to use some livecd, rename the VG on an external drive, and then mount it to the main system.

Y
younghacker, 2014-04-15
@younghacker

Mounting an external drive is no different from mounting an internal drive.
Physically connect the drive.
See if it's connected:
It must be in the list
Then

# vgscan --mknodes
# vgchange -ay

Then mount readonly if you are afraid of overwriting data
If the disks had the same group names , then you need to either
boot from an external disk,
or rename the group by uuid
# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2

I don't know how to find out if LV belongs to PV, so I took
advantage of the difference in disk sizes.
# vgdisplay | grep -i 'name\|uuid'
  VG Name VolGroup00
  VG Size 148.94 GB
  PE Size 32.00 MB
  Total PE 4766
  Alloc PE / Size 4766 / 148.94 GB
  Free PE / Size 0 / 0
  VG UUID pkb1cy-1JSf-n3Px-UYRi-eImv-e1Eg-t12BgY
  VG Name VolGroup00
  VG Size 74.41 GB
  PE Size 32.00 MB
  Total PE 2381
  Alloc PE / Size 2381 / 74.41 GB
  Free PE / Size 0 / 0
  VG UUID SjBmkg-YvMz-B160-tEds-Vqrg-SFMS-mYNimL

And now rename the group by UUID
# pvscan
PV /dev/sda2 VG vg160 lvm2 [148.94 GB / 0 free] 
PV /dev/hda2 VG VolGroup00 lvm2 [74.41 GB / 0 free] 
Total: 2 [223.34 GB] / in use: 2 [223.34 GB] / in no VG: 0 [0 ]

# lvscan
inactive '/dev/vg160/LogVol00' [147.00 GB] inherit
inactive '/dev/vg160/LogVol01' [1.94 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [72.47 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit

# lvscan
ACTIVE '/dev/vg160/LogVol00' [147.00 GB] inherit
ACTIVE '/dev/vg160/LogVol01' [1.94 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol00' [72.47 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit

# mount -t ext3 -o ro /dev/vg160/LogVol00 /mnt/yourmountpoint

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question