0

How can I determine used space of a block device that has no filesystem on it? If it helps, such device is managed via lvm.

I understand that the concept of "used space" on a device without filesystem isn't a term, but what I mean by "used space of a block device with no filesystem" is "number of blocks that differ from what was initially allocated when that block device was created".

How can I calculate it? Maybe there is some daemon that supports this? Or is my concept of used space of a block device with no filesystem ill-formed and OS / hard-drives / SSD's may write some weird data to the block-device if there is no filesystem which would impact the measurement?

4
  • 4
    "blocks that differ from what was initially allocated" ... still doesn't seem like a useful metric. In most situations these days, data isn't actually deleted, just whatever metadata marks the presence of data. So the block might technically differ from what was originally allocated, and still be part of "free space" if this was about an actual filesystem. Commented Apr 6 at 18:41
  • 1
    Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Commented Apr 6 at 18:42
  • "is my concept of used space of a block device with no filesystem is ill-formed" ... put another way, what is preventing the use of any space in said block device? Commented Apr 6 at 18:43
  • 4
    You're suffering from a mismatch of concepts. If a block device is considered, without a filesystem (or the wrong filesystem), it's all "free space", just clusters of blocks. Creating a filesystem atop a block device writes distributed metadata across the disk, but does NOT initialize the rest of the blocks. See, for example man mke2fs. Commented Apr 6 at 18:54

1 Answer 1

1

You need a thin provisioning block device for this:

  • thin LVM
  • ZFS
  • Ceph (RADOS)

You have to copy the existing block device content to the thin one in a way which avoids writing zeros: e.g. with dd bs=64K conv=sparse ... (assuming the chunk size is 64K)

Then you see how much has been written with

  • lvs
  • zfs get volsize
  • rbd du --pool ...

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.