Last updated
Last updated
The /media
directory in Unix and Linux systems is used as a common mount point for removable media, such as USB drives, CDs, DVDs, and other external storage devices. When you insert a removable device, many Linux distributions automatically mount it under the /media
directory, creating a subdirectory named after the device label or identifier.
/media
Purpose: To provide a standardized location for mounting removable media.
Usage: Typically used by the operating system's automounter to mount devices when they are inserted.
Directory Structure: Subdirectories within /media
are often named after the label of the device or a unique identifier to distinguish between multiple devices.
When you plug in a USB drive labeled USB_DRIVE
, the automounter might create a directory like /media/username/USB_DRIVE
and mount the drive there.
Here, username
is your current user's name.
Many desktop environments (such as GNOME, KDE, and others) automatically mount removable devices to /media
using tools like udisks
or gvfs
. This automatic mounting is convenient for everyday users who need to access removable media without manually running mount commands.
While automatic mounting is convenient, you may sometimes need to manually mount a device to the /media
directory. Here’s how you can do it:
Identify the Device: Use the lsblk
or blkid
command to find the device name.
Output example:
Here, /dev/sdb1
is the USB drive.
Create a Mount Point: Create a directory under /media
where you want to mount the device.
Mount the Device: Use the mount
command to mount the device to the created directory.
Verify the Mount: Check that the device is mounted correctly.
To unmount a device, use the umount
command followed by the mount point or the device name.
Unmount the previously mounted USB drive:
To configure automatic mounting behavior, you can use /etc/fstab
for persistent mounts, or rely on desktop environment settings and automount tools.
/etc/fstab
EntryTo automatically mount a USB drive with UUID a1b2c3d4-e5f6-7890-1234-56789abcdef0
at boot:
The /media
directory plays a crucial role in managing removable media in Unix and Linux systems. It provides a standardized location for mounting external devices, which can be handled automatically by the operating system or manually by the user. Understanding how to use and configure /media
is essential for effectively managing storage devices and ensuring seamless access to external media.