Command to show partition scheme
Solution 1
There are many possible ways. These three below should be the most common. The stuff after #
on the command lines are comments explaining what each of them does, you don't need to copy them.
lsblk
This is probably the most simple tool to get a quick overview of what partitions exist. Nested structures (e.g. disk > partition > LUKS container > LVM container > volume) are also nicely displayed as a tree. Runs as regular user, no sudo
needed.
You get (amongst others) information about device name, size, type and mount point (if mounted). With the option -f
it will show file system type, label and UUID.
It's possible to specify a disk, partition or any similar device to only view information about that instead of listing everything.
Examples:
lsblk # default info about all devices
lsblk -f # file system info about all devices
lsblk /dev/sda1 # default info about the /dev/sda1 partition and its children only
lsblk -f /dev/sdb # file system info about the /dev/sdb disk and its children only
See man lsblk
for more info.
parted
parted
is a more powerful command-line tool, similar to its GUI pendant GParted. It can also modify the partitioning layout. Note that this requires elevated privileges (sudo
) to run.
It will show you information about your disk hardware (model, type, size, sector size, ...) as well as a detailed partition table including start and end positions, size, type, file system, flags, label, ...
You can either list everything or specify a disk to print details about.
Examples:
sudo parted -l # show info about all devices
sudo parted /dev/sda print # show info about the /dev/sda disk only
See man parted
for more info.
fdisk
fdisk
is very similar to parted
. It is also able to make modifications, requires elevated privileges and shows basically the same information as well.
Examples:
sudo fdisk -l # show info about all devices
sudo fdisk -l /dev/sda # show info about the /dev/sda disk only
See man fdisk
for more info.
Solution 2
fdisk
For my two 1 TB disks
sudo fdisk -l # (ell)
gives the following output:
Disk /dev/sda: 931,5 GiB, 1000204886016 bytes, 1953525168 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
Disklabel type: dos
Disk identifier: 0x81fe91a0
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 821247 819200 400M 83 Linux
/dev/sda2 821248 1953525167 1952703920 931,1G f W95 Ext'd (LBA)
/dev/sda5 823296 391028735 390205440 186,1G 83 Linux
/dev/sda6 391030784 1415032831 1024002048 488,3G 83 Linux
/dev/sda7 1415034880 1451898879 36864000 17,6G 82 Linux swap / Solaris
Disk /dev/sdb: 931,5 GiB, 1000204886016 bytes, 1953525168 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
Disklabel type: dos
Disk identifier: 0x81fe91a0
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1953523711 1953521664 931,5G 5 Extended
/dev/sdb5 4096 629149695 629145600 300G 83 Linux
/dev/sdb6 629151744 1258297343 629145600 300G 83 Linux
lsblk
The command
lsblk # apparently no sudo needed
gives
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931,5G 0 disk
├─sda1 8:1 0 400M 0 part
├─sda2 8:2 0 1K 0 part
├─sda5 8:5 0 186,1G 0 part /
├─sda6 8:6 0 488,3G 0 part /home
└─sda7 8:7 0 17,6G 0 part [SWAP]
sdb 8:16 0 931,5G 0 disk
├─sdb1 8:17 0 1K 0 part
├─sdb5 8:21 0 300G 0 part /mnt/freeA
└─sdb6 8:22 0 300G 0 part /mnt/freeB
sr0 11:0 1 1024M 0 rom
(sr0
is a DVD drive).
Related videos on Youtube
![vipul jadhav](https://lh5.googleusercontent.com/-lFaDs1Lq1-0/AAAAAAAAAAI/AAAAAAAAADI/3U4RydHd9IY/photo.jpg?sz=256)
vipul jadhav
Updated on September 18, 2022Comments
-
vipul jadhav almost 2 years
What is the command for looking at the partition scheme of the hard disk on Ubuntu?
I know we can see the partition scheme in Gparted, but how can we run it on command line?
-
David Foerster over 6 yearsDon't forget
gdisk
, the GPT-equivalent offdisk
! -
wjandrea over 6 years
lsblk
requiressudo
if you want certain info, like volume label and filesystem type. -
Byte Commander over 6 years@WJAndrea Are you sure? I can't confirm your statement on 16.04, for me both
lsblk
andsudo lsblk
(orlsblk -f
andsudo lsblk -f
) show exactly the same amount of information. -
wjandrea over 6 yearsOh yeah, on 16.04 it's not required. I guess it changed since 14.04, which I'm using.