Display, Format, and Mount Hard Drives in Ubuntu

So, it’s come to the point where you want to mount some more hard drives, or format old hard drives, or just see what hard drives you have connected to your Ubuntu box. Great step, now what?

This becomes a complicated matter for the SSH Ubuntu user, who doesn’t have a fancy GUI to do all their work on.

To identify what hard drives are mounted on your system, you run the simple command in the Terminal:


It is not necessary to use sudo.

This should result in a nice list of your filesystems, and show you how much is used, how much is available, and the usage %. It will also tell you where the filesystem/hard drive is mounted, which becomes handy if you’re trying to access the contents to see if there is any valuable information on there.

If you’re running your Ubuntu instance on a cloud, you may have run into the problem where you’ve attached the storage block (EBS in AWS), but for some reason can’t browse to it anywhere in your file browser!

To get a list of attached hard drives, you first need to know what your version of Ubuntu will rename the hard drive as. That is, inside of the AWS management console, your volume will have a label of sda1, but Ubuntu will label it as, for example, xvda1. The reasons for this I have no idea, perhaps a reader can explain this for me..

The terminal command to list the attached file systems, hard drives, or storage blocks, one just simply wants to lists all the devices that start with the xv name in the /dev/ folder, so:

sudo ls /dev/xv*

Of course, you will want to change xv to whatever your Ubuntu version sees the file systems as, so you will want to identify this first with the df command.

This will give you a list of the attached storage devices at your disposal. But remember, use the df command to see which ones you are using.

Once this information is identified, it would be wise to then mount the storage block/file system to Ubuntu so it can then be used!

To get a view of what drives are mounted on your machine, in the terminal simply type:


This should return a list of all the mounted filesystems on the machine. Another way to view the user added file systems is to open up the file /etc/fstab. This file will list the manually entered file systems, which you will be doing in the next step. For more information read Ubuntu’s manual.

An AWS tutorial, that has a section on how to setup and configure an EBS on your Ubuntu box, might come in handy if you’re looking for that solution, specifically the section:

grep -q xfs /proc/filesystems || sudo modprobe xfs
sudo mkfs.xfs /dev/sdh
echo “/dev/sdh /vol xfs noatime 0 0” | sudo tee -a /etc/fstab
sudo mkdir -m 000 /vol
sudo mount /vol

Line 1: see if xfs is recognized, if not install it
Line 2: make/format file system that’s attached (the exact name is found with the instructions in this tutorial)
Line 3: add the necessary details to the /etc/fstab file, which Ubuntu uses to mount file systems
Line 4: make the directory you want to mount the file system to
Line 5: mount the storage device into the file system

Note: You should change the name of /vol to whatever the name is that you want your new directory to be on your Ubuntu box.

Once this is done, using the df command in the terminal should now show you the file system that you just mounted. It should be known, or obvious that you do not want to mount or make a directory in space that is already used by the sytem, and it is a smart system, so it shouldn’t allow you to do this anyways.

Note: if you’re formatting the hard drive, please please please make sure there is no information on there you want to keep!

Hope this helps!

1 Comment

Leave a Reply

11 − one =