RED HAT ENTERPRISE LINUX

Mounting File Systems

Accessing Removable Media and Storage Devices

CIS126RH | RHEL System Administration 1
Mesa Community College

Learning Objectives

1
Identify storage devices

Understand device naming and use lsblk to list block devices

2
Mount file systems manually

Use mount command to attach file systems to directories

3
Unmount file systems safely

Use umount and understand when unmounting fails

4
Work with removable media

Access USB drives, optical media, and understand automatic mounting

The Mounting Concept

Mounting is the process of attaching a file system to a directory in the Linux file system hierarchy, making its contents accessible at that location.

/dev/sdb1
mount
/mnt/usb

Device + Mount Point = Accessible Files

Key Concept: Linux has a single directory tree starting at /. All storage devices are accessed by mounting them somewhere in this tree - there are no drive letters like C: or D:.

Device Naming

Block devices in Linux are represented as files in /dev/. The naming convention indicates the device type and sequence.

/dev/sda1
Component Meaning Examples
sd SCSI/SATA/USB disk sda, sdb, sdc
a, b, c... Disk sequence (first, second, third) sda = first disk
1, 2, 3... Partition number on disk sda1 = first partition on sda
nvme0n1 NVMe SSD (controller 0, namespace 1) nvme0n1p1 = first partition
sr0 Optical drive (CD/DVD) sr0 = first optical drive

Listing Block Devices

# List all block devices
[root@server ~]# lsblk
NAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda             8:0    0   100G  0 disk 
├─sda1          8:1    0     1G  0 part /boot
└─sda2          8:2    0    99G  0 part 
  ├─rhel-root 253:0    0    50G  0 lvm  /
  └─rhel-swap 253:1    0     4G  0 lvm  [SWAP]
sdb             8:16   1    32G  0 disk 
└─sdb1          8:17   1    32G  0 part 
sr0            11:0    1  1024M  0 rom

# Show file system type
[root@server ~]# lsblk -f
NAME          FSTYPE      LABEL  UUID                                 MOUNTPOINTS
sda                                                                    
├─sda1        xfs                 a1b2c3d4-e5f6-...                    /boot
└─sda2        LVM2_member         d4e5f6a7-b8c9-...                    
  ├─rhel-root xfs                 1a2b3c4d-5e6f-...                    /
  └─rhel-swap swap                9z8y7x6w-5v4u-...                    [SWAP]
sdb                                                                    
└─sdb1        vfat        USBDISK 1234-5678

# Show specific columns
[root@server ~]# lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT,UUID

Device Information Commands

# Show all block devices with details
[root@server ~]# blkid
/dev/sda1: UUID="a1b2c3d4-..." TYPE="xfs" PARTUUID="..."
/dev/sda2: UUID="d4e5f6a7-..." TYPE="LVM2_member" PARTUUID="..."
/dev/sdb1: LABEL="USBDISK" UUID="1234-5678" TYPE="vfat" PARTUUID="..."
/dev/mapper/rhel-root: UUID="1a2b3c4d-..." TYPE="xfs"

# Query specific device
[root@server ~]# blkid /dev/sdb1
/dev/sdb1: LABEL="USBDISK" UUID="1234-5678" TYPE="vfat"

# Show partition table
[root@server ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 32 GiB, 34359738368 bytes, 67108864 sectors
...
Device     Boot Start      End  Sectors Size Id Type
/dev/sdb1        2048 67108863 67106816  32G  c W95 FAT32 (LBA)

# Real-time device events
[root@server ~]# udevadm monitor
# Insert USB device to see events...

The mount Command

# Basic mount syntax
mount [options] device mountpoint

# Mount a device to a directory
[root@server ~]# mount /dev/sdb1 /mnt/usb

# Mount with specific filesystem type
[root@server ~]# mount -t vfat /dev/sdb1 /mnt/usb

# Mount by UUID (more reliable)
[root@server ~]# mount UUID="1234-5678" /mnt/usb

# Mount by label
[root@server ~]# mount LABEL="USBDISK" /mnt/usb

# Mount read-only
[root@server ~]# mount -o ro /dev/sdb1 /mnt/usb

# View currently mounted filesystems
[root@server ~]# mount
[root@server ~]# mount | grep "^/dev"
Mount Point Requirements: The directory must exist before mounting. Create it with mkdir if needed.

Common Mount Options

ro Mount read-only
rw Mount read-write (default)
noexec Prevent program execution
nosuid Ignore setuid/setgid bits
nodev Ignore device files
sync Synchronous I/O (slower, safer)
async Asynchronous I/O (default)
auto Can be mounted with mount -a
noauto Must be mounted explicitly
user Allow non-root users to mount
defaults rw, suid, dev, exec, auto, nouser, async
remount Change options on mounted filesystem
# Combine multiple options with comma
[root@server ~]# mount -o ro,noexec,nosuid /dev/sdb1 /mnt/usb

# Remount with different options (useful for root filesystem)
[root@server ~]# mount -o remount,rw /

Creating Mount Points

# Standard locations for mount points
/mnt         # Temporary mounts (manual)
/media       # Removable media (automatic)
/run/media   # User-specific removable media (GNOME/systemd)

# Create a mount point directory
[root@server ~]# mkdir /mnt/usb

# Create with specific permissions
[root@server ~]# mkdir -m 755 /mnt/backup

# Create nested directories
[root@server ~]# mkdir -p /mnt/data/projects

# Mount the device
[root@server ~]# mount /dev/sdb1 /mnt/usb

# Verify mount
[root@server ~]# ls /mnt/usb
documents  photos  music

# Check mount with df
[root@server ~]# df -h /mnt/usb
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1        32G  8.0G   24G  25% /mnt/usb

Unmounting File Systems

# Unmount by mount point
[root@server ~]# umount /mnt/usb

# Unmount by device
[root@server ~]# umount /dev/sdb1

# Common error: device is busy
[root@server ~]# umount /mnt/usb
umount: /mnt/usb: target is busy.

# Find what's using the mount point
[root@server ~]# lsof /mnt/usb
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
bash     1234 root  cwd    DIR    8,17     4096    2 /mnt/usb
vim      1240 root    4r   REG    8,17    12288   15 /mnt/usb/file.txt

# Alternative: fuser
[root@server ~]# fuser -mv /mnt/usb
                     USER        PID ACCESS COMMAND
/mnt/usb:            root       1234 ..c.. bash
                     root       1240 F.... vim

# Force unmount (use with caution!)
[root@server ~]# umount -f /mnt/usb

# Lazy unmount - unmounts when no longer busy
[root@server ~]# umount -l /mnt/usb

Why Unmounting Matters

Data Loss Risk: Removing media without unmounting can corrupt the filesystem and lose recent writes that are still in cache.

Problems from Not Unmounting:

  • Cached data not written to disk
  • Filesystem metadata corruption
  • Lost files or directories
  • Filesystem marked as dirty/unclean
  • Requires fsck on next mount

Safe Removal Process:

  • Close all files on the device
  • Exit directories on the device
  • Run umount command
  • Wait for command to complete
  • Physically remove media
# Sync all cached writes before unmounting
[root@server ~]# sync
[root@server ~]# umount /mnt/usb

# For extra safety with removable media
[root@server ~]# sync && umount /mnt/usb && sync

Working with USB Drives

# 1. Connect USB drive and identify it
[root@server ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sdb      8:16   1   32G  0 disk 
└─sdb1   8:17   1   32G  0 part           # New USB drive!

# 2. Check filesystem type
[root@server ~]# blkid /dev/sdb1
/dev/sdb1: LABEL="BACKUP" UUID="1234-5678" TYPE="vfat"

# 3. Create mount point
[root@server ~]# mkdir /mnt/usb

# 4. Mount the drive
[root@server ~]# mount /dev/sdb1 /mnt/usb

# 5. Access files
[root@server ~]# ls /mnt/usb
documents  photos  backup.tar.gz

# 6. Copy files
[root@server ~]# cp /etc/passwd /mnt/usb/

# 7. Unmount when done
[root@server ~]# umount /mnt/usb

# 8. Safe to remove physically

Working with Optical Media

# Optical drives are typically sr0, sr1, etc.
[root@server ~]# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sr0     11:0    1   4.7G  0 rom

# Mount a CD/DVD
[root@server ~]# mkdir /mnt/cdrom
[root@server ~]# mount /dev/sr0 /mnt/cdrom
mount: /mnt/cdrom: WARNING: source write-protected, mounted read-only.

# Mount an ISO image file
[root@server ~]# mount -o loop rhel-9.0.iso /mnt/iso

# List contents
[root@server ~]# ls /mnt/cdrom
BaseOS  AppStream  images  isolinux  EFI

# Eject optical media
[root@server ~]# umount /mnt/cdrom
[root@server ~]# eject

# Eject specific drive
[root@server ~]# eject /dev/sr0
ISO Files: The -o loop option mounts an ISO file as if it were a physical disc, using a loop device.

Automatic Mounting with udisks

udisks is a daemon that provides automatic mounting of removable media on desktop systems, with mounts appearing under /run/media/username/.

# On desktop systems, USB drives mount automatically
# Mount location: /run/media/username/LABEL

# Example after inserting USB drive labeled "BACKUP"
[student@workstation ~]$ ls /run/media/student/
BACKUP

# Command-line control with udisksctl
[student@workstation ~]$ udisksctl mount -b /dev/sdb1
Mounted /dev/sdb1 at /run/media/student/BACKUP

# Unmount with udisksctl
[student@workstation ~]$ udisksctl unmount -b /dev/sdb1
Unmounted /dev/sdb1

# Power off the drive (safe removal)
[student@workstation ~]$ udisksctl power-off -b /dev/sdb

# View drive information
[student@workstation ~]$ udisksctl info -b /dev/sdb1

Viewing Mounted Filesystems

# Show all mounts
[root@server ~]# mount | grep "^/dev"
/dev/mapper/rhel-root on / type xfs (rw,relatime,attr2,inode64,logbufs=8)
/dev/sda1 on /boot type xfs (rw,relatime,attr2,inode64,logbufs=8)
/dev/sdb1 on /mnt/usb type vfat (rw,relatime,fmask=0022,dmask=0022)

# Detailed mount info from /proc
[root@server ~]# cat /proc/mounts | grep "^/dev"

# Human-readable disk usage
[root@server ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   50G   12G   38G  24% /
/dev/sda1             1014M  254M  761M  26% /boot
/dev/sdb1               32G  8.0G   24G  25% /mnt/usb

# Show filesystem types
[root@server ~]# df -Th
Filesystem            Type      Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs        50G   12G   38G  24% /
/dev/sda1             xfs      1014M  254M  761M  26% /boot
/dev/sdb1             vfat       32G  8.0G   24G  25% /mnt/usb

# Show only specific filesystem types
[root@server ~]# df -t xfs
[root@server ~]# df -x tmpfs   # Exclude tmpfs

Common Filesystem Types

Type Description Use Cases
xfs Default RHEL filesystem, high performance Root filesystem, data storage
ext4 Fourth extended filesystem, mature and stable /boot, general use, compatibility
vfat FAT32, Windows compatible USB drives, EFI System Partition
ntfs Windows NTFS (via ntfs-3g) Windows data exchange
iso9660 CD/DVD filesystem Optical media, ISO images
nfs Network File System Network shares (covered separately)
tmpfs RAM-based temporary filesystem /tmp, /run, fast scratch space
# Mount NTFS drive (requires ntfs-3g package)
[root@server ~]# mount -t ntfs-3g /dev/sdb1 /mnt/windows

Troubleshooting Mount Issues

# Error: wrong fs type, bad option, bad superblock
[root@server ~]# mount /dev/sdb1 /mnt/usb
mount: /mnt/usb: wrong fs type, bad option, bad superblock...

# Solution: Check filesystem type and specify it
[root@server ~]# blkid /dev/sdb1
[root@server ~]# mount -t ntfs-3g /dev/sdb1 /mnt/usb

# Error: mount point does not exist
[root@server ~]# mkdir /mnt/usb

# Error: already mounted or busy
[root@server ~]# mount | grep /dev/sdb1
[root@server ~]# umount /dev/sdb1  # then remount

# Error: read-only filesystem
[root@server ~]# dmesg | tail  # Check for hardware errors

# Filesystem needs repair
[root@server ~]# fsck /dev/sdb1  # Only on unmounted filesystems!

# NTFS marked as dirty (unclean shutdown from Windows)
[root@server ~]# ntfsfix /dev/sdb1

Introduction to /etc/fstab

/etc/fstab (filesystem table) defines filesystems to mount automatically at boot. It's also used by mount -a and allows simplified mount commands.

# View the filesystem table
[root@server ~]# cat /etc/fstab
# device                    mount-point   type   options        dump fsck
/dev/mapper/rhel-root       /             xfs    defaults       0    0
UUID=a1b2c3d4-e5f6-...      /boot         xfs    defaults       0    0
/dev/mapper/rhel-swap       none          swap   defaults       0    0
UUID=1234-5678              /mnt/usb      vfat   noauto,user    0    0
Field Description Example
1Device (name, UUID, or LABEL)UUID=1234-5678
2Mount point/mnt/usb
3Filesystem typevfat, xfs, ext4
4Mount optionsdefaults, noauto, user
5Dump (backup) - typically 00
6fsck order (0=skip, 1=first, 2=other)0

fstab for Removable Media

# Find UUID of USB drive
[root@server ~]# blkid /dev/sdb1
/dev/sdb1: LABEL="BACKUP" UUID="1234-5678" TYPE="vfat"

# Add entry to /etc/fstab for removable media
[root@server ~]# vim /etc/fstab
# Add this line:
UUID=1234-5678  /mnt/backup  vfat  noauto,user,uid=1000,gid=1000  0  0

# Create mount point
[root@server ~]# mkdir /mnt/backup

# Now regular user can mount/unmount
[student@server ~]$ mount /mnt/backup
[student@server ~]$ ls /mnt/backup
documents  photos
[student@server ~]$ umount /mnt/backup

# Test fstab entry (mount all 'auto' entries)
[root@server ~]# mount -a

# Verify with noauto entries
[root@server ~]# mount /mnt/backup  # Simplified - only mount point needed

Practical Workflow

1. Connect Device └── Physical: Insert USB drive or disc 2. Identify Device └── lsblk # Find device name (sdb1, sr0, etc.) └── blkid /dev/xxx # Check filesystem type and UUID 3. Create Mount Point └── mkdir /mnt/mydrive 4. Mount └── mount /dev/sdb1 /mnt/mydrive └── OR: mount UUID="xxx" /mnt/mydrive 5. Access & Use └── cd /mnt/mydrive └── ls, cp, etc. 6. Unmount Safely └── cd / # Exit the mount point first! └── umount /mnt/mydrive └── Physical: Remove device

Key Takeaways

1

Devices: Block devices live in /dev/; use lsblk and blkid to identify

<