RED HAT ENTERPRISE LINUX

Mounting File Systems

Accessing Removable Media and Storage Devices

College-Level Course Module | RHEL System Administration

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/
Key concept: 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
# List block devices (storage)
[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

Finding Attached Devices

# List all block devices with details
[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 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)

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

# Monitor for new devices (watch dmesg)
[root@host ~]# dmesg -w
# Plug in device, see messages about new device
Tip: When you plug in a USB device, run dmesg | tail to see kernel messages identifying the new device.

File System Types

File systems define how data is organized on storage. Different file systems have different features, limitations, and use cases.

File SystemDescriptionMax File SizeUse Case
XFS Default in RHEL, high performance 8 EiB RHEL system drives, large files
ext4 Traditional Linux filesystem 16 TiB General Linux use, /boot
vfat (FAT32) Windows-compatible, simple 4 GiB USB drives, cross-platform
exFAT Extended FAT, large file support 16 EiB Large USB drives, SD cards
NTFS Windows native filesystem 16 EiB Windows drives (read/write support)
iso9660 CD/DVD filesystem 4 GiB Optical media, ISO images
RHEL default: XFS is the default for RHEL. Use ext4 for /boot and vfat/exFAT for cross-platform USB drives.

The mount Command

mount attaches a file system to the directory tree. You specify the device and the mount point.

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 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)
autoCan be mounted with mount -a
noautoMust be mounted explicitly
userAllow non-root users to mount
defaultsUse default options (rw, suid, dev, exec, auto, nouser, async)
# 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

Mounting a USB Drive

# Step 1: Identify the USB device
[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 /
sdb      8:16   1   32G  0 disk       ← USB drive (RM=1 means removable)
└─sdb1   8:17   1   32G  0 part       ← Partition to mount

# Step 2: Create mount point (if it doesn't exist)
[root@host ~]# mkdir -p /mnt/usb

# Step 3: Mount the partition
[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

Mounting ISO Images

ISO images are file system images typically from CDs/DVDs. Mount them with the loop option to access contents without burning to disc.

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

# Or with explicit options
[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

# Use as local repository (common use case)
[root@host ~]# cat /etc/yum.repos.d/local.repo
[local-baseos]
name=Local BaseOS
baseurl=file:///mnt/iso/BaseOS
enabled=1
gpgcheck=0

# 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.

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

# If busy: find what's using it
[root@host ~]# umount /mnt/usb
umount: /mnt/usb: target is busy.

[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 or close the process
[root@host ~]# cd /
[root@host ~]# umount /mnt/usb

# Force unmount (use with caution - may cause data loss)
[root@host ~]# umount -f /mnt/usb

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

Safe Media Removal

Removing media without unmounting can cause data loss and file system corruption. Always follow the safe removal procedure.

# 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
[root@host ~]# mount | grep usb
# (no output = successfully unmounted)

# 5. Now safe to physically remove the device

# For extra safety with USB drives
[root@host ~]# udisksctl power-off -b /dev/sdb
# Spins down drive before removal
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. DeviceDevice name, UUID, or LABELUUID=..., /dev/sdb1, LABEL=DATA
2. Mount PointWhere to mount/, /boot, /mnt/data
3. TypeFile system typexfs, ext4, vfat, swap
4. OptionsMount optionsdefaults, ro, noexec
5. DumpBackup flag (usually 0)0 or 1
6. FsckCheck order at boot0, 1, or 2

Using UUIDs

UUIDs (Universally Unique Identifiers) uniquely identify file systems. They do not change when device order changes, making them more reliable than device names.

# 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/sda2: UUID="e5f6g7h8-..." TYPE="LVM2_member"
/dev/sdb1: UUID="1234-ABCD" TYPE="vfat" LABEL="USBDATA"

# lsblk also shows UUIDs
[root@host ~]# lsblk -f

# 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. This prevents boot issues when device order changes.

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
# Add this line:
UUID=1234-ABCD  /mnt/backup  vfat  defaults,noexec  0  0

# Step 4: Test the fstab entry (IMPORTANT!)
[root@host ~]# mount -a
# Mounts all fstab entries not yet mounted

# Step 5: Verify
[root@host ~]# mount | grep backup
/dev/sdb1 on /mnt/backup type vfat (rw,noexec,relatime)

# The filesystem will now mount automatically at boot
Critical: Always test with mount -a before rebooting! Errors in fstab can prevent system boot.

Options for Removable Media

# 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
[user@host ~]$ mount /mnt/usb
[user@host ~]$ umount /mnt/usb

# For network file systems (nfs): use _netdev
server:/export  /mnt/nfs  nfs  _netdev,defaults  0  0
# _netdev: Wait for network before mounting

# For SSDs: add discard for TRIM support
UUID=xxxx  /data  xfs  defaults,discard  0  0

# For data integrity: add sync (slower but safer)
UUID=xxxx  /mnt/usb  vfat  sync,noauto,user  0  0
Key options for removable media: noauto (no boot mount), user (users can mount), noexec (security), sync (immediate writes).

Systemd Mount Units

systemd can also manage mounts using .mount unit files. These are automatically generated from fstab but can also be created manually.

# 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 of specific mount
[root@host ~]# systemctl status mnt-usb.mount

# Mount/unmount using systemctl
[root@host ~]# systemctl start mnt-usb.mount
[root@host ~]# systemctl stop mnt-usb.mount

# 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

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/sda1       1.0G  200M  800M  20% /boot
/dev/sdb1        32G  1.2G   31G   4% /mnt/usb

# View specific filesystem types only
[root@host ~]# df -h -t xfs

# View filesystem type
[root@host ~]# df -T
Filesystem     Type  1K-blocks    Used Available Use% Mounted on
/dev/sda2      xfs   103080448 15728640  87351808  16% /

# findmnt - modern mount listing
[root@host ~]# findmnt
[root@host ~]# findmnt /mnt/usb
[root@host ~]# findmnt -t vfat

Troubleshooting Mounts

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

# Problem: "mount: /mnt/usb: mount point does not exist"
# Solution: Create the directory
[root@host ~]# mkdir -p /mnt/usb

# Problem: "target is busy"
# Solution: Find and close what's using it
[root@host ~]# lsof /mnt/usb
[root@host ~]# fuser -mv /mnt/usb

# Problem: "only root can mount"
# Solution: Add user option to fstab, or use udisksctl
[user@host ~]$ udisksctl mount -b /dev/sdb1

# Problem: Boot fails due to fstab error
# Solution: Boot to emergency mode, fix fstab
# Add nofail option to non-critical mounts to prevent boot failure
UUID=xxxx  /mnt/data  xfs  defaults,nofail  0  0

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.

LAB 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