Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Lab 14.1RH124, Chapter 14

Mount a USB disk and an ISO file, then remove them safely

Level
Easy
25 min
Machines
server1
Status
Not started

Goal

Practise the full life of removable media on server1: find a new disk, mount it, copy files to it, fix a "target is busy" error, and read an ISO file. No real USB stick is needed — you add a small virtual disk.

Before you start

  • server1 with RHEL 10 (or CentOS Stream 10 / AlmaLinux 10) and root access.
  • Add a new empty virtual disk of 1 GiB to server1 (in virt-manager: Add Hardware → Storage, bus USB if you can choose, else VirtIO). It plays the USB stick.
  • An ISO file on server1, for example the RHEL 10 DVD ISO in /root/. Any ISO works.

Tasks

  1. Find the name of the new disk. Write down its size and whether the kernel sees it as removable.
  2. Make one partition on the new disk that uses the whole disk, and format it as vfat with the label LABSTICK.
  3. Mount it on /mnt/usb so that the user student owns all files on it.
  4. As student, copy /etc/os-release to the stick.
  5. Open a second shell, cd /mnt/usb in it, and try to unmount the stick in the first shell. Find the reason for the error and fix it, then unmount.
  6. Mount the ISO file read-only on /mnt/iso and list the folders in it. Then unmount it.

Check your work

lsblk -f
findmnt /mnt/usb
ls -l /mnt/usb/os-release
findmnt /mnt/iso

Hints

Show the hints

Solution

Show the solution
  1. Compare the disk list. Here the new disk is /dev/sda (it can be /dev/vdb on VirtIO).
    lsblk -o NAME,SIZE,RM,TYPE
  2. Partition and format it.
    parted -s /dev/sda mklabel msdos mkpart primary fat32 1MiB 100%
    mkfs.vfat -n LABSTICK /dev/sda1
  3. Mount it for student (UID and GID 1000 on most test systems; check with id student).
    id student
    mkdir -p /mnt/usb
    mount -o uid=1000,gid=1000 /dev/sda1 /mnt/usb
  4. Copy the file as student.
    cp /etc/os-release /mnt/usb/
    ls -l /mnt/usb
  5. The second shell is inside the folder. Find it, leave the folder there, then unmount.
    umount /mnt/usb
    fuser -vm /mnt/usb
    umount /mnt/usb
  6. Mount the ISO read-only with a loop device.
    mkdir -p /mnt/iso
    mount -o loop,ro /root/rhel-10.0-x86_64-dvd.iso /mnt/iso
    ls /mnt/iso
    umount /mnt/iso

My notes

No notes yet.

Lessons for this lab

Commands in this lab