1

I have a VG called ubuntu with a single LV called titan that is made out of 4 PV (sd[a,b,c,d).

I want to know how much space is used/free on each PV inside that LV. Commands like pvdisplay, vgdisplay and lvdisplay only show other type of information like how much was used to create a lv. I need to know how much is used by files inside each PV and how much is free.

3
  • 1
    I've posted an answer... but if this isn't something you're doing because you're just curious about it, it sounds like you need to explain the higher-level problem you're trying to solve, as I'm pretty sure there is a better way. – derobert Oct 20 '14 at 19:27
  • Thanks derobert. I wanted to make sure that this was not possible because of how LVM works. The idea was to for example get an output that would say that Pv1 was used 25% and had 75%, pv2 had % used, % free... up to PvN. – Luis Alvarado Oct 20 '14 at 20:18
  • You can get %used/free, but only on an "is it allocated to an LV?" basis. But it sounds like you already know how to do that (with pvs). – derobert Oct 20 '14 at 20:29
2

That's not really possible; LVM doesn't know anything about files.

LVM creates logical volumes, which are block devices. They function much like other any other block device, such as a hard disk, and thus they they don't know or care what the data stored on them means. To LVM, its just a series of 0s and 1s, organized in x-byte blocks.

You've stored a filesystem on that block device (the logical volume). The filesystem knows about files, but it doesn't export that knowledge down to the block device.

Just as you couldn't ask your hard disk which platters contain files, you can't ask LVM which PVs contain files.

[You could, of course, go through each file in the file system, ask the filesystem which blocks its stored on, then ask LVM where each of those blocks are, and put that all together, but I'm not aware of any tool to do that. Nor am I sure why you'd want to do that.]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.