Christopher Carter

For King and Country

Mounting Devices

April 16, 2025

To access an external storage device, like a flash drive, a hard drive, a mobile phone, etc., the device must be mounted to a location on your filesystem.

Block Devices

To mount a block device (hard drive, flash drive, etc.), use the mount syscall:

sudo mount <device> <mountpoint>

where <device> is a device e.g. /dev/sdb1 and <mountpoint> is a directory on your device to mount to. To unmount, simply do:

sudo umount <device>
# or
sudo umount <mountpoint>

Where should my mountpoint be?

If it is removable media, mount it under /media. /media often has seperate subdirectories unter it for each removable medium, e.g. /media/floppy, /media/cdrom, /media/zip, etc. I have /media/usb for my usb drives.

If it is a temporarily mounted filesystem, mount it at /mnt.

But why do I need sudo?

You don’t, if you use udisks.

This is which GUI file managers in systems like Linux Mint, Ubuntu, etc. use to mount devices. When you run:

udisksctl mount -b /dev/sdb1

/dev/sdb1 will automatically be mounted at /run/media/chris/<label>, which is a private directory (not visible to other system users, unlike /media) that doesn’t require root access. The -b is for “block device”.

/run is for “run-time variable data”, and is a directory that will be cleared when the system boots.

To unmount, just run:

udisksctl unmount -b /dev/sdb1

udisks provides a lot more functionality than this, in general providing interfaces for users to “enumerate and perform operations on disks and storage devices”. See man udisks for more.

Android Devices

Unfortunately, Android devices don’t work like typical block devices. Since Android 4.x, file transfer from your Android device uses a protocol called “Media Transfer Protocol” (MTP). The Arch Wiki lists several programs which allow you to mount your device and transfer files.

To mount your phone using e.g. simple-mtpfs,

  1. Plug in your Android device. Select the notification that says the device is USB charging, and choose “File Transfer”.
  2. Run simple-mtpfs -l to list devices.
  3. Run simple-mtpfs --device <device number> <mountpoint>

To unmount, run fusermount -u <mountpoint>.

in hoc signo, vinces

© 2021-2025 Chris Carter. All rights reserved.