January 18, 2025
Linux Terminal Tutorial

Tutorial: How To Mount A Drive on Linux Terminal

The mount command is used to attach drives and files to a filesystem tree on your computer. Here in this tutorial, I’ll show how to mount disk storage or an ISO image.

Find your Device

The first thing you want to do is check where the device you want to mount is located. I connected a 64GB USB stick, by using lsblk I can see where the device file is located. (Note: The Device file contains the instance of a piece of hardware on your computer. These files are located in the /dev folder on the filesystem.)

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223.6G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
└─sda2   8:2    0 223.1G  0 part /
sdb      8:16   1  59.6G  0 disk 
└─sdb1   8:17   1  59.6G  0 part 

I see that sdb is 59.5G and is close to the size of my USB stick and it’s not mounted. Right below that we’ll find sdb1, this is a partition type that we can mount. The device file I want will be located at /dev/sdb1.

If this didn’t help find your device, another utility called fidsk can be used to locate your drive. Running the command “sudo fdisk -l” will show all the drives attach to your system and their partitions.

$ sudo fdisk -l

Disk /dev/sdb: 59.62 GiB, 63999836160 bytes, 124999680 sectors
Disk model: USB 3.0 FD      
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xab612de1

Device     Boot Start       End   Sectors  Size Id Type
/dev/sdb1        2048 124999679 124997632 59.6G  b W95 FAT32

fdisk will show much more information on the devices on your computer then lsblk, we can clearly see what the device name is and size. Here my device is called USB 3.0 FD and at the bottom, it shows a partition located at /dev/sdb1 formatted with FAT32.

Mounting A Storage Device

note: You need root to be able to use mount, you can use sudo to run a command as root.

To mount a device you first need a folder to mount on. Here I created a folder called usb at /mnt.

/mnt$ sudo mkdir usb

Now we can mount the device to that folder with this command “mount /dev/sdxX Your_Folder“. Since we know my USB drive partition is located at /dev/sdb1, the command will look like this.

/mnt$sudo mount /dev/sdb1 usb

Now that it’s mounted change your working directory and explore. If it failed you can try mounting with read-only with the option for mount by "mount -O ro

/mnt$sudo mount -O ro /dev/sdb1 usb

If you continue to have issues try using a filesystem repair tool, you can read my fsck tutorial to try to repair a Linux filesystem.

Mounting A Iso Image

The neat thing with mount you can also mount iso file’s with it too. They will mount as read-only when mounted.

$sudo mount debian-10.10.0-amd64-netinst.iso iso
mount: /home/colby/Downloads/iso: WARNING: device write-protected, mounted read-only.

Unmount Storage From Filesystem

When you want to unmount a Drive from the filesystem you use umount. The umount command can be used at mount-point or device file location. Note: You may need to run the command with sudo.

#at the device file
$sudo umount /dev/sdb1
#or at the mount-point
$sudo umount /mnt/usb 

colby

Computer guru with years working with technology. I find it fun to tinker with computer new and old, and make them do my work for me.

View all posts by colby →

Leave a Reply

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