Red Hat System Administration I · RH124

Chapter 14

Accessing Removable Media

Mounting and unmounting · lsblk and blkid · Automount · Safe removal
CIS126RH — Mesa Community College
Identify, mount, use, and safely remove removable storage such as USB drives, from the command line and from the graphical desktop.

Key Commands

  • lsblk
  • blkid
  • mount
  • umount
  • eject
  • Linux uses no drive letters. A device's file system is attached, or mounted, at a mount point in the single directory tree.
  • Once mounted, the device's files appear as an ordinary subdirectory.
Why It MattersA USB drive appears as a directory in the existing tree, commonly under /run/media/username/ when the desktop mounts it automatically.
# 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
Tip — RM Column Marks RemovableA 1 in the RM column marks removable media.
Warning — Double-Check the Device NameA destructive command run against the internal disk instead of the USB drive destroys data irreversibly. Confirm with lsblk first.
# 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
Warning — "Device Is Busy"umount fails while the file system is in use, such as when your shell's working directory is inside it. cd elsewhere, close programs using it, and retry.

In GNOME, the desktop's storage service detects removable media, mounts it under /run/media/username/, and usually offers to open the file manager.

# Confirm where the desktop auto-mounted a device
lsblk
# MOUNTPOINT column will show something like:
# /run/media/student/MYUSBDRIVE
Note — Headless Systems Are DifferentAutomount needs a logged-in desktop session. On a headless server, mount manually with mount.

File systems buffer writes in memory. Removing media before unmounting can leave data partly 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
Tip — Use the Desktop's Eject Button TooIn a graphical session, the file manager's eject icon flushes and unmounts the device in one click.
mount
Attaching a device's file system to a location in the directory tree
mount point
The directory a file system is attached to
block device
A device, such as a disk or USB drive, that stores data in fixed-size blocks
lsblk
Lists block devices and partitions, with sizes and mount points
blkid
Reports each device's file system type, label, and UUID
automount
The desktop automatically detecting and mounting newly connected media
sync
Forces buffered writes to physical storage immediately
  1. Why doesn't Linux use drive letters for removable media?
  2. Which lsblk column quickly identifies removable devices?
  3. What two commands create /mnt/data and mount /dev/sdb1 there?
  4. An unmount fails with "device is busy." What's the likely cause, and the fix?
  5. Where does GNOME automatically mount removable media for a logged-in user?
  6. Why is removing a USB drive without unmounting it risky?
  7. Which command flushes buffered writes before you unmount?