Note: This article was originally published in 2013. Some steps, commands, or software versions may have changed. Check the current Ubuntu documentation for the latest information.
In this step-by-step guide, you’ll learn list all available hard drives / partitions in ubuntu. Ubuntu is a popular Linux distribution based on Debian, widely used for servers and development environments.
Prerequisites
Before you begin, make sure you have:
- A system running Ubuntu (desktop or server edition)
- Terminal access with sudo privileges
- Basic familiarity with Linux command line
How to: List all available Hard Drives / Partitions in (http://www.ubuntu.com “Ubuntu (operating system)”)
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.
(http://img.zemanta.com/zemified_h.png?x-id=81228b91-6a11-45dc-8666-c637543be47a)](http://www.zemanta.com/?px “Enhanced by Zemanta”)
Summary
You’ve successfully learned list all available hard drives / partitions in ubuntu. If you run into any issues, double-check the prerequisites and ensure your Ubuntu environment is properly configured.