[RndTbl] Getting disk sizes of mountpoints

Kevin McGregor kevin.a.mcgregor at gmail.com
Wed Feb 21 19:40:43 CST 2024


No worries. I’d just use whatever, but I’m trying to come up with something
I can use via Ansible across a couple of hundred machines. I need precise
numbers for work reasons. 🙂

On Wed, Feb 21, 2024 at 18:47 Vijay Sankar <vsankar at foretell.ca> wrote:

> Thanks for the explanation Kevin and sorry for the noise. I tend to use
> disklabel to see the size of each partition or physical disk info and df
> just to see how much is on each mount point as my needs are quite trivial.
> However, I am an OpenBSD user and don’t know as much about Linux etc.
>
> Sent from my iPhone
>
> On Feb 21, 2024, at 18:23, Kevin McGregor <kevin.a.mcgregor at gmail.com>
> wrote:
>
> 
>
> Fair question. On the same system, df -h gives:
> Filesystem            Size  Used Avail Use% Mounted on
> udev                  465M     0  465M   0% /dev
> tmpfs                  99M  7.8M   91M   8% /run
> /dev/mapper/vg0-root   15G  3.3G   12G  22% /
> tmpfs                 493M     0  493M   0% /dev/shm
> tmpfs                 5.0M     0  5.0M   0% /run/lock
> tmpfs                 493M     0  493M   0% /sys/fs/cgroup
> /dev/mapper/vg1-data   98G   61M   93G   1% /mnt/data
> /dev/mapper/vg0-var   5.0G  956M  4.1G  19% /var
> tmpfs                  99M     0   99M   0% /run/user/1000
>
> Where '/' and 'var' are correct, but /mnt/data shows as 98G instead of
> 100G. I'm looking for the disk sizes, not the file system sizes.
>
> This is actually a VM, and I can get the exact disk sizes from VMware...
> but not the mount points. And since / and /var are on the same disk, the
> VMware info lacks the detail I need.
>
> Major device 253 seems to be used for LVM devices, so assuming that misses
> things like "sda2                8:2    0    2G  0 part /boot", which I'd
> also like to account for. Another system, for example, has
> NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
> sda                   8:0    0   50G  0 disk
> ├─sda1                8:1    0    1M  0 part
> ├─sda2                8:2    0    2G  0 part /boot
> └─sda3                8:3    0   48G  0 part
>   ├─ubuntu--vg-root 253:0    0   24G  0 lvm  /
>   └─ubuntu--vg-var  253:1    0   24G  0 lvm  /var
> sr0                  11:0    1 1024M  0 rom
>
> And from that I would want
> /boot 2G
> / 24G
> /var 24G
> which adds up to 50G (sda)
>
> lsblk -e 7 | grep '/' | awk '{ print $NF, $4 }'
> basically works (for my sample of two systems), but I don't know how
> reliable assuming grep '/' is going to be for what I want.
>
>
> On Wed, Feb 21, 2024 at 4:44 PM Vijay Sankar <vsankar at foretell.ca> wrote:
>
>> Doesn’t df -h give that info? Sorry if I misunderstood your question.
>>
>> Sent from my iPhone
>>
>> On Feb 21, 2024, at 16:36, Kevin McGregor <kevin.a.mcgregor at gmail.com>
>> wrote:
>>
>> 
>> With 'lsblk' I can get something like this:
>> NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
>> sda            8:0    0   20G  0 disk
>> └─sda1         8:1    0   20G  0 part
>>   ├─vg0-root 253:0    0   15G  0 lvm  /
>>   └─vg0-var  253:1    0    5G  0 lvm  /var
>> sdb            8:16   0  100G  0 disk
>> └─sdb1         8:17   0  100G  0 part
>>   └─vg1-data 253:2    0  100G  0 lvm  /mnt/data
>> sr0           11:0    1 1024M  0 rom
>>
>> What I'm looking for is output like:
>> / 15G
>> /var 5G
>> /mnt/data 100G
>>
>> So I just want the size of the block devices which are actually mounted.
>> I'm wondering what is the most reliable way to produce the second output. I
>> can just grep for 'lvm', but I can't guarantee the mounts are all LVM type.
>> I can grep for ' 253:', but is the 253 going to be reliable? What does 253
>> even mean?
>>
>> From https://www.kernel.org/doc/html/latest/admin-guide/devices.html :
>>
>> 240-254 block  LOCAL/EXPERIMENTAL USE
>>                 Allocated for local/experimental use.  For devices not
>>                 assigned official numbers, these ranges should be
>>                 used in order to avoid conflicting with future assignments.
>>
>> ... which isn't encouraging. Is that list outdated? grep for '/'s?
>>
>> _______________________________________________
>> Roundtable mailing list
>> Roundtable at muug.ca
>> https://muug.ca/mailman/listinfo/roundtable
>>
>> _______________________________________________
>> Roundtable mailing list
>> Roundtable at muug.ca
>> https://muug.ca/mailman/listinfo/roundtable
>>
> _______________________________________________
> Roundtable mailing list
> Roundtable at muug.ca
> https://muug.ca/mailman/listinfo/roundtable
>
> _______________________________________________
> Roundtable mailing list
> Roundtable at muug.ca
> https://muug.ca/mailman/listinfo/roundtable
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://muug.ca/pipermail/roundtable/attachments/20240221/da29b82f/attachment-0001.htm>


More information about the Roundtable mailing list