System and processes
The lsblk command
Lists disks and partitions as a tree, with sizes and mount points.
Most useful options
-a, --allAlso includes empty devices and RAM disks, which are hidden by default-b, --bytesShows sizes in exact bytes instead of readable units such as G or M-d, --nodepsDoes not show dependent devices such as partitions: only the disk you name-f, --fsAdds the filesystem type, UUID, label and free space-o, --output <columnas>Chooses the columns to show, separated by commas. It is the stable way to use it in scripts-p, --pathsShows the full path of each device, such as /dev/sda1-J, --jsonJSON output, useful to process it with jq or another programCopy-ready examples
$ lsblkdisks and partitions as a tree, with their size and where they are mounted.$ lsblk -fthe same, with the filesystem type and the UUID of each partition.$ lsblk -o NAME,SIZE,TYPE,MOUNTPOINTSonly the columns you need, always in the same order.$ lsblk -d -o NAME,SIZE,TYPE /dev/sdaa single disk, without its partitions, to check its size before touching anything.$ lsblk -J -p -o NAME,SIZE,TYPEJSON output with full paths, ready for a script to process it.You can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- The default output can change between util-linux versions: in a script, fix the columns with -o.
- With -f, the UUID and label come from the information lsblk reads from the system; the manual points to blkid as the authoritative source.
- Some filesystem data requires root when there is no udev database: if a column comes out empty, try with sudo.
Differences from similar commands
- df: measures used and free space in mounted folders. lsblk shows the structure of disks and partitions.
- blkid: queries the identification of one specific device. lsblk -f puts it together with the disk tree.
- fdisk: lists and edits the partition table. lsblk only reads it and shows it as a tree.
- findmnt: shows mount points sorted by path. lsblk shows which device sits behind each one.
FAQ
What is the difference between sda and sda1?
sda is the whole disk; sda1 is its first partition. lsblk shows them nested: partitions hang under the disk that contains them.
Why do devices show up that I do not have connected?
lsblk reads what the kernel has registered in sysfs. A device can show up even when it is empty, and -a also shows the ones lsblk hides by default.
Do I need sudo to use lsblk?
Usually not. If a label or UUID column comes out empty, the manual says that data needs root when there is no udev database; try sudo lsblk -f.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course