A filesystem is the methods and data structures that an operating system uses to keep track of files on a disk or partition; that is, the way the files are organized on the disk. Linux operating system supports several types of filesystems. There are many tools available to find the list of currently available filesystems in Linux. The most commonly used commandline tool is df
. In this guide, we will see how to list filesystems in Linux using Lfs.
What is Lfs?
Lfs is a commandline tool to display the information of the mounted disks in your Linux system. The developer of Lfs claims it is slightly a better alternative to df -H
command.
Most information given by lfs
is already provided by df
. However, lfs has a few improvements as listed below:
- lfs helps you recognize your disks by labelling them "rem" (removable), "HDD", "SSD".
- lfs only uses SI units. You don't have to open the help and check the right argument for the correct size units.
- lfs displays the type of filesystem.
- lfs sorts filesystems by size.
- Unlike the df command, lfs displays the output in a tabular column format. Df displays the output in listing format.
Lfs is an open source program written in Rust. The code is freely available in GitHub under MIT license.
Install Lfs in Linux
Currently, Lfs can be installed in two ways.
- Using Cargo package manager.
- Using precombiled binary,
1. Install lfs using Cargo
First install Rust on your Linux box as described in the following link:
If Rust is already installed, you need to update it to its latest version with the following command:
$ rustup update
Then install lfs using cargo
package manager:
$ cargo install lfs
2. Install Lfs using precompiled binaryies
If you prefer to use precompiled binary, download it from the releases page.
$ wget https://github.com/Canop/lfs/releases/download/v0.5.1/lfs_0.5.1.zip
Extract it and move the executable file to your $PATH
, for example /usr/local/bin/
.
$ sudo mv lfs_0.5.1/build/lfs /usr/local/bin/
Please note that the precompiled version is not the most recent version. So you might miss some functionalities.
List Filesystems In Linux Using Lfs
Run lfs command without any options to list filesystems in your Linux system:
$ lfs
Sample output:
┌──┬───┬──────────┬───┬────┬────┬────┬────┬─────┬───────────┐ │id│dev│filesystem│dsk│type│size│used│use%│avail│mount point│ ├──┼───┼──────────┼───┼────┼────┼────┼────┼─────┼───────────┤ │31│8:1│/dev/sda1 │HDD│ext4│491G│468G│ 95%│ 23G│/ │ └──┴───┴──────────┴───┴────┴────┴────┴────┴─────┴───────────┘
By default, lfs
only lists the filesystems backed by block devices looking like real disks. To show all filesystems, -a
flag.
$ lfs -a
Sample output:
┌────┬────┬───────────┬───┬───────────────┬────┬────┬────┬─────┬───────────────────────────────┐ │ id│dev │filesystem │dsk│ type │size│used│use%│avail│mount point │ ├────┼────┼───────────┼───┼───────────────┼────┼────┼────┼─────┼───────────────────────────────┤ │ 31│8:1 │/dev/sda1 │HDD│ ext4 │491G│468G│ 95%│ 23G│/ │ │ 33│0:27│tmpfs │ │ tmpfs │4.1G│366M│ 9%│ 3.8G│/dev/shm │ │ 35│0:29│tmpfs │ │ tmpfs │4.1G│ 0│ 0%│ 4.1G│/sys/fs/cgroup │ │ 26│0:6 │udev │ │ devtmpfs │4.1G│ 0│ 0%│ 4.1G│/dev │ │ 28│0:24│tmpfs │ │ tmpfs │825M│1.9M│ 0%│ 823M│/run │ │1315│0:24│tmpfs │ │ tmpfs │825M│1.9M│ 0%│ 823M│/run/snapd/ns │ │1546│0:54│tmpfs │ │ tmpfs │825M│ 53K│ 0%│ 825M│/run/user/1000 │ │ 161│7:4 │/dev/loop4 │HDD│ squashfs │268M│268M│100%│ 0│/snap/gnome-3-34-1804/36 │ │ 143│7:8 │/dev/loop8 │HDD│ squashfs │252M│252M│100%│ 0│/snap/chromium/1328 │ │ 167│7:13│/dev/loop13│HDD│ squashfs │231M│231M│100%│ 0│/snap/multipass/2604 │ │ 176│7:17│/dev/loop17│HDD│ squashfs │231M│231M│100%│ 0│/snap/multipass/2531 │ │ 131│7:1 │/dev/loop1 │HDD│ squashfs │229M│229M│100%│ 0│/snap/gnome-3-34-1804/60 │ │ 146│7:5 │/dev/loop5 │HDD│ squashfs │171M│171M│100%│ 0│/snap/gnome-3-28-1804/145 │ │ 137│7:10│/dev/loop10│HDD│ squashfs │171M│171M│100%│ 0│/snap/chromium/1350 │ │ 164│7:12│/dev/loop12│HDD│ squashfs │169M│169M│100%│ 0│/snap/gnome-3-28-1804/128 │ │ 125│7:6 │/dev/loop6 │HDD│ squashfs │148M│148M│100%│ 0│/snap/gnome-3-26-1604/98 │ │ 128│7:2 │/dev/loop2 │HDD│ squashfs │148M│148M│100%│ 0│/snap/gnome-3-26-1604/100 │ │ 140│7:7 │/dev/loop7 │HDD│ squashfs │102M│102M│100%│ 0│/snap/core/10126 │ │ 173│7:9 │/dev/loop9 │HDD│ squashfs │102M│102M│100%│ 0│/snap/core/9993 │ │ 158│7:11│/dev/loop11│HDD│ squashfs │ 65M│ 65M│100%│ 0│/snap/gtk-common-themes/1506 │ │ 155│7:3 │/dev/loop3 │HDD│ squashfs │ 58M│ 58M│100%│ 0│/snap/core18/1885 │ │ 170│7:15│/dev/loop15│HDD│ squashfs │ 58M│ 58M│100%│ 0│/snap/core18/1880 │ │ 152│7:14│/dev/loop14│HDD│ squashfs │ 58M│ 58M│100%│ 0│/snap/gtk-common-themes/1502 │ │ 34│0:28│tmpfs │ │ tmpfs │5.2M│4096│ 0%│ 5.2M│/run/lock │ │ 134│7:0 │/dev/loop0 │HDD│ squashfs │2.4M│2.4M│100%│ 0│/snap/gnome-system-monitor/145 │ │ 149│7:16│/dev/loop16│HDD│ squashfs │2.4M│2.4M│100%│ 0│/snap/gnome-system-monitor/148 │ │ 24│0:22│sysfs │ │ sysfs │ │ │ │ │/sys │ │ 25│0:5 │proc │ │ proc │ │ │ │ │/proc │ │ 27│0:23│devpts │ │ devpts │ │ │ │ │/dev/pts │ │ 32│0:7 │securityfs │ │ securityfs │ │ │ │ │/sys/kernel/security │ │ 36│0:30│cgroup2 │ │ cgroup2 │ │ │ │ │/sys/fs/cgroup/unified │ │ 37│0:31│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/systemd │ │ 38│0:32│pstore │ │ pstore │ │ │ │ │/sys/fs/pstore │ │ 39│0:33│none │ │ bpf │ │ │ │ │/sys/fs/bpf │ │ 40│0:34│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/perf_event │ │ 41│0:35│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/rdma │ │ 42│0:36│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/net_cls,net_prio│ │ 43│0:37│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/memory │ │ 44│0:38│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/cpu,cpuacct │ │ 45│0:39│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/devices │ │ 46│0:40│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/cpuset │ │ 47│0:41│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/freezer │ │ 48│0:42│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/hugetlb │ │ 49│0:43│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/pids │ │ 50│0:44│cgroup │ │ cgroup │ │ │ │ │/sys/fs/cgroup/blkio │ │ 51│0:45│systemd-1 │ │ autofs │ │ │ │ │/proc/sys/fs/binfmt_misc │ │ 52│0:20│mqueue │ │ mqueue │ │ │ │ │/dev/mqueue │ │ 53│0:46│hugetlbfs │ │ hugetlbfs │ │ │ │ │/dev/hugepages │ │ 54│0:12│tracefs │ │ tracefs │ │ │ │ │/sys/kernel/tracing │ │ 55│0:8 │debugfs │ │ debugfs │ │ │ │ │/sys/kernel/debug │ │ 119│0:47│fusectl │ │ fusectl │ │ │ │ │/sys/fs/fuse/connections │ │ 122│0:21│configfs │ │ configfs │ │ │ │ │/sys/kernel/config │ │ 840│0:4 │nsfs │ │ nsfs │ │ │ │ │/run/snapd/ns/multipass.mnt │ │1574│0:55│gvfsd-fuse │ │fuse.gvfsd-fuse│ │ │ │ │/run/user/1000/gvfs │ │1202│0:69│binfmt_misc│ │ binfmt_misc │ │ │ │ │/proc/sys/fs/binfmt_misc │ └────┴────┴───────────┴───┴───────────────┴────┴────┴────┴─────┴───────────────────────────────┘
You can also get the filesystem details in JSON
format with -j
flag.
$ lfs -j
Sample output:
[ { "dev": { "major": 8, "minor": 1 }, "disk": { "removable": false, "rotational": true, "type": "HDD" }, "fs": "/dev/sda1", "fs-type": "ext4", "id": 31, "mount-point": "/", "stats": { "available": "23G", "bavail": 5652047, "bfree": 11760949, "blocks": 119917226, "bsize": 4096, "size": "491G", "used": "468G", "used-percent": "95%" } } ]
To display the details of all filesystems in JSON format, do:
$ lfs -a -j
For help, run:
$ lfs --help Usage: lfs [-v] [-a] [-j] List your filesystems. All units are SI. Source at https://github.com/Canop/lfs Options: -v, --version print the version -a, --all whether to show all mount points -j, --json output as JSON --help display usage information
Lfs is a small and simple utility to display your filesystem disk space usage. It does the job well as advertised. Give it a try and let us know your thoughts on this utility in the comment section below.
Resource:
Related read:
- How To Find The Mounted Filesystem Type In Linux
- Some Good Alternatives To ‘du’ Command
- How To View Disk Usage With Duf On Linux And Unix
- Filelight – Visualize Disk Usage On Your Linux System
- How To Check Disk Space Usage In Linux Using Ncdu
- Agedu – Find Out Wasted Disk Space In Linux
- Duc – A Collection Of Tools To Inspect And Visualize Disk Usage
2 comments
“Lfs is a small …”
Small?
Have you seen how much disk space it takes up compared to the standard GNU “ls” program?
Lfs and ls are different commands. Why are you comparing lfs with ls? Btw, to answer your questions, lsf is just 241 KB. So, I used the right term IMO.