Jannah Theme License is not validated, Go to the theme options page to validate the license, You need a single license for each domain name.
ألعاب

How to Mount a Drive in Linux


Mounting a filesystem from a drive is one of the most common tasks that you will do as you use your Linux system. It allows you to access foreign devices inside your machine and manipulate the data inside them. This article will show you how to mount a drive in your Linux system as well as access files inside disks with different internal filesystems.

Mounting an External Drive using the GUI

By default, modern Linux distros will be able to automatically mount a drive as well as access most of the common filesystems right out of the box.

To start, plug in the drive that you want to mount to your machine. This could either be an external hard drive or a simple USB drive.

Go to your system’s application launcher, then open your default file manager.

Inside, you will find your external drive on the manager’s left sidebar. Click the label of your drive to fully mount it and view its contents.

To unmount your drive, click the small eject icon beside your drive’s label.

A screenshot of the default file manager on Ubuntu with a highlight on the drive's eject button.

Tip: other than mounting an external drive, you can also mount ISO files in your file manager.

Force Mount a Drive in Linux using GNOME Disks

Open your system’s application launcher, then open the Disks utility. This will list all the currently active drives in your machine. Select your external disk from the program’s left sidebar.

A screenshot highlighting the external drive on the GNOME Disks utility.

Click the “Play” button underneath the visual partition table for your external drive. This will forcibly mount the drive to your filesystem.

A screenshot highlighting the mount button on the GNOME Disks utility.

Open your system’s default file manager and scroll through the program’s left sidebar. Click your external drive’s label to access its contents.

To unmount your external drive, go back to GNOME Disks. Select your drive and click the “Stop” button under your drive’s visual partition table.

A screenshot highlighting the unmount button on the GNOME Disks utility.

Mounting an External Drive using the Command Line

While using the GUI is enough to mount a basic drive in Linux, there can be instances where you need to access one over SSH as a headless machine. For that, you need to use the built-in UNIX mount command.

To start, plug the drive that you want to mount, then run the following command:

This will list all the SATA/SCSI devices in your machine. In most cases, the “sda” disk corresponds to your system drive while everything else after are additional, non-system drives.

Run the following command to check if there are any mountable partitions inside your external drive:

Create a directory where your drive can mount itself properly:

sudo mkdir -p /media/drive

Mount your external drive’s partition to your system’s root filesystem. The following command will display all the contents of your external drive to the “/media/drive” folder and move your current working directory to it.

sudo mount /dev/sdb1 /media/drive
cd /media/drive

Ensure that your drive has the correct permission bits for your current user:

sudo chown -R $USER:$USER /media/drive

Check whether the drive is working properly by listing its contents:

Mount a Drive in Linux with a Specific Filesystem

Another great feature of the mount command is that it can specify the filesystem that it will mount the drive as.

To start, check the filesystem type for the available partitions inside your external drive:

This will print a list of the partitions inside your drive along with their filesystem under the second column.

A terminal showing the filesystem type of the sda1 partition.

You can use the value in the second column with the -t option in mount to force mount a partition as that filesystem:

sudo mount -t vfat /dev/sdb1 /media/drive

Check whether you have properly mounted the filesystem by going inside the media directory and listing its contents:

To unmount the drive, you can use the umount command followed by the directory where the drive is currently mounted:

If you need to mount an NTFS partition on your Linux machine, here is the way to do it.

Frequently Asked Questions

I have a “mount: wrong fs type, bad option, bad superblock” error when I mount my drive.

This issue is due to a missing filesystem binary in your system. The most common filesystem that causes this problem is NTFS since it doesn’t come on most Linux distros by default. To fix this, you need to install the ntfs-3g package from your distro’s package manager.

My external drive is being mounted as “read-only.”

This problem is caused by an improperly unmounted Ext4 drive. You can fix by remounting the drive either with a “read-write” tag: sudo mount -o rw /dev/sdb1 /mnt/drive or the “noload” option: sudo mount -o ro,noload /dev/sdb1 /mnt/drive.

Is it possible to automatically mount a drive in Linux?

Yes. To do that, you can go to your GNOME Disks program and select the drive that you want to automount. Click the “Gear” icon under the drive’s partition table, then select “Edit Mount Options.” Inside, disable the “User System Defaults” option, then tick the “Mount at System Startup” checkbox. Alternatively, you can add an /etc/fstab entry so it can auto mount the drive on boot up.

Image credit: Immo Wegmann via Unsplash. All alterations and screenshots by Ramces Red.

Ramces Red

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *

زر الذهاب إلى الأعلى