Linux can detect and manage:
- USB drives
- External hard disks
- SSDs
- Memory cards
- CD/DVD devices
These devices are usually mounted under:
/media
or
/mnt
- Detect Connected USB Devices
List USB Devices
lsusb
Shows connected USB hardware.
Example Output
Bus 001 Device 002: USB Flash Drive
- Check Storage Devices
List Disks
lsblk
Example Output
sda 100G
├─sda1 99G
sdb 16G
└─sdb1 16G
Here:
*sdb * is likely the USB drive.
1. Create Mount Point
Before mounting, create a directory:
sudo mkdir /mnt/usb
2. Mount USB Drive
Syntax
sudo mount /dev/sdb1 /mnt/usb
Meaning:
- /dev/sdb1 = USB partition
- /mnt/usb = mount point
Access USB Files
cd /mnt/usb
ls
3. Check Mounted Devices
df -h
Example Output
/dev/sdb1 16G 2G 14G
4. Unmount USB Drive
Before removing device:
sudo umount /mnt/usb
or
sudo umount /dev/sdb1
Important
Never remove USB storage without unmounting.
Otherwise:
- Data corruption may happen
- Files may be damaged
5. Automatic Mounting
Modern Linux distributions automatically mount USB drives under:
/media/username/
Example
/media/aryan/MyUSB
6. Filesystem Types
Common USB filesystem formats:
| Filesystem | Usage |
|---|---|
| vfat/FAT32 | Windows compatibility |
| exFAT | Large USB storage |
| NTFS | Windows drives |
| ext4 | Linux native filesystem |
Check Filesystem Type
lsblk -f
7. Format USB Drive
EXT4 Format
sudo mkfs.ext4 /dev/sdb1
FAT32 Format
sudo mkfs.vfat /dev/sdb1
Warning
Formatting deletes all data.
8. Safely Remove Device
After unmounting:
udisksctl power-off -b /dev/sdb
Safely powers off USB device.
Real-World Usage
Backup Logs to External Disk
cp /var/log/syslog /mnt/usb
Transfer Kubernetes YAML Files
cp *.yaml /mnt/usb
Store Database Backups
mysqldump database > /mnt/usb/backup.sql
Useful Commands Summary
| Command | Purpose |
|---|---|
| lsusb | Show USB devices |
| lsblk | Show disks |
| mount | Mount device |
| umount | Unmount device |
| df -h | Disk usage |
| mkfs.ext4 | Format ext4 |
| mkfs.vfat | Format FAT32 |
Common Mount Locations
| Directory | Usage |
|---|---|
| /media | Auto-mounted devices |
| /mnt | Manual mounts |
Best Practices
- Always unmount before removal
- Verify device name before formatting
- Use df -h to confirm mount
- Avoid mounting unknown USB devices on servers
- Use proper filesystem types for compatibility.
Top comments (0)