You are not logged in.

#1 2014-01-12 17:26:02

javex
Member
Registered: 2011-12-30
Posts: 77

LVM: On which hard drive is a file?

I have an LVM system that combines multiple drives into one large partition. I have always wondered if it is possible to determine on which drive a file was placed, however, I cannot find anything regarding this question online. So I will provide my thoughts here and hope someone will be able to fill the gaps to be able to go from "/path/to/file" to "/dev/sdbXX".

Note: Of course this will only work if the volume is linear, because with striped mode each file will likely be on all partitions.

My setup consists of 4 drives, each encrypted with LUKS and then added to a volume group which in turn uses all available space to form one large ext3 partition. So in summary:

/dev/sd{a,b,c,d}1 --> /dev/mapper/luksdrive{1,2,3,4} --> myVolGroup --> /dev/mapper/lvol-data --> ext3

Without all the intermediate software, I get that I could just use Find File that Owns a Given Block to find which file is on which block. So from there I would only need to know which block in my logical volume corresponds to which drive in the volume group (and thus corresponds to which physical volume).

When I have the drive, I can pass through encryption transparently (it maps 1:1). So from my perspective, I guess, the real question is: Which ext3 block belongs to which physical volume? Is there anyone with enough LVM expertise to help me out on that?

I realize, that some files may be on two drives (since one drive might be full and the fill be split, LVM only sees blocks anyway), but that would still be more than I know right now (which is nothing...).

Finally, I would also be ready to write some C code for it, but it does not seem that LVM has an extensive API (only lvm2cmd and lvm2app, which are very limited).

Offline

Board footer

Powered by FluxBB