Mounting Hard Disks and Partitions Using the Linux Command Line

Austin Luong 14-12-2016

If you’re looking to use the Linux terminal more A Quick Guide To Get Started With The Linux Command Line You can do lots of amazing stuff with commands in Linux and it's really not difficult to learn. Read More , learning how to manually mount and unmount your hard disks is a simple place to start. Besides, if you ever find yourself in a situation that leaves you away from the traditional desktop, learning how to do so might save a lot of time and Googling.


Fortunately, modern Linux distributions The Best Linux Operating Distros The best Linux distros are hard to find. Unless you read our list of the best Linux operating systems for gaming, Raspberry Pi, and more. Read More make this process much easier and intuitive than before.

What Is Mounting?

In most cases, mounting refers to a process which enables your computer to access files on different devices, such as USBs or hard disk drives. This is because they originate from separate file systems. Mounting also occurs in most Linux distributions due to how they themselves use multiple file systems in the form of “partitions”.

Usually, modern Linux desktops handle this automatically. However, it’s good to know how to do it manually if all else fails, or if you happen to be stuck with only a terminal and need to back up some data How to Make Data Backups on Ubuntu & Other Distros How much sensitive data would you lose if your disk drive died? Naturally, you need a backup solution, but making backups in Linux can be tricky if you don't know what you're doing... Read More .

Checking Your Available Partitions

To see your devices and their separate file-systems, simply use this command:




As seen above, separate devices are split into differently named letters, namely sda, sdb, and sdc. Further hard drives follow this convention, continuing to sdd, sde, and so on. Modern hard disks and USBs all start named with sd(x), short for “serial device”. On older computers, you might see them labelled like hda instead.

These devices are further split into different partitions. Put simply, they represent how your hard disk is divided up. It’s these specific partitions which we’re going to mount, rather than the devices themselves — they are where data is actually stored.

As a thumb rule, your Linux box is the device with more than one partition. This is usually done to split important and unimportant system files from one another, among other things What Is a Linux Swap Partition? Everything You Need to Know Most Linux installations suggest you include a swap partition. What is a swap partition for? Here's what you need to know. Read More . Another way to tell is to look under the “Mountpoint” entry. The entries which are part of your Linux box will be already mounted.

Mounting With Udisks

Udisks is an important piece of software used in many Linux distributions. It is responsible for managing storage devices such as USB flash storage, and hard disk drives. With it comes a command line tool called udisksctl. Under this tool, all of your partitioning commands follow this pattern:

udisksctl [command]

Simple isn’t it? To mount your desired partition, use this command, substituting the last bit with the right partition:

udisksctl mount -b /dev/sd[b1, b2, etc.]


The -b simply denotes that what you’re mounting is from a device.

You can also mount disk images with Udisks, but it takes an extra step:

udisksctl loop-setup -r -f Example.iso
udisksctl mount -b /dev/loop[0, 1, 2, etc.]


The first command allows us to recognize our disk image as a virtual (or loop) device. The -r is optional, but makes doubly sure the files you’re mounting won’t be accidentally overwritten — it’s read only. After that, we can proceed as usual, and mount the now available disk image. Since we’re not mounting a hard disk drive, it’s labelled as loop rather than sd(x).

If you check your mounted partitions with the lsblk command again, you’ll notice a few changes.

Notice how the devices other than your Linux box now also have specific mount points. This means you can now access the files on them by going to their specified locations.


Unmounting With Udisks

Once you’re done with your USB, or any other miscellaneous device, you need to safely remove it from your Linux box to prevent data loss. This is done by unmounting the foreign file-system, decoupling it from your own.

Doing this is as simple as substituting mount with unmount:

udisksctl unmount -b /dev/sd[b1, b2, etc.]

udisksctl unmount short

Keep in mind that your virtual devices such as disk images are named differently to hard disk drives and USBs!

If you check your devices using lsblk, you’ll notice that your USB/hard disk drive is still present, even after unmounting it. To remove it completely and safely remove your device, you need to enter in another command which switches it off:

udisksctl power-off -b /dev/sd[b, c, etc.]

udisksctl power off

Note that this does not apply to your own partitions, as they’re part of your system. The same goes for disk images, as they’re not powered in the first place — instead, you’ll need a different command to remove them from your list of devices:

udisksctl loop-delete -b /dev/loop[0, 1, 2, etc.]

Mounting the Old-School Way

For the most part, Udisks should be able to cover most of your bases. However, it’s good to know how to do it another way. The main difference here is that you need to specify where you’d like to mount your partitions, and you won’t be able to turn off your devices using these commands after you’ve finished with them.

You will also need administrator privileges (hence the “sudo” at the beginning of the following commands), so suffice to say, using Udisks is recommended in most cases to prevent your system from breaking accidentally 9 Lethal Linux Commands You Should Never Run You should never run a Linux command unless you know exactly what it does. Here are some of the deadliest Linux commands that you'll, for the most part, want to avoid. Read More !

To mount a partition:

sudo mount /dev/sd[b1, b2, etc.] /mnt

The last part indicates where you’d like to place the foreign file-system in your Linux box. Traditionally, this is the /mnt directory. For multiple devices, you can mount them in sub-folders under /mnt. Just be sure to create these folders first with the mkdir command!

mounting the old school way

Like Udisks, the mount tool also supports disk images. However, memorizing how it works can be a little more cumbersome. On the bright side, you only need to enter a single command compared to the Udisks method:

sudo mount Example.iso /mnt -t (iso9660|udf) -o loop

If the contents of your disk image isn’t showing properly, you may have to alternate between “iso9660” and “udf” (excluding the brackets!) — this indicates the format of the disk image.

Unmounting the Old-School Way

Strangely enough, the command to unmount a partition is not unmount, but umount. Keep that in mind. Unlike mounting, you don’t need to specify the location of your mount point — just the device will do:

sudo umount /dev/sd[b1, b2, etc.]

You can now remove your device without data being potentially lost.

For disk images, the command is a little different:

sudo umount /dev/loop[0, 1, 2, etc.]

Future Referencing

If ever you need to remember the specific steps to mount or unmount your devices with the command line, all you need is to do is to enter this:

udisksctl help

udesksctl help

As seen in the above image, you can also ask for help pertaining to the different udisksctl commands.

So there you have it. With these commands at your side, you’re one step closer to using Linux without the aid of the desktop. If you’re up to it, feel free to navigate through your freshly mounted files through the terminal too.

Looking for more helpful commands? Check out our Linux commands reference The Linux Commands Reference Cheat Sheet This simple cheat sheet will help you get comfortable with the Linux command line terminal in no time. Read More cheat sheet.

Related topics: Disk Partition, Linux.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

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

  1. Pabloes
    June 6, 2020 at 1:58 pm

    Good article. I tried them all but when rebooting, any of these ways of mounting keeps the external HDD mounted... I'll keep on reading.

  2. smit
    October 2, 2017 at 11:16 am

    `sudo apt-install clamav` should be `sudo apt-get install clamav`

  3. Joseph Pollock
    December 21, 2016 at 11:48 pm

    Nice. I learned the basics when udisksctl didn't exist.

    I used to use pmount to get things mounted as a regular user. It was nice, but I just looked and I don't even have it installed any more.

    One thing I haven't really used, is a great feature - mount --bind . It allows you to make parts of file systems appear to be parts of other file systems. This is useful if you want to access/process down a file system tree that is really pieces gathered from more than one source. Your program/user doesn't need to deal with all the separate pieces.

    See: for more info.

  4. spyjoshx
    December 14, 2016 at 3:53 pm

    This clears up a whole lot for me! I've really wanted to use the command line for more, and this is very helpful. I also really like being able to mount to a directory with the MOUNT command. I can see this being very useful. Thank you!

    • Austin Luong
      December 14, 2016 at 11:41 pm

      Happy to have helped!