3

hi i have a server which its first hdd was broken , the server has 2 HDD , the first hdd crashed . datacenter replaced it for me with a new hdd.

the second hdd use to have 2 pv on 2 partitions , and both PV where added to 1 vg , and 1 lv used allof the vg available space.

/dev/mapper/vg1-lv1 2.7T 255G 2.4T 10% /mnt/home2

/dev/sdb1 --> pv /dev/sdb2 --> another pv

both these PV where added to vg1 , vg1 had one 2.7 TB lv1 /dev/mapper/vg1-lv1 was mounted as ext4 on /home2


now the problem is that datacenter replaced the hdd , and i installed a new OS on the first hdd , but linux do not see second hdd PV or LV or VG .

i dont know if i do pvcreate /dev/sdb1 and pvcreate /dev/sdb2
so that they get a UUid , will the linux see the rest vg/lv ? or if i do pvcreate it will break the existing lvm on it ?

************************************************

Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xe88b6ea0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63  4294961684  2147480811   8e  Linux LVM
Partition 1 does not start on physical sector boundary.
/dev/sdb2      4294961685  5860528064   782783190   8e  Linux LVM
Partition 2 does not start on physical sector boundary.

***************************************************************************
8
  • What is the output of pvs, vgs and lvs commands? Commented Apr 2, 2014 at 1:13
  • [root@s1 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg0 lvm2 a-- 1024.00g 0 /dev/sda3 vg0 lvm2 a-- 1.73t 0
    – Farzin Sb
    Commented Apr 2, 2014 at 13:06
  • [root@s1 ~]# vgs VG #PV #LV #SN Attr VSize VFree vg0 2 4 0 wz--n- 2.73t 0
    – Farzin Sb
    Commented Apr 2, 2014 at 13:06
  • [root@s1 ~]# lvs LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert home vg0 -wi-ao---- 2.53t root vg0 -wi-ao---- 126.00g swap vg0 -wi-ao---- 64.00g tmp vg0 -wi-ao---- 9.00g
    – Farzin Sb
    Commented Apr 2, 2014 at 13:07
  • they do not find the second hdd ( sdb ) as a lvm PV at all :( but the partitions are there and are intact.
    – Farzin Sb
    Commented Apr 2, 2014 at 13:07

2 Answers 2

3

It seems I figured it out:

at first LVM VG was not seen at system at all, pvscan showed no signs of attached foreign VG and physical volumes, but it seems, that some systems, like Synology Diskstation, have filter defined in /etc/lvm/lvm.conf and after commenting it out pvscan finally discovered attached PVs:

lvm pvscan
  PV /dev/md2    VG vg1         lvm2 [7.27 TiB / 0    free]
  PV /dev/md4    VG vg1         lvm2 [14.55 TiB / 3.80 TiB free]
  PV /dev/sdq2   VG vg-bw   lvm2 [2.73 TiB / 0    free]
  PV /dev/sdq1   VG vg-bw   lvm2 [1.82 TiB / 429.41 GiB free]

and finally VG appeared to be seen also:

lvm vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "vg1" using metadata type lvm2
  Found volume group "vg-bw" using metadata type lvm2

but Volume Group and LVs are still not seen by system:

ls /dev/mapper/
vg1-volume_1               vg1-volume_2               
vg1-volume_3        

Trying to import foreign VG still no luck:

lvm vgimport vg-bw
  Volume group "vg-bw" is not exported

The trick is very easy, just activate the VG!

vgchange -ay vg-bw
  2 logical volume(s) in volume group "vg-bw" now active

Yay! Here it is:

vgs
  VG        #PV #LV #SN Attr   VSize  VFree  
  vg-bw       2   2   0 wz--n-  4.55t 429.41g
  vg1         2   6   0 wz--n- 21.82t   3.80t

also seen by system:

ls /dev/mapper/
vg1-volume_1    vg1-volume_2  
vg1-volume_3    vg--bw-backup

Hope it helps others to save some time.

0

It seems that creating the same exact PV and VG and LVM in a new centos without formating the lvm as ext4 , will regain access to the data :) but it is an unconfirmed and experimental solution , do not try this if you don't have backup of your data.

here is the full description and how I solved this problem (on StackOverflow)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .