Linux systems provide many ways to look at disk partitions. Here's a look at commands you can use to display useful information -- each providing a different format and with a different focus. Credit: Marco Verch Linux systems provide many ways to look at disk partitions. In this post, we’ll look at a series of commands, each which shows useful information but in a different format and with a different focus. Maybe one will make your favorites list. lsblk One of the most useful commands is the lsblk (list block devices) command that provides a very nicely formatted display of block devices and disk partitions. In the example below, we can see that the system has two disks (sda and sdb) and that sdb has both a very small (500M) partition and a large one (465.3G). Disks and partitions (part) are clearly labeled, and the relationship between the disks and partitions is quite obvious. We also see that the system has a cdrom (sr0). $ lsblk | grep -v loop NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 111.8G 0 disk └─sda1 8:1 0 111.8G 0 part / sdb 8:16 0 465.8G 0 disk ├─sdb1 8:17 0 500M 0 part └─sdb2 8:18 0 465.3G 0 part /apps sr0 11:0 1 1024M 0 rom [ Two-Minute Linux Tips: Learn how to master a host of Linux commands in these 2-minute video tutorials] A block device is a device that the system reads and writes one block of data at a time unlike, for example, character and serial devices. The command above is skipping over loop devices with the grep -v command. cat /proc/partitions Looking at the partitions file shows similar data, but not in as nearly a useful format. Partitions and disks sizes are reported in blocks. It does, however, show the major and minor device numbers. Note that we are again selecting lines (only those containing an “s”) to omit loop devices. $ cat /proc/partitions | grep s major minor #blocks name 8 0 117220824 sda 8 1 117219328 sda1 11 0 1048575 sr0 8 16 488386584 sdb 8 17 512000 sdb1 8 18 487872512 sdb2 df The df (disk usage) command can provide a succinct report on disk partitions, but only mounted partitions. It shows file system sizes along with measurements of how much of the disk space is used. In this example, we’re using -h (human-readable size measurements), -T (include partition type), and -t (select partitions of the specified type) options. $ df -hTt ext4 Filesystem Type Size Used Avail Use% Mounted on /dev/sda1 ext4 110G 9.0G 95G 9% / /dev/sdb2 ext4 457G 73M 434G 1% /apps mount Another command for listing file systems that are mounted along with their types and mount options is the mount command itself. This command shows us nothing about partition sizes, but the options are interesting. $ mount | grep ^/dev /dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered) /dev/sdb2 on /apps type ext4 (rw,relatime,data=ordered) In the above output, we see the partitions, mount points, file system type, and these options: rw — read/write relatime — access time (atime) will not be written to the disc during every access errors=remount-ro — file system will be remounted as read-only if errors are detected data=ordered — file data written to file system prior to metadata being committed to the journal The remount-ro choice is specified in the /etc/fstab file. The tune2fs command allows us to adjust other file system parameters. fdisk The fdisk command provides ways to manipulate disk partitions, but with the -l option, we are only displaying partition descriptions on ext2, ext3 and ext4 file systems. $ sudo fdisk -l /dev/sda1 Disk /dev/sda1: 111.8 GiB, 120032591872 bytes, 234438656 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes $ sudo sfdisk -l /dev/sda1 Disk /dev/sda1: 111.8 GiB, 120032591872 bytes, 234438656 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes parted Like sfdisk, the parted command allows us to manipulate partitions but offers a -l option for displaying partition descriptions. $ sudo parted -l Model: ATA SSD2SC120G1CS175 (scsi) Disk /dev/sda: 120GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 120GB 120GB primary ext4 boot Model: ATA SAMSUNG HE502HJ (scsi) Disk /dev/sdb: 500GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 525MB 524MB primary ntfs boot 2 525MB 500GB 500GB primary ext4 blkid The blkid command displays block device attributes. It shows the 128-bit UUID and file system type, but it is not likely to be the most illuminating command for providing partition stats. $ sudo blkid /dev/sda1: UUID="235f8f0c-641a-4d83-b584-7280cfcd3faa" TYPE="ext4" PARTUUID="f63b5929-01" /dev/sdb1: LABEL="System Reserved" UUID="08F0AF99F0AF8C0E" TYPE="ntfs" PARTUUID="7e67ccf3-01" /dev/sdb2: UUID="94a29e41-b282-4ca2-aacb-fbd91507dc27" TYPE="ext4" PARTUUID="7e67ccf3-02" hwinfo The hwinfo command probes system hardware and provides a nicely organized display of disks, partitions and, if available, other block devices. This short report displays only a fraction of the information the command will report. The –block and the –short options specify that we only want the command to provide summaries on block devices. $ hwinfo --block --short disk: /dev/sdb SAMSUNG HE502HJ /dev/sda SSD2SC120G1CS175 partition: /dev/sdb1 Partition /dev/sdb2 Partition /dev/sda1 Partition cdrom: /dev/sr0 HL-DT-ST DVD+-RW GSA-H73N file Even the file command can shed some light on partitions. In the example below, we see the partitions, file system types, and the 128 bit UUID numbers. $ sudo file -s /dev/sda1 /dev/sda1: Linux rev 1.0 ext4 filesystem data, UUID=235f8f0c-641a-4d83-b584-7280cfcd3faa (needs journal recovery) (extents) (64bit) (large files) (huge files) $ sudo file -s /dev/sdb2 /dev/sdb2: Linux rev 1.0 ext4 filesystem data, UUID=94a29e41-b282-4ca2-aacb-fbd91507dc27 (extents) (64bit) (large files) (huge files) Wrap-up Linux systems provide many ways to examine partition information. Which is best depends on what you’re looking for. Some commands look only at mounted file systems, while others provide copious details on the hardware. Related content how-to Compressing files using the zip command on Linux The zip command lets you compress files to preserve them or back them up, and you can require a password to extract the contents of a zip file. By Sandra Henry-Stocker May 13, 2024 4 mins Linux opinion NSA, FBI warn of email spoofing threat Email spoofing is acknowledged by experts as a very credible threat. By Sandra Henry-Stocker May 13, 2024 3 mins Linux how-to The logic of && and || on Linux These AND and OR equivalents can be used in scripts to determine next actions. By Sandra Henry-Stocker May 02, 2024 4 mins Linux how-to Using the apropos command on Linux By Sandra Henry-Stocker Apr 24, 2024 3 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe