Hi Jeremy,

Some time ago I worked with Citrix in creating a article to mount and recover
LVMoHBA.

How to Mount Linux LVM Partition in a XenServer Host

http://support.citrix.com/article/CTX117791

The above CTX article only applies to raw LVM LV. In our case the VDIs are LVs
with VHD headers in it. We'll have to use blktap to create tapdisks to open
the VHD LV before we can create device maps for the partitions / LVs within
the VDI.

Up to activating the VG, the article still applies. After activating the
VG/LVs, we'll need to manually create tapdisk to open the VHD LV before using
kpartx to create maps from partition tables.

NOTE: I've included output from my test environment for your reference

1. Create tapdisk

# tap-ctl allocate /dev/xen/blktap-2/tapdev0

2. Spawn a new process

# tap-ctl spawn

tapdisk spawned with pid 30383

# tap-ctl list
30383 - - - -
- 0 - - -

4. Attach the tapdisk to the process

tap-ctl attach -p PID -m minor

# tap-ctl attach -p 30383 -m 0
# tap-ctl list
30383 0 0 - -


5. Open the VHD LV

Note you may need to activate the LVM first with lvchange -ay

# tap-ctl open -p 30383 -m 0 -a
vhd:/dev/VG_XenStorage-b1415cf5-07e2-14fa-cbf8-6490751da242/VHD-182ce043-bf98-45d9-926b-595bbd82ed8a

6. Verify

# tap-ctl list 
30383 0 0 vhd
/dev/VG_XenStorage-b1415cf5-07e2-14fa-cbf8-6490751da242/VHD-182ce043-bf98-45d9-926b-595bbd82ed8a

7. Create device maps from partition tables using kpartx

kpartx -av /dev/xen/blktap-2/tapdev0

# kpartx -av /dev/xen/blktap-2/tapdev0
add map tapdev0p1 (252:5): 0 1024000 linear /dev/xen/blktap-2/tapdev0 2048
add map tapdev0p2 (252:6): 0 32872448 linear /dev/xen/blktap-2/tapdev0 1026048

NOTE: in this case, it is a CentOS 7 VDI, contains a /boot partition and VG -
linux and 2 LVs (root, home).

Device maps were created in
/dev/mapper/tapdev0pN

8. Mount 1st partition

# mount /dev/mapper/tapdev0p1 /mnt/boot

9. Activate VG

# vgchange -a y
2 logical volume(s) in volume group "linux" now active

# lvscan
ACTIVE '/dev/linux/root' [13.67 GB] inherit
ACTIVE '/dev/linux/home' [2.00 GB] inherit


10. Mount root and home LVs

mount -t xfs /dev/linux/root /mnt/root

NOTE: XenServer 6.2 kernel does NOT support XFS

mount -t ext4 /dev/linux/home /mnt/home

11. After backing up data, reverse the procedure to release resources

List partition mappings

# kpartx -lv /dev/xen/blktap-2/tapdev0
tapdev0p1 : 0 1024000 /dev/xen/blktap-2/tapdev0 2048
tapdev0p2 : 0 32872448 /dev/xen/blktap-2/tapdev0 1026048

De-active the VG (all LVs)

# vgchange -an linux
0 logical volume(s) in volume group "linux" now active

Delete partition mappings

# kpartx -dv /dev/xen/blktap-2/tapdev0
del devmap : tapdev0p2
del devmap : tapdev0p1

12. Release the blktap resources

# tap-ctl list
30383 0 0 vhd
/dev/VG_XenStorage-b1415cf5-07e2-14fa-cbf8-6490751da242/VHD-182ce043-bf98-45d9-926b-595bbd82ed8a

# tap-ctl close -p 30383 -m 0
[root@xenserver-zilblqhl /]# tap-ctl list
30383 0 0x2 - -

# tap-ctl destroy -p 30383 -m 0
[root@xenserver-zilblqhl /]# tap-ctl list

Regards,
Adrian Sender



---------- Original Message -----------
From: Jeremy Peterson <[email protected]>
To: "[email protected]" <[email protected]>
Sent: Sun, 24 Sep 2017 22:38:29 +0000
Subject: Corrupted HDD

> So I need to know if anyone can drop a hint on this.
> 
> How can i recover data from cloudstack with xenserver.  One of the 
> storage LUN's got 100% full.  I was carefully deleting un-associated 
> disks from the LUN.  A disk that had no VM attached.  Then when one 
> of the VM's rebooted it came online with no bootable disk found.
> 
> Now I'm thinking this over that one of those disks were the a master 
> UUID and thats why my VM's wont boot.  Can that been fixed?
> 
> I look in primary storage and can find the UUID of a disk matches a 
> volume in /dev/mapper/VG.....
> 
> Can I pull that disk down and create a VHD to deploy a template and 
> deploy a new vm from that vhd file?
> 
> Can I dd that disk to export to anything to try and recover data?  
> Office files or PDF's are critical.
> 
> Does anyone know if there are any good consulting companies with 
> Citrix or if Citrix can help with this?
> 
> Jeremy
------- End of Original Message -------

Reply via email to