<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Segoe UI Emoji";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        mso-ligatures:none;
        mso-fareast-language:EN-CA;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-CA" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">If you’re using awk anyway:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">    lsblk -b -r | awk 'NR>1 && $7 {print $1,$4}'
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">appears to do the trick. 
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Unfortunately, it doesn’t do the VG/LV to dm-X translation for you, and using -l instead of -r doesn’t really work either b/c of the rather silly column formatting lsblk does – there’s a SPACE in
 the middle of the first column, gee, thanks.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">The lsblk(8) manpage notes that it pulls all of its information from sysfs, so I imagine you could fairly easily do exactly the same, targeting only the info you really want.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Finally, note that in your example, 98G is correct as the “disk” size – to get that result from df, you *<b>must</b>* have an LV that’s 98G, and the LV is the “disk” as far as the filesystem is concerned. 
 There are many reasons this can happen, but I guarantee you can’t actually put 100G of user data on that filesystem.  I do this deliberately, but alignment issues or metadata can sometimes chew up a bit of space, too.  Cross-check against the output of lvscan(8)
 and if that reports 100G, let us know – and also file a bug with the vendor!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">If you use df, I would suggest an invocation such as
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">    df -lm | awk '/^\/dev/ && $2>1  {print $6,$1,$2}'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">depending on which bits of info you want.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">-Adam<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Roundtable <roundtable-bounces@muug.ca>
<b>On Behalf Of </b>Kevin McGregor<br>
<b>Sent:</b> Wednesday, February 21, 2024 7:41 PM<br>
<b>To:</b> Continuation of Round Table discussion <roundtable@muug.ca><br>
<b>Subject:</b> Re: [RndTbl] Getting disk sizes of mountpoints<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">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.
<span style="font-family:"Segoe UI Emoji",sans-serif">🙂</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, Feb 21, 2024 at 18:47 Vijay Sankar <<a href="mailto:vsankar@foretell.ca">vsankar@foretell.ca</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal">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. <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Sent from my iPhone<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt">On Feb 21, 2024, at 18:23, Kevin McGregor <<a href="mailto:kevin.a.mcgregor@gmail.com" target="_blank">kevin.a.mcgregor@gmail.com</a>> wrote:<o:p></o:p></p>
</blockquote>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><o:p></o:p></p>
</div>
</blockquote>
</div>
</div>
<div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal">Fair question. On the same system, df -h gives:<o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black">Filesystem            Size  Used Avail Use% Mounted on<br>
udev                  465M     0  465M   0% /dev<br>
tmpfs                  99M  7.8M   91M   8% /run<br>
/dev/mapper/vg0-root   15G  3.3G   12G  22% /<br>
tmpfs                 493M     0  493M   0% /dev/shm<br>
tmpfs                 5.0M     0  5.0M   0% /run/lock<br>
tmpfs                 493M     0  493M   0% /sys/fs/cgroup<br>
/dev/mapper/vg1-data   98G   61M   93G   1% /mnt/data<br>
/dev/mapper/vg0-var   5.0G  956M  4.1G  19% /var<br>
tmpfs                  99M     0   99M   0% /run/user/1000</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black">NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS<br>
sda                   8:0    0   50G  0 disk<br>
├─sda1                8:1    0    1M  0 part<br>
├─sda2                8:2    0    2G  0 part /boot<br>
└─sda3                8:3    0   48G  0 part<br>
  ├─ubuntu--vg-root 253:0    0   24G  0 lvm  /<br>
  └─ubuntu--vg-var  253:1    0   24G  0 lvm  /var<br>
sr0                  11:0    1 1024M  0 rom</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">And from that I would want<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black">/boot 2G</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black">/ 24G</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black">/var 24G</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">which adds up to 50G (sda)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black">lsblk -e 7 | grep '/' | awk '{ print $NF, $4 }'</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, Feb 21, 2024 at 4:44 PM Vijay Sankar <<a href="mailto:vsankar@foretell.ca" target="_blank">vsankar@foretell.ca</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal">Doesn’t df -h give that info? Sorry if I misunderstood your question. <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Sent from my iPhone<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt">On Feb 21, 2024, at 16:36, Kevin McGregor <<a href="mailto:kevin.a.mcgregor@gmail.com" target="_blank">kevin.a.mcgregor@gmail.com</a>> wrote:<o:p></o:p></p>
</blockquote>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><o:p></o:p></p>
<div>
<p class="MsoNormal">With 'lsblk' I can get something like this:<o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New";color:black">NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT<br>
sda            8:0    0   20G  0 disk<br>
└─sda1         8:1    0   20G  0 part<br>
  ├─vg0-root 253:0    0   15G  0 lvm  /<br>
  └─vg0-var  253:1    0    5G  0 lvm  /var<br>
sdb            8:16   0  100G  0 disk<br>
└─sdb1         8:17   0  100G  0 part<br>
  └─vg1-data 253:2    0  100G  0 lvm  /mnt/data<br>
sr0           11:0    1 1024M  0 rom</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">What I'm looking for is output like:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">/ 15G<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">/var 5G<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">/mnt/data 100G<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">From <a href="https://www.kernel.org/doc/html/latest/admin-guide/devices.html" target="_blank">https://www.kernel.org/doc/html/latest/admin-guide/devices.html</a> :<o:p></o:p></p>
</div>
<div>
<pre style="mso-margin-top-alt:11.25pt;margin-right:0in;margin-bottom:11.25pt;margin-left:0in;line-height:15.6pt;background:#EEEEEE;overflow:hidden"><span style="font-family:Consolas;color:#3E4349">240-254 block  LOCAL/EXPERIMENTAL USE<o:p></o:p></span></pre>
<pre style="mso-margin-top-alt:11.25pt;margin-right:0in;margin-bottom:11.25pt;margin-left:0in;line-height:15.6pt;background:#EEEEEE"><span style="font-family:Consolas;color:#3E4349">                Allocated for local/experimental use.  For devices not<o:p></o:p></span></pre>
<pre style="mso-margin-top-alt:11.25pt;margin-right:0in;margin-bottom:11.25pt;margin-left:0in;line-height:15.6pt;background:#EEEEEE"><span style="font-family:Consolas;color:#3E4349">                assigned official numbers, these ranges should be<o:p></o:p></span></pre>
<pre style="mso-margin-top-alt:11.25pt;margin-right:0in;margin-bottom:11.25pt;margin-left:0in;line-height:15.6pt;background:#EEEEEE"><span style="font-family:Consolas;color:#3E4349">                used in order to avoid conflicting with future assignments.<o:p></o:p></span></pre>
</div>
<div>
<p class="MsoNormal">... which isn't encouraging. Is that list outdated? grep for '/'s?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.ca" target="_blank">Roundtable@muug.ca</a><br>
<a href="https://muug.ca/mailman/listinfo/roundtable" target="_blank">https://muug.ca/mailman/listinfo/roundtable</a><o:p></o:p></p>
</div>
</blockquote>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.ca" target="_blank">Roundtable@muug.ca</a><br>
<a href="https://muug.ca/mailman/listinfo/roundtable" target="_blank">https://muug.ca/mailman/listinfo/roundtable</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal">_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.ca" target="_blank">Roundtable@muug.ca</a><br>
<a href="https://muug.ca/mailman/listinfo/roundtable" target="_blank">https://muug.ca/mailman/listinfo/roundtable</a><o:p></o:p></p>
</div>
</blockquote>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.ca" target="_blank">Roundtable@muug.ca</a><br>
<a href="https://muug.ca/mailman/listinfo/roundtable" target="_blank">https://muug.ca/mailman/listinfo/roundtable</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>