Chapter Objective
Identify, mount, use, and safely remove removable storage media such as USB drives from the command line and the graphical desktop.
Key Commands
lsblkblkidmountumounteject
Identify, mount, use, and safely remove removable storage media such as USB drives from the command line and the graphical desktop.
lsblkblkidmountumountejectLinux doesn't use drive letters. Instead, a storage device's filesystem is mounted — attached — at a chosen point in the single filesystem tree, called a mount point. Once mounted, files on that device appear as an ordinary subdirectory, indistinguishable in normal use from any other part of the tree.
/run/media/username/ when auto-mounted by the desktop.
Before mounting anything manually, confirm the device name the kernel assigned it.
# List block devices in a tree, showing partitions and mount points lsblk # Example output NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part / sdb 8:16 1 32G 0 disk └─sdb1 8:17 1 32G 0 part # Show filesystem type and label/UUID for each device blkid # Show only currently mounted filesystems findmnt
lsblk output, a 1 in the RM (removable) column is your quickest visual cue that a device is removable media rather than a fixed internal disk — helpful for confirming you're about to act on the right device.
lsblk before referencing a device like /dev/sdb in any command.
# Create a mount point if one doesn't already exist sudo mkdir -p /mnt/usbdrive # Mount a partition at that mount point sudo mount /dev/sdb1 /mnt/usbdrive # Confirm it mounted successfully df -h /mnt/usbdrive # Work with files normally, as though it were any other directory ls /mnt/usbdrive # Unmount when finished — always do this before removing the device sudo umount /mnt/usbdrive # Alternative: unmount by mount point OR by device name sudo umount /dev/sdb1
umount refuses to detach a filesystem that's still in use — for example, if a terminal's current working directory is inside it, or a process has an open file there. Change out of the directory and close any programs using it, then try again.
On a system running the GNOME desktop, plugging in removable media is normally handled automatically: the desktop's storage service detects the new device, mounts it under /run/media/username/, and typically offers to open a file manager window for it.
# Confirm where the desktop auto-mounted a device lsblk # MOUNTPOINT column will show something like: # /run/media/student/MYUSBDRIVE
mount, as shown above.
Filesystems buffer writes in memory before flushing them to the physical device. Pulling media out before it's unmounted risks leaving data only half-written.
# Ensure all pending writes are flushed to disk sync # Unmount before physically removing the device sudo umount /mnt/usbdrive # Eject optical media or safely power down a removable drive eject /dev/sdb
umount from the terminal, just one click instead of a command.
lsblk output helps you quickly identify which device is removable?/mnt/data and mount /dev/sdb1 there.