How to get list of Partition and Block devices

Following are the command line utility which can display disk partitions and block devices.

[ root @ leolinux ~ ]#   fdisk  -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes

255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x980e5793
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2          206848   164866047    82329600    7  HPFS/NTFS/exFAT
/dev/sda3       164866048   267266047    51200000   83  Linux
/dev/sda4       267266048   976773119   354753536    5  Extended
/dev/sda5       267270144   287750143    10240000   83  Linux
/dev/sda6       287752192   295944191     4096000   82  Linux swap / Solaris

 

[ root @ leolinux ~ ]#   sfdisk  -l 
Disk /dev/sda: 60801 cylinders, 255 heads, 63 sectors/track
sfdisk: Warning: extended partition does not start at a cylinder boundary.
DOS and Linux will interpret the contents differently.
 
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
 
   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1   *      0+     12-     13-    102400    7  HPFS/NTFS/exFAT
/dev/sda2         12+  10262-  10250-  82329600    7  HPFS/NTFS/exFAT
/dev/sda3      10262+  16636-   6375-  51200000   83  Linux
/dev/sda4      16636+  60801-  44165- 354753536    5  Extended
/dev/sda5      16636+  17911-   1275-  10240000   83  Linux
/dev/sda6      17911+  18421-    510-   4096000   82  Linux swap / Solaris

 

[ root @ leolinux ~ ]#   parted

GNU Parted 3.0

Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.                                                            
(parted) print                                                            
Model: ATA WDC WD5000BPVT-7 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 
 
Number  Start   End     Size    Type      File system     Flags
 1      1049kB  106MB   105MB   primary   ntfs            boot
 2      106MB   84.4GB  84.3GB  primary   ntfs
 3      84.4GB  137GB   52.4GB  primary   ext4
 4      137GB   500GB   363GB   extended
 5      137GB   147GB   10.5GB  logical   ext4
 6      147GB   152GB   4194MB  logical   linux-swap(v1)
(parted) quit

 

[ root @ leolinux ~ ]#    cat   /proc/partitions

major minor  #blocks  name

 
   8        0  488386584 sda
   8        1     102400 sda1
   8        2   82329600 sda2
   8        3   51200000 sda3
   8        4          1 sda4
   8        5   10240000 sda5
   8        6    4096000 sda6
   8        7   71680000 sda7
  11        0    1048575 sr0
 

 

[ root @ leolinux ~ ]#   lsblk

NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT

sda       8:0    0 465.8G  0 disk 
├─sda1    8:1    0   100M  0 part 
├─sda2    8:2    0  78.5G  0 part 
├─sda3    8:3    0  48.8G  0 part /
├─sda4    8:4    0     1K  0 part 
├─sda5    8:5    0   9.8G  0 part /home
├─sda6    8:6    0   3.9G  0 part [SWAP]
└─sda7   8:10   0  51.2G  0 part 
sr0      11:0    1  1024M  0 rom 

 

#  Following command will display mapper device

[ root @ leolinux ~ ]#   dmsetup    ls

vg0-lv0           (253, 0 )

vg1-lv1           (253, 1 )

 

Cheer!!