menuimage

Description

Usage

Example

Options

Dependencies

License

Changelog

Download

Donation

My_Other_Sites

My_Programs

Comments

lvm-usage v4.51 [05 May 2024] by Dominic

Description

For GNU/Linux systems using LVM (Logical Volume Management), shows usage of:
- LVM Physical Volumes (PVs)
- LVM Volume Groups (VGs)
- LVM Logical Volumes (LVs)

And for all systems (using LVM or not) it shows usage of:
- Mounted filesystems
- Physical disk partitions

It also gives a localised example showing how space could be added using LVM. When run with '-q' option it will be silent unless any filesystem's level of usage is over the specified percent_trigger, and so it can be used to issue a warning if running out of space.

With '-f' option, it shows in a tree format the usage of the filesystem (if any) that is above percent_trigger level or, if none, then /home.

Suggested use is as a cron job with e.g. -q 75 (percent_trigger is ignored without -q switch.) Note that if run with '-f' option it can take many minutes to complete.

All sizes are reported in binary quantities e.g. gibibytes i.e. powers of 1024 not 1000.

Oh, and it runs happily on systems that do not have or use LVM, too.

Usage

lvm-usage.sh [options] [percent_trigger]

Example

sudo ./lvm-usage.sh -q 85

Options

-b show size and location of physical partitions in bytes
-f show full tree usage of the first volume with usage over percent_trigger (default /home)
-h shows these instructions and exit
-i use ascii characters for tree
-l show changelog and exit
-q suppress output unless usage is over percent_trigger (default 0%)

Dependencies

awk bash coreutils grep linux-utils parted sed optional:util-linux_(for_lsblk)

License

Copyright © 2024 Dominic Raferd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Changelog

4.51 [05 May 2024] - bugfix for sdnx_crypt devices
4.50 [03 May 2024] - bugfix for nvme devices, closer shellcheck compliance, stop using swapon -s which was, better lv name identification
4.42 [11 Sep 2023] - stop having lines in body that end in a colon (attempt to prevent breaking DKIM)
4.41 [19 Jan 2021] - limit line length (when listing directory contents) so if output is emailed it does not break DKIM
4.40 [18 May 2020] - alter -f so (a) it is based on the first-listed volume that was over percent_trigger, default /home, rather than only ever /home, and (b) it excludes directories on different file systems
4.34 [01 Aug 2018] - bugfix, with newer 'df' was always remounting /tmp
4.33 [16 Sep 2017] - ignore loop devices in listing of physical devices
4.32 [28 Oct 2016] - ignore /dev/loop devices
4.31 [11 Aug 2016] - add name and ip of machine to output
4.30 [18 Mar 2016] - remove all use of fdisk to make GPT-disk-compatible
4.26 [14 Dec 2015] - don't warn about 'full' iso9660 fs
4.25 [22 Sep 2015] - add -i option
4.24 [18 Aug 2015] - fix some PATH problems on some os (e.g. Centos 5), restore ability to work without lsblk (also missing on Centos 5)
4.23 [21 Jul 2015] - add swap info and include all filesystems
4.22 [20 Jul 2015] - output layout improvement
4.21 [04 May 2015] - corrected/simplified list of dependencies
4.20 [04 Apr 2015] - consistently use powers of 1024, lsblk instead of fdisk
4.14 [16 Mar 2015] - simplified/improved resizing example
4.13 [26 Feb 2015] - add example for resizing with btrfs
4.12 [21 Feb 2015] - minor layout improvement
4.11 [03 Feb 2015] - include tmpfs filesystems in report
4.10 [16 Jan 2015] - use mktemp, recreate/mount /tmp read-write if it is currently read-only
4.03 [05 Mar 2014] - remove extraneous sudo
4.02 [02 Mar 2014] - improved layout
4.0110 [10 Jan 2014] - minor fix
3.1117 [17 Nov 2013] - also exclude tmpfs & devtmpfs filesystems, add listing of physical partitions
3.0611 [11 June 2013] - also exclude shmfs filesystems
2.0807 [07 Aug 2012] - also exclude ecryptfs filesystems from output
2.0717 [17 Jul 2012] - minor correction for output wording
2.0513 [13 May 2012] - improved example text
2.0430 [30 Apr 2012] - when analysing /home, show files + directories over 1GB
2.0426 [26 Apr 2012] - improved example text
2.0417 [19 Apr 2012] - improved localised example for adding PV to VG
2.0412 [12 Apr 2012] - correctly remove temporary files in quiet mode
2.0219 [19 Feb 2012] - work smoothly if no LVM-mapped filesystems, bugfix, improved help, rename as 'lvm-usage.sh'
2.0216 [16 Feb 2012] - change -f fast option to -f full
2.0214 [14 Feb 2012] - exclude 'iso9660', include 'none' filesystems
2.0209 [09 Feb 2012] - provide localised examples in help text, add listing and checking of non-LVM filesystems
2.0125 [25 Jan 2012] - minor correction in help text
2.0117 [17 Jan 2012] - trivial elucidation in help text
2.0106 [06 Jan 2012] - fix for VG containing dash in name, add -f option
1.1231 [31 Dec 2011] - changed text

Download lvm-usage.sh

Donation

I have provided this software free gratis and for nothing. If you would like to thank me with a contribution, please let me know and I will send you a link. Thank you!

My Other Sites

My Programs

Here is a selection of some (other) programs I have written, most of which run under GNU/Linux from the command line (CLI), are freely available and can be obtained by clicking on the links. Dependencies are shown and while in most cases written and tested on an x86-based Linux server, they should run on a Raspberry Pi, and many can run under Windows using Windows Subsystem for Linux (WSL) or Cygwin. Email me if you have problems or questions, or if you think I could help with a programming requirement.

Backup Utilities

Debian/Ubuntu kernel and LVM Utilities

Miscellaneous Programs

Comments

This section is closed. If you have a question, please submit it by email, thank you.

No comments yet for '/programs/help/lvm-usage.sh.php'