📖 Scenario: You have a USB drive that you want to access on your Linux system. To use it, you need to mount it to a folder. After using it, you will unmount it safely.
🎯 Goal: Learn how to mount a USB drive to a folder and then unmount it using Linux command line commands.
📋 What You'll Learn
Create a directory to use as a mount point
Use the mount command to mount the USB drive
Use the umount command to unmount the USB drive
Display the mount points before and after unmounting
💡 Why This Matters
🌍 Real World
Mounting and unmounting drives is a common task when using external storage devices like USB drives or external hard disks on Linux systems.
💼 Career
System administrators and developers often need to manage storage devices safely and efficiently using these commands.
Progress0 / 4 steps
1
Create a mount point directory
Create a directory called /mnt/usbdrive to use as the mount point for the USB drive.
Linux CLI
Hint
Use the mkdir command with the -p option to create the directory.
2
Mount the USB drive
Mount the USB drive device /dev/sdb1 to the directory /mnt/usbdrive using the mount command.
Linux CLI
Hint
Use mount /dev/sdb1 /mnt/usbdrive to mount the drive.
3
Check mounted drives
Use the mount command without arguments to list all mounted drives and verify that /dev/sdb1 is mounted on /mnt/usbdrive.
Linux CLI
Hint
Simply run mount to see all mounted drives.
4
Unmount the USB drive and verify
Use the umount command to unmount the USB drive from /mnt/usbdrive. Then run mount again to confirm it is no longer mounted.
Linux CLI
Hint
Use umount /mnt/usbdrive to unmount, then mount to check.
Practice
(1/5)
1. What does the mount command do in Linux?
easy
A. It formats a storage device for use.
B. It connects a device or filesystem to a directory so you can access its files.
C. It disconnects a device from the system safely.
D. It lists all files in a directory.
Solution
Step 1: Understand the purpose of mount
The mount command attaches a device or filesystem to a directory, making its files accessible.
Step 2: Differentiate from umount and other commands
Umount disconnects devices, formatting prepares devices, and listing files is done by ls, not mount.
Final Answer:
It connects a device or filesystem to a directory so you can access its files. -> Option B
Quick Check:
Mount = Connect device to directory [OK]
Hint: Mount = connect device to folder, umount = disconnect [OK]
Common Mistakes:
Confusing mount with umount
Thinking mount formats devices
Assuming mount lists files
2. Which of the following is the correct syntax to mount a device /dev/sdb1 to directory /mnt/usb?
easy
A. mount -u /dev/sdb1 /mnt/usb
B. mount /mnt/usb /dev/sdb1
C. umount /dev/sdb1 /mnt/usb
D. mount /dev/sdb1 /mnt/usb
Solution
Step 1: Recall mount command syntax
The correct syntax is mount [device] [mount_point], so device first, then directory.
Step 2: Check options for correctness
mount /dev/sdb1 /mnt/usb matches the syntax: mount /dev/sdb1 /mnt/usb. Others reverse order or use wrong command.
Final Answer:
mount /dev/sdb1 /mnt/usb -> Option D
Quick Check:
mount device directory = correct syntax [OK]
Hint: Device first, then directory in mount command [OK]
Common Mistakes:
Swapping device and directory order
Using umount instead of mount
Adding wrong options like -u
3. What will be the output of the command sequence below if /dev/sdb1 is already mounted on /mnt/usb?
mount /dev/sdb1 /mnt/usb
mount | grep /mnt/usb
medium
A. /dev/sdb1 on /mnt/usb type ext4 (rw,relatime)
B. mount: /mnt/usb is busy
C. mount: /dev/sdb1 is already mounted
D. No output
Solution
Step 1: Understand mounting an already mounted device
Running mount on an already mounted device usually remounts or shows no error, depending on system, but the second command lists mounts.
Step 2: Analyze the grep output
The command mount | grep /mnt/usb shows the current mount info for that directory, typically like /dev/sdb1 on /mnt/usb type ext4 (rw,relatime).
Final Answer:
/dev/sdb1 on /mnt/usb type ext4 (rw,relatime) -> Option A
Quick Check:
mount | grep shows mount info [OK]
Hint: mount | grep shows current mounts [OK]
Common Mistakes:
Expecting error when mounting already mounted device
Confusing mount error messages
Ignoring output of grep command
4. You try to unmount a device with umount /mnt/usb but get the error: umount: /mnt/usb: target is busy. What is the best way to fix this?
medium
A. Close any open files or terminals using /mnt/usb, then try umount again.
B. Force unmount with umount -f /mnt/usb immediately.
C. Reboot the system to clear the busy state.
D. Delete the /mnt/usb directory and try umount again.
Solution
Step 1: Understand 'target is busy' error
This error means some process is using files or directories inside /mnt/usb, blocking unmount.
Step 2: Proper fix is to close those processes
Close open files, terminals, or programs accessing /mnt/usb, then run umount again safely.
Final Answer:
Close any open files or terminals using /mnt/usb, then try umount again. -> Option A
Quick Check:
Busy means in-use; close files before umount [OK]
Hint: Close files using mount point before umount [OK]
Common Mistakes:
Forcing unmount without checking usage
Deleting mount directory instead of unmounting
Rebooting unnecessarily
5. You want to write a script that mounts a USB device /dev/sdb1 to /mnt/usb, copies a file data.txt to it, then safely unmounts it. Which sequence of commands is correct?
hard
A. umount /mnt/usb && mount /dev/sdb1 /mnt/usb && cp data.txt /mnt/usb/
B. cp data.txt /mnt/usb/ && mount /dev/sdb1 /mnt/usb && umount /mnt/usb
C. mount /dev/sdb1 /mnt/usb && cp data.txt /mnt/usb/ && umount /mnt/usb
D. mount /mnt/usb /dev/sdb1 && cp data.txt /mnt/usb/ && umount /mnt/usb
Solution
Step 1: Mount device before copying files
You must mount the device first to access its filesystem, so mount command comes first.
Step 2: Copy file then unmount safely
After copying, unmount to safely disconnect device. The sequence is mount, copy, then umount.
Final Answer:
mount /dev/sdb1 /mnt/usb && cp data.txt /mnt/usb/ && umount /mnt/usb -> Option C
Quick Check:
Mount -> copy -> umount sequence [OK]
Hint: Mount first, copy files, then unmount [OK]
Common Mistakes:
Copying files before mounting
Unmounting before copying
Swapping device and directory in mount
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.