How to: List all available Hard Drives / Partitions in Ubuntu

How to: List all available Hard Drives / Partitions in Ubuntu

Managing hard drives, partitions and mounting points in Ubuntu requires knowing a few commands in order to list/view what is available on the system. Fortunately Ubuntu offers a few command lines that can help you visualize how your storage is organized so you can access it accordingly.

I. First we have fdisk.

sudo fdisk -l

This is a great tool for seeing information like how is your partition formatted, etc. Very detailed information as shown below:

Disk /dev/sda: 31.5 GB, 31457280000 bytes
4 heads, 32 sectors/track, 480000 cylinders, total 61440000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 1024 bytes
I/O size (minimum/optimal): 1024 bytes / 1024 bytes
Disk identifier: 0x0004dd19

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 61439999 30718976 83 Linux

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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: 0xbd849152

Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 41940991 20969472 7 HPFS/NTFS/exFAT

The problem with this is that it might be too much information and you can’t see mounting points. Mounting points is something availbe in Windows as well but not used as often as it is in Linux. For example, to mount a FAT32 partition located at dev/sda3 read-only into directory /media/my_test_mount you can do

sudo mount -t cifs -o ro /dev/sda3 /media/ext_library

So within your storage structure you can reference several partitions/drives.


II. Then we have lsblk

lsblk is one I like as it provides you with less details but on the other hand it organizes the information onscreen much better and gives you information on the mounting points, etc.

sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

would show the following:

NAME FSTYPE SIZE MOUNTPOINT LABEL

sda 29.3G

└─sda1 ext4 29.3G / cloudimg-rootfs

sdb 20G

└─sdb1 ext4 20G /mnt

sr0 udf 1.1M rd_rdfe_stable.131209-1312

I swear it looks better on my screen. Anyway, as with many of the command lines additional help is availabe lsblk --help. I particularly thing this is the way to go most of the time. 

Enhanced by Zemanta

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.