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 how to find attached devices

2
Understand file systems

Common file system types and their characteristics

3
Mount file systems manually

Use the mount command to access storage devices

4
Unmount file systems safely

Properly disconnect devices to prevent data loss

5
Configure persistent mounts

Use /etc/fstab for automatic mounting at boot

The Mounting Concept

Mounting is the process of making a file system accessible by attaching it to an existing directory (mount point) in the file-system hierarchy.
Storage Device
/dev/sdb1
→ mount →
Mount Point
/mnt/usb
/ (root)
├── home
├── var
├── etc
└── mnt
    └── usb ← /dev/sdb1 mounted here
        ├── documents/
        └── photos/

Mount Point Conventions

Common Locations

  • /mnt — temporary mounts
  • /media — removable media (auto)
  • /mnt/usb — USB drives (manual)
  • /mnt/iso — ISO images
  • /mnt/data — custom data partitions

Key Rules

  • Mount point directory must exist first
  • Files in the directory are hidden while mounted
  • They reappear when unmounted
  • Multiple devices can be mounted at different points
After mounting, files on the device appear under the mount point directory as if they were always part of the file system.

Device Naming

Linux represents storage devices as files in /dev. Understanding device naming helps you identify the correct device to mount.
Device TypeNaming PatternExample
SATA/SAS/USB drives/dev/sdX/dev/sda, /dev/sdb, /dev/sdc
NVMe drives/dev/nvmeXnY/dev/nvme0n1, /dev/nvme1n1
Virtual drives (VMs)/dev/vdX/dev/vda, /dev/vdb
Partitions (SATA)/dev/sdXN/dev/sda1, /dev/sda2, /dev/sdb1
Partitions (NVMe)/dev/nvmeXnYpN/dev/nvme0n1p1, /dev/nvme0n1p2
CD/DVD drives/dev/srN/dev/sr0, /dev/cdrom

Listing Devices: lsblk

# List block devices (storage) — your go-to command
[root@host ~]# lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
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    99G  0 lvm  /
sdb           8:16   1    32G  0 disk
└─sdb1        8:17   1    32G  0 part
lsblk lists block devices in a tree format, showing drives, their partitions, and where they are mounted. The RM column indicates removable media (1 = removable).

Finding Attached Devices

# Show filesystem info, labels, and UUIDs
[root@host ~]# lsblk -f
NAME        FSTYPE      LABEL    UUID                                 MOUNTPOINT
sda
├─sda1      xfs                  a1b2c3d4-...                          /boot
└─sda2      LVM2_member          e5f6g7h8-...
sdb
└─sdb1      vfat        USBDISK  1234-ABCD

# View disk partition information
[root@host ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 32 GiB, 34359738368 bytes
Device     Boot Start      End  Sectors Size Id Type
/dev/sdb1        2048 67108863 67106816  32G  c W95 FAT32 (LBA)

Detecting New Devices

# Check USB devices specifically
[root@host ~]# lsusb
Bus 002 Device 003: ID 0781:5567 SanDisk Corp. Cruzer Blade

# Monitor for new devices (watch kernel messages)
[root@host ~]# dmesg -w
# Plug in device, see messages about new device

# See recent kernel messages after plugging in
[root@host ~]# dmesg | tail
Tip: When you plug in a USB device, run dmesg | tail to see kernel messages identifying the new device. The kernel messages show exactly which device name was assigned — essential when multiple similar devices are connected.

File System Types

File SystemDescriptionMax File SizeUse Case
XFSDefault in RHEL, high performance8 EiBRHEL system drives, large files
ext4Traditional Linux filesystem16 TiBGeneral Linux use, /boot
vfatWindows-compatible, simple4 GiBUSB drives, cross-platform
exFATExtended FAT, large file support16 EiBLarge USB drives, SD cards
NTFSWindows native filesystem16 EiBWindows drives (read/write)
iso9660CD/DVD filesystem4 GiBOptical media, ISO images
RHEL default: XFS for system drives. Use ext4 for /boot. Use vfat/exFAT for cross-platform USB drives. Install ntfs-3g for NTFS support.

The mount Command

mount [-t fstype] [-o options] device mount_point
# Basic mount (auto-detect filesystem)
[root@host ~]# mount /dev/sdb1 /mnt/usb

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

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

# Mount with multiple options
[root@host ~]# mount -o ro,noexec /dev/sdb1 /mnt/usb

# View currently mounted filesystems
[root@host ~]# mount | grep sdb
/dev/sdb1 on /mnt/usb type vfat (rw,relatime,fmask=0022,dmask=0022)
Prerequisite: The mount point directory must exist before mounting. Create it with mkdir -p /mnt/usb if needed.

Mount Options

OptionDescription
rwMount read-write (default)
roMount read-only
noexecDo not allow execution of binaries
nosuidIgnore setuid/setgid bits
nodevDo not interpret device files
syncWrite changes immediately (slower but safer)
asyncWrite changes asynchronously (faster, default)
noautoMust be mounted explicitly (not with mount -a)
userAllow non-root users to mount
defaultsrw, suid, dev, exec, auto, nouser, async

Mount Options: Security & Remount

# Secure mount for untrusted USB drive
[root@host ~]# mount -o ro,noexec,nosuid,nodev /dev/sdb1 /mnt/usb

# Remount with different options (without unmounting)
[root@host ~]# mount -o remount,rw /mnt/usb
Security tip: When mounting untrusted media (USB drives from unknown sources), always use ro,noexec,nosuid,nodev to prevent malware execution and privilege escalation.
You can change mount options without unmounting using -o remount. This is handy for changing options on an already-mounted file system, such as temporarily making a read-only mount writable.

Mounting a USB Drive

# Step 1: Identify the USB device (RM=1 = removable)
[root@host ~]# lsblk
sdb      8:16   1   32G  0 disk       ← USB drive
└─sdb1   8:17   1   32G  0 part       ← Partition to mount

# Step 2: Create mount point
[root@host ~]# mkdir -p /mnt/usb

# Step 3: Mount the partition (not the whole disk!)
[root@host ~]# mount /dev/sdb1 /mnt/usb

# Step 4: Verify mount
[root@host ~]# df -h /mnt/usb
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1        32G  1.2G   31G   4% /mnt/usb

# Step 5: Access files
[root@host ~]# ls /mnt/usb
documents  photos  backup.tar.gz
Mount the partition (/dev/sdb1), not the whole disk (/dev/sdb). The partition contains the file system.

Mounting ISO Images

# Mount an ISO file using the loop option
[root@host ~]# mkdir -p /mnt/iso
[root@host ~]# mount -o loop rhel-9.3-x86_64-dvd.iso /mnt/iso

# Or with explicit type and read-only
[root@host ~]# mount -t iso9660 -o loop,ro rhel-9.3-x86_64-dvd.iso /mnt/iso

# Access ISO contents
[root@host ~]# ls /mnt/iso
AppStream  BaseOS  EFI  images  isolinux  media.repo

# Unmount when done
[root@host ~]# umount /mnt/iso
Loop device: The -o loop option creates a virtual block device from a file, allowing it to be mounted like physical media — without burning to disc.

ISO as Local Repository

# Common use case: configure DNF to use mounted ISO
[root@host ~]# cat /etc/yum.repos.d/local.repo
[local-baseos]
name=Local BaseOS
baseurl=file:///mnt/iso/BaseOS
enabled=1
gpgcheck=0
Mounting a RHEL installation ISO as a local repository is especially useful for isolated systems without internet access. The ISO provides all packages needed for installation and updates.
The loop option is also useful for examining disk images, mounting virtual machine disk files, and working with any file that contains a file system.

Unmounting File Systems

umount (note: not "unmount") detaches a file system from the directory tree. Always unmount before physically removing media!
# Unmount by mount point
[root@host ~]# umount /mnt/usb

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

# Lazy unmount — detach now, fully unmount when not busy
[root@host ~]# umount -l /mnt/usb

# Force unmount (use with caution — may cause data loss)
[root@host ~]# umount -f /mnt/usb
When you work with a file system, data may be cached in memory and not yet written to disk. Unmounting flushes these caches and ensures everything is safely written before the device is removed.

umount: Target is Busy

[root@host ~]# umount /mnt/usb
umount: /mnt/usb: target is busy.

# Find what's using the mount
[root@host ~]# lsof /mnt/usb
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
bash    1234 root  cwd    DIR   8,17     4096    2 /mnt/usb

# Solution: cd out of the directory, then retry
[root@host ~]# cd /
[root@host ~]# umount /mnt/usb
The most common cause of "target is busy" is a shell with its current working directory inside the mounted file system. Simply cd / and retry the unmount.

Safe Media Removal

# Safe removal procedure:

# 1. Ensure no processes are using the mount
[root@host ~]# cd /
[root@host ~]# lsof /mnt/usb

# 2. Sync to force write cached data
[root@host ~]# sync

# 3. Unmount the file system
[root@host ~]# umount /mnt/usb

# 4. Verify unmount (no output = success)
[root@host ~]# mount | grep usb

# 5. Now safe to physically remove

# For extra safety: power off the USB drive first
[root@host ~]# udisksctl power-off -b /dev/sdb
Remember: sync → umount → verify → remove. Following this order protects your data.

Understanding /etc/fstab

/etc/fstab (file system table) defines file systems to mount automatically at boot. Each line specifies a device and how to mount it.
[root@host ~]# cat /etc/fstab
# device                                  mount point  type  options   dump fsck
UUID=a1b2c3d4-5678-90ab-cdef-1234567890ab /            xfs   defaults  0    0
UUID=12345678-90ab-cdef-1234-567890abcdef /boot        ext4  defaults  0    0
/dev/mapper/rhel-swap                     none         swap  defaults  0    0
FieldDescriptionExample
1. DeviceUUID, LABEL, or device pathUUID=..., /dev/sdb1
2. Mount PointWhere to mount/, /boot, /mnt/data
3. TypeFile system typexfs, ext4, vfat
4. OptionsMount optionsdefaults, ro,noexec
5. DumpBackup flag (usually 0)0 or 1
6. FsckCheck order at boot (root=1, others=2)0, 1, or 2

Using UUIDs

# Find UUID of a device
[root@host ~]# blkid /dev/sdb1
/dev/sdb1: LABEL="USBDATA" UUID="1234-ABCD" TYPE="vfat"

# List all UUIDs
[root@host ~]# blkid
/dev/sda1: UUID="a1b2c3d4-..." TYPE="xfs"
/dev/sdb1: UUID="1234-ABCD"  TYPE="vfat" LABEL="USBDATA"

# Using UUID in fstab
UUID=1234-ABCD  /mnt/usb  vfat  defaults  0  0

# Using LABEL in fstab
LABEL=USBDATA   /mnt/usb  vfat  defaults  0  0
Best practice: Use UUID= or LABEL= in /etc/fstab instead of device names like /dev/sdb1. Device names can change between boots — UUIDs never change.

Adding Persistent Mounts

# Step 1: Get the UUID
[root@host ~]# blkid /dev/sdb1
/dev/sdb1: UUID="1234-ABCD" TYPE="vfat" LABEL="BACKUP"

# Step 2: Create mount point
[root@host ~]# mkdir -p /mnt/backup

# Step 3: Add entry to /etc/fstab
[root@host ~]# vim /etc/fstab
UUID=1234-ABCD  /mnt/backup  vfat  defaults,noexec  0  0

# Step 4: CRITICAL — test before rebooting
[root@host ~]# mount -a

# Step 5: Verify
[root@host ~]# mount | grep backup
Critical: Always test with mount -a before rebooting! Errors in fstab can prevent system boot — testing catches problems now rather than at the next reboot.

fstab: Removable Media Options

# Removable media: use noauto and user options
UUID=1234-ABCD  /mnt/usb  vfat  noauto,user,noexec  0  0

# noauto: Don't mount at boot (device might not be present)
# user: Allow regular users to mount/unmount

# Regular user can now mount using just the mount point
[user@host ~]$ mount /mnt/usb
[user@host ~]$ umount /mnt/usb

# For network filesystems: use _netdev
server:/export  /mnt/nfs  nfs  _netdev,defaults  0  0

# For SSDs: add discard for TRIM support
UUID=xxxx  /data  xfs  defaults,discard  0  0
Key options for removable media: noauto (no boot mount)  |  user (users can mount)  |  noexec (security)  |  sync (immediate writes)

Systemd Mount Units

# View mount units
[root@host ~]# systemctl list-units --type=mount
UNIT                  LOAD   ACTIVE SUB     DESCRIPTION
-.mount               loaded active mounted Root Mount
boot.mount            loaded active mounted /boot
mnt-usb.mount         loaded active mounted /mnt/usb

# Check status / Mount / Unmount via systemctl
[root@host ~]# systemctl status mnt-usb.mount
[root@host ~]# systemctl start  mnt-usb.mount
[root@host ~]# systemctl stop   mnt-usb.mount
systemd reads fstab at boot and generates corresponding mount units automatically. Unit names are derived from the mount point path — /mnt/usb becomes mnt-usb.mount.

Manual Mount Unit

# Example manual mount unit: /etc/systemd/system/mnt-data.mount
[Unit]
Description=Data Drive Mount

[Mount]
What=/dev/disk/by-uuid/1234-ABCD
Where=/mnt/data
Type=vfat
Options=defaults,noexec

[Install]
WantedBy=multi-user.target
Manual mount unit files offer more control over dependencies and ordering than fstab alone — useful for complex scenarios where a mount must wait for specific services or conditions.
For most administrators, fstab is sufficient. Use manual mount units only when you need precise systemd dependency control.

Viewing Mount Information

# View all mounted filesystems
[root@host ~]# mount
/dev/sda2 on / type xfs (rw,relatime,seclabel,attr2)
/dev/sda1 on /boot type ext4 (rw,relatime,seclabel)
/dev/sdb1 on /mnt/usb type vfat (rw,relatime,fmask=0022)

# View with disk space usage
[root@host ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        99G   15G   84G  15% /
/dev/sdb1        32G  1.2G   31G   4% /mnt/usb

# Modern mount listing (tree format)
[root@host ~]# findmnt
[root@host ~]# findmnt /mnt/usb
[root@host ~]# findmnt -t vfat
df -h shows disk space usage. findmnt is a modern command showing mounts in a tree format that can also compare fstab against what is actually mounted.

Troubleshooting Mounts

# "wrong fs type, bad option, bad superblock"
[root@host ~]# blkid /dev/sdb1          # Check actual fs type
[root@host ~]# dnf install ntfs-3g      # Install NTFS support if needed

# "mount point does not exist"
[root@host ~]# mkdir -p /mnt/usb

# "only root can mount"
[user@host ~]$ udisksctl mount -b /dev/sdb1

# Boot fails due to fstab error — add nofail to non-critical mounts
UUID=xxxx  /mnt/data  xfs  defaults,nofail  0  0
fstab error at boot: You'll get an emergency shell. Mount root read-write with mount -o remount,rw /, fix /etc/fstab, then reboot. Add nofail to non-critical mounts to prevent boot failures.

Best Practices

Do

  • Use UUID or LABEL in fstab
  • Always unmount before removing media
  • Test fstab changes with mount -a
  • Use noauto for removable media
  • Apply security options (noexec, nosuid)
  • Add nofail for non-critical mounts
  • Verify with df or mount after mounting
  • Document custom mount configurations

Do Not

  • Use device names in fstab (can change)
  • Remove media without unmounting
  • Reboot without testing fstab
  • Force unmount without cause
  • Mount untrusted media with exec
  • Ignore "target is busy" errors
  • Skip backup before fstab changes
  • Assume mount succeeded without checking
Golden rule: Always unmount before physical removal. Always test fstab before reboot.

Key Takeaways

1

Devices: Storage appears as /dev/sdX, /dev/nvmeXnY. Use lsblk and blkid to identify devices and UUIDs.

2

Mount: mount device mountpoint attaches file systems. Create mount point first. Use options for security and behavior.

3

Unmount: umount before removing media. Check for busy processes with lsof. Never skip this step!

4

Persistence: Use /etc/fstab with UUID for automatic mounts. Test with mount -a before rebooting.

Graded Lab

HANDS-ON EXERCISES

  • Identify attached storage devices with lsblk and blkid
  • Mount a USB drive manually to /mnt/usb
  • Create files, sync, and safely unmount the drive
  • Mount an ISO image using the loop option
  • Add a persistent mount to /etc/fstab using UUID
  • Test the fstab entry with mount -a

Next: Monitoring and Managing Linux Processes