- How To – Linux List Disk Partitions Command
- lsblk Command to list block device on Linux
- Understanding lsblk option that displays block devices and partitions
- How to locate/print block device attributes using blkid
- List partitions ynder Linux using the fdisk command
- Display disk partitions using sfdisk command in Linux
- Listing Linux a Partition Size Larger Than 2TB
- How Do I List All Partitions Layout On All Block Devices?
- lssci command to list SCSI devices (or hosts) and their attributes
- A note about GUI tools
- Using hardware detction tools to print disk paritions on Linux
- Conclusion
How To – Linux List Disk Partitions Command
WARNING ! These examples may crash your computer if NOT executed with proper care. BE EXTREMELY CAREFUL WITH THE FOLLOWING COMMANDS. ONE TYPING MISTAKE AND ALL YOUR DATA IS LOST.
lsblk Command to list block device on Linux
Listing disks and partitions on Linux using lsblk
Understanding lsblk option that displays block devices and partitions
- -m : Show info about Linux permissions
- -f : List info about Linux filesystems
- -l : Force list format output option
- -d : Avoid printing holders. In other words just see block device/disk names
- -o NAME,FSTYPE,SIZE,MOUNTPOINT : Only display selected columns as per Table 1.
Column | Descripton |
---|---|
NAME | device name |
KNAME | internal kernel device name |
PATH | path to the device node |
MAJ:MIN | major:minor device number |
FSAVAIL | filesystem size available |
FSSIZE | filesystem size |
FSTYPE | filesystem type |
FSUSED | filesystem size used |
FSUSE% | filesystem use percentage |
MOUNTPOINT | where the device is mounted |
LABEL | filesystem LABEL |
UUID | filesystem UUID |
PTUUID | partition table identifier (usually UUID) |
PTTYPE | partition table type |
PARTTYPE | partition type UUID |
PARTLABEL | partition LABEL |
PARTUUID | partition UUID |
PARTFLAGS | partition flags |
RA | read-ahead of the device |
RO | read-only device |
RM | removable device |
HOTPLUG | removable or hotplug device (usb, pcmcia, …) |
MODEL | device identifier |
SERIAL | disk serial number |
SIZE | size of the device |
STATE | state of the device |
OWNER | user name |
GROUP | group name |
MODE | device node permissions |
ALIGNMENT | alignment offset |
MIN-IO | minimum I/O size |
OPT-IO | optimal I/O size |
PHY-SEC | physical sector size |
LOG-SEC | logical sector size |
ROTA | rotational device |
SCHED | I/O scheduler name |
RQ-SIZE | request queue size |
TYPE | device type |
DISC-ALN | discard alignment offset |
DISC-GRAN | discard granularity |
DISC-MAX | discard max bytes |
DISC-ZERO | discard zeroes data |
WSAME | write same max bytes |
WWN | unique storage identifier |
RAND | adds randomness |
PKNAME | internal parent kernel device name |
HCTL | Host:Channel:Target:Lun for SCSI |
TRAN | device transport type |
SUBSYSTEMS | de-duplicated chain of subsystems |
REV | device revision |
VENDOR | device vendor |
ZONED | zone model |
How to locate/print block device attributes using blkid
Apart from physical block storage and logical partitions, your Linux box may have software RAID and encrypted hard disks too. We can determine the type of filesystem that a block device holds and also the attributes:
# blkid
The ugly output provided as follows; hence it is recommended to use lsblk:
List partitions ynder Linux using the fdisk command
Open a terminal window (select Applications > Accessories > Terminal). Switch to the root user by typing the su — and entering the root password, when prompted by the su command. Or use the sudo command:
$ su —
# fdisk -l
OR
$ sudo fdisk -l
Here is what I see from my Linux desktop:
The -l options shows the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that exists) are used. You can specify device name as follows (in this example list partitions for /dev/sda):
# fdisk -l
Display disk partitions using sfdisk command in Linux
The sfdisk command act as a partition table manipulator for Linux. You can use this tool to list partitions too:
# sfdisk -l /dev/sda
# sfdisk -lu /dev/sda
# sfdisk -ls /dev/sda
Linux partitions info:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
- -l : List the partitions of a device.
- -s : List the size of a partition.
- -u or -uS or -uB or -uC or -uM : Accept or report in units of sectors (blocks, cylinders, megabytes, respecpively). The default is cylinders, at least when the geometry is known.
Listing Linux a Partition Size Larger Than 2TB
The fdisk or sfdisk command will not list any partition size larger than 2TB. To solve this problem you need to use GNU parted command with GPT partitions. It supports Intel EFI/GPT partition tables. Partition Table (GPT) is a standard for the layout of the partition table on a physical hard disk. It is a part of the Extensible Firmware Interface (EFI) standard proposed by Intel as a replacement for the outdated PC BIOS, one of the few remaining relics of the original IBM PC. EFI uses GPT where BIOS uses a Master Boot Record (MBR). In this example list partitions on /dev/sdb using the parted command:
# parted /dev/sdb
GNU/Linux parted prompt:
Set unit type to TB or GB by typing ‘unit TB‘ or ‘unit GB‘ at the (parted) prompt:
(parted) unit TB
OR
(parted) unit GB
To list partitions type print command at the (parted) prompt:
(parted) print
Detailed information:
To exit from parted session type ‘quit’ at the (parted) prompt:
(parted) quit
How Do I List All Partitions Layout On All Block Devices?
Pass the -l OR –list option to the parted command to lists partition layout on all block devices:
# parted -l
Sample outputs:
Fig.01: Show Linux Disk Partitions With GNU parted Command
lssci command to list SCSI devices (or hosts) and their attributes
Use the lsscsi command to show SCSI devices (or hosts) and their attributes:
# lsscsi
Sample outputs:
Here is another outputs:
A note about GUI tools
Linux desktop comes with “Disks & storage” utility to show disk information and perform everyday tasks. Open Disks from the Activities overview under Gnome.
A dialog will open where we can see disks. For instance, I have two 1 TB Samsung NVMe SSD installed in my system. Make sure you choose the disk to see partition information. See the gnome help section for other options.
Using hardware detction tools to print disk paritions on Linux
You can install and use the following tools. I don’t use and promote third party tools on Linux servers as inbuilt tools provide all information. But, I added them here as they might be useful to someone. We can use the hwinfo command to probe for hardware as follows:
hwinfo | more
hwinfo —block | more
hwinfo —block —short
inxi -P
inxi -p | more
See the following pages:
Conclusion
You just learned how to list disk partitions using various Linux commands. For for info see “ls* Commands Are Even More Useful Than You May Have Thought” blog post and man pages by typing the following man command:
man fdisk
man lsblk
man sfdisk
man parted
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
Disk /dev/sda: 145.4 GB, 145492017152 bytes
255 heads, 63 sectors/track, 17688 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 5 40131 de Dell Utility
/dev/sda2 6 1458 11671222+ 83 Linux
/dev/sda3 * 1459 1471 104422+ 83 Linux
/dev/sda4 1472 17688 130263052+ 5 Extended
/dev/sda5 1472 17688 130263021 8e Linux LVM
Model: ST380215A (ide)
Disk /dev/hda: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 16.8GB 16.8GB primary ext3 boot
2 16.8GB 32.5GB 15.7GB primary ext3
3 32.5GB 48.2GB 15.7GB primary ext3
4 48.2GB 80.0GB 31.8GB extended
5 48.2GB 60.8GB 12.6GB logical ext3
6 60.8GB 66.1GB 5239MB logical ext3
7 66.1GB 71.3GB 5239MB logical linux-swap
# fdisk -l
cannot open /proc/partitions
You’re probably missing sudo at the beginning of line 😉
it helps me a lot, thank you . . .
Very informative and nicely written, thanks.
I tried parted -l in debian operating system and it is not working as it is not available in the help command option. Please advise. is there any other command that shows all the partitions and the type of the partition on the operating system.
I am unsure but when I did the sfdisk I got this
sfdisk -lu /dev/sda
unrecognized format – using sectors
Disk /dev/sda: 121601 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sda1 * 4096 81922047 81917952 83 Linux
/dev/sda2 81922247 1715951615 1634029369 83 Linux
start: (c,h,s) expected (1023,254,63) found (1003,108,9)
end: (c,h,s) expected (1023,254,63) found (317,12,15)
/dev/sda3 1715951616 1748717551 32765936 82 Linux swap / Solaris
/dev/sda4 1748717568 1953515519 204797952 83 Linux
Can anyone tell me how to fix the /dev/sda2 ?
How many years have linux installations been plagued by the infamous “No Root File System is Defined” message, whenever a pc user attempts to install Linux or Ubuntu on a hard-drive alongside their Windows installation?!
This has been going on way too long, for the makers of Linux and Ubuntu to not find a simpler way to facilitate this issue. We all know what the problem is yet, for those of us whom wish to use Linux on the same drive as their Windows OS, literally seem to have no choice but to format the entire drive in order to install Linux, because of some stupid glitch that prevents it recognizing the appropriate partition parameters.
Of all my experiences with Linux, none of them have ever been with a hard-drive installation but instead only using the LiveCD versions—because I will not remove Windows, just so that I can install Linux on the one Hard drive I have—which is why I want to install Linux alongside Windows.
The nagging but persistent problem is always the same, “No Root File System is Defined.”
Even after I extended the system partition and changed the partition id of said system partition (which had over 100GB of unused space), to [ “Linux Native” ] from the drop-down menu of the partition program I was using, it still displayed the same error message above. I tried it with the [ Primary ] option in the Linux installation module, as well as an attempt with the [ Logical ] option——-both of these made no difference and yes, before any nit-picking techies get on my case about it——-I tried the above scenarios with following options:
[ Use As: (Ext 4) and Mount Point: ( / ) ]
[ Use As: (EFI Boot Partition) ]
This is what I got after I listed the partition info from the terminal:
WARNING: GPT (GUID Partition Table) detected on ‘/dev/sda’! The util fdisk doesn’t support GPT. Use GNU Parted.
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 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
Disk identifier: 0x02ebc2e4
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 505081855 252437504 7 HPFS/NTFS/exFAT
/dev/sda3 505083904 625139711 60027904 83 Linux
When I visited the Ubuntu and Linux support pages which depict a working installation, what displays is a screen-shot of the Linux installation module, at the screen that actually gives the user a choice if they would like to install it with Windows. I was never given that option when I attempted to install Linux Mint 17 or Ubuntu 14.04.1. Both ISO’s provided me with the exact same setup scenario upon installation——-Either I could erase my only hard-drive (which includes my Win7 I want to keep) or (I could attempt to install manually using the partition options). That’s it!
No option to install with Windows like it showed on the website.
This is so disconcerting to me that after hours of attempting to install a Linux or Ubuntu platform, neither installation module will recognize the appropriate partition configurations to make a dual-boot (without removing Windows) work.
Microsoft may definitely be number one at the top of my list of the most frustrating companies in the world, but after enduring this rigmarole to simply install the OS, Linux is definitely not far behind Microsoft when it comes to such improprieties.
Heck, even Microsoft’s installation of Windows is far simpler than this.
Linux may have intrigued me time and again, but the more I’ve delved into it’s world, all the more frustrated I became. Really——-how different from Microsoft is Linux, when it’s developers couldn’t even fully automate something as simple as a detect and auto-configuration feature to as to facilitate any type of installation a user might want?!
After all these years——-and Linux still can’t fix this problem with partition allocation and configuration, except to again dump all this nonsense on the user to try to sort out?!
It doesn’t matter if it’s free. It’s still marketed as and geared toward users whom want an alternative and even better experience than Windows (even if they still want to keep their Windows installation). Yet the current options available easily put average users in an enormous debacle just to get started with this so-called great Software.
If its that great——–then why make it extremely difficult to setup?! Us average users in the Windows community already have enough Microsoft headaches to deal with all on their own. You promote a cleaner experience on a faster OS that’s easy to use but fall short of making it a complete package by putting together a very sloppy, at best, installation module, which undoubtedly leaves much to be desired——-to say the least.
Please fix this problem with the boot-loader/partition/allocation/Root File System Definitions issue. This is an unnecessary road-block which is probably turning away a lot of users whom might otherwise benefit from using this software and whom might actually like it and want to contribute——-but heck!——-if it’s this much trouble just to try to get it installed onto the same drive as my primary OS——-then maybe that’s just one of the reasons why Windows will likely always be my “Primary” choice!
Why not just run your Linux distribution of choice in a VM so that you can tinker around in Linux and still be able to use your windows machine at the same time? I found this to be much easier for me as I get more familiar with linux
I have never had this issue you describe. I have successfuly installed Ubuntu easily for years alongside Windows, and also Mac OSX.
But I have also installed operating systems before. I have installed DOS, Windows, and (of course) various Linux distros so it may be easier for me to do.
Installing Ubuntu is much easier and quicker than installing Windows (if you have ever done it) and can detect other OS, unlike Windows, though Mac OSX can detect Windows (usually).
Installing an OS in a virtual machine would probably suit you better. It is easy to do and will not screw anything up if you make a mistake. If you have a decent processor with vt handling it will run very well. You can also install Ubuntu onto a USB disk, and boot it from your BIOS (if your computer is able to do this).
If you have you Windows install disks, you can also try installing both in a VM, so you can learn how to do it confidently.
Is there any issues to install Redhat Linux 6 in IDE based hard drive machine… When I try to install it on my laptop, its not booting.. Pls help to solve this issue
I have doubt in partition. First, I install the os that time itself i partition the hard disk then why we using fdisk command
sir, there is four partition in my linux os
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
2 1049kB 109GB 109GB ext4 partition 2
5 109GB 539GB 430GB ntfs Basic data partition msftdata
6 539GB 749GB 210GB ext4 Basic data partition msftdata
1 749GB 1000GB 252GB ext4 partition 1
but in in the file system i am able to see the
1 749GB 1000GB 252GB ext4 partition 1
5 109GB 539GB 430GB ntfs Basic data partition msftdata
and sda 6 and sda2 is unable to see
how to mount it in file system
Источник