How to Use Ubuntu udisksctl to Mount USB Drives from the Terminal

Mounting a USB flash drive or external hard drive in Ubuntu is usually an effortless process; you plug it in, and the GNOME desktop automatically mounts it and opens a file manager window. However, if you are managing an Ubuntu Server without a graphical user interface (GUI), or if you are logged in remotely via SSH, you must mount the drive manually using the command line. While the traditional mount command requires root privileges and manual directory creation, Ubuntu includes a modern, user-friendly alternative called udisksctl. This command-line utility interacts directly with the UDisks2 background service, allowing you to mount and unmount drives exactly as the GUI does, without needing sudo or creating temporary mount points.

Identifying the USB Drive

Before you can mount the drive, you must figure out what device name the Linux kernel assigned to it when it was plugged in. In Linux, storage drives are typically named /dev/sda, /dev/sdb, /dev/sdc, etc., with numbers indicating the partitions (e.g., /dev/sdb1).

  1. Plug the USB drive into your Ubuntu machine.
  2. Open your terminal and type the following command to list all block devices: lsblk
  3. Look at the output tree. Your primary hard drive (where Ubuntu is installed) will usually be sda or nvme0n1. Look for a new device at the bottom of the list with a size that matches your USB drive (for example, 14.9G for a 16GB flash drive).
  4. Note the name of the partition you want to mount, such as sdb1.

Mounting the Drive with udisksctl

Once you know the partition name, mounting it is a single, simple command.

  1. In your terminal, use the udisksctl mount command followed by the -b (block device) flag and the absolute path to the partition: udisksctl mount -b /dev/sdb1
  2. Press Enter. Because udisksctl uses Polkit for authorization, you do not need to prefix this with sudo if you are logged in as a standard user with physical seat access.
  3. The terminal will output a confirmation message telling you exactly where the drive was mounted. It will look something like this: Mounted /dev/sdb1 at /media/username/USB_NAME.

You can now navigate to that /media/username/ directory using the cd command to read or write files to the USB drive.

Unmounting and Powering Off the Drive

Just like ejecting a flash drive in Windows, you must properly unmount the drive in Linux before physically pulling it out of the USB port. Failing to do so can corrupt the file system and cause data loss, as Linux caches write operations in RAM before writing them to the physical disk.

  1. Ensure your terminal is not currently inside the USB drive’s directory. (Type cd ~ to return to your home directory).
  2. Use the unmount command: udisksctl unmount -b /dev/sdb1
  3. The terminal will confirm it has been unmounted. However, the drive is still receiving power. To safely cut power to the USB port so the drive stops spinning, use the power-off command: udisksctl power-off -b /dev/sdb (Note: you target the whole disk sdb here, not the partition sdb1).

Once the power-off command completes, it is completely safe to physically remove the USB drive from your computer.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.