If you plug a USB thumb drive into a Windows PC or a Mac, a folder instantly pops up on the screen, allowing you to drag and drop files immediately. If you plug a USB thumb drive into a headless Linux server running a command-line interface, absolutely nothing happens. The kernel detects the hardware, but it refuses to actively connect the file system to your operating system until you explicitly tell it to.
In Linux, the process of linking a piece of external hardware (like a USB drive or a secondary hard drive) to an empty directory in your file system so you can actually read the files is called “mounting.” Here is how to do it manually.
Step 1: Identify the USB Drive
Before you can mount the drive, you must figure out what random hardware name the Linux kernel assigned to it when you plugged it in. In Linux, all hardware devices are represented as files inside the /dev/ (devices) directory.
- Plug the USB drive into the server.
- Open your terminal and type this command:
sudo fdisk -l
- Press Enter.
The terminal will print a list of every single hard drive attached to the system. You must look closely at the size of the drives to identify your USB.
- Your primary 1TB hard drive will likely be listed as
/dev/sda. - Your 16GB USB drive will likely be listed at the absolute bottom as
/dev/sdb. - Below
/dev/sdb, you will see the actual, formatted partition on that drive (e.g.,/dev/sdb1). This is the exact partition you need to mount. Write it down.
(Note: If you are using an NVMe drive, your primary drive might be /dev/nvme0n1, meaning the USB drive might show up as /dev/sda1).
Step 2: Create a Mount Point
You cannot mount a hard drive into the void. You must mount it to an empty folder. When you open that empty folder, you will be looking inside the USB drive.
By convention, Linux administrators usually create temporary mount points inside the /mnt/ or /media/ directories.
- Type this command to create a brand new, empty folder named “usb”:
sudo mkdir -p /mnt/usb
- Press Enter.
Step 3: Mount the Drive
Now you must bridge the hardware (/dev/sdb1) to the folder (/mnt/usb).
- Type the mount command:
sudo mount /dev/sdb1 /mnt/usb
- Press Enter.
If the command is successful, the terminal will say absolutely nothing. It will just return to a blank prompt. This is a good thing.
To verify it worked, navigate into your new folder and list the contents:
cd /mnt/usb
ls -l
You will now see all the files and folders stored on your USB drive. You can copy files to the drive using the standard cp command, or move them using mv.
Step 4: Unmount the Drive (Crucial)
CRITICAL WARNING: Never physically rip a USB drive out of a Linux server without unmounting it first. Linux uses “lazy writing” (asynchronous I/O), meaning it often pretends to copy a file to the USB drive, but actually waits in the background to do it later. If you pull the drive out, you will corrupt the file system and destroy your data.
You must tell the kernel to flush its cache and sever the connection.
- First, you must step out of the USB folder. (You cannot unmount a drive if you are currently standing inside it; the terminal will scream “target is busy”). Type:
cd ~
- Now, issue the unmount (umount) command:
sudo umount /mnt/usb
- Press Enter.
Wait for the terminal prompt to return. Once it does, the drive is safely disconnected, and you can physically remove it from the server.