Linux Tutorials - Herong's Tutorial Examples - v5.45, by Herong Yang
Mount USB Drive as File System
This section provides a tutorial example on how to mount the formatted partition of a USB drive on a Linux system as a file system.
If you have a USB drive, you can insert it into a USB socket on your Linux system, and follow this tutorial to mount it as a new file system.
1. Check existing SCSI disk devices represented as /dev/sd* files:
herong$ ls -l /dev/sd* brw-rw----. 1 root disk 8, 0 Mar 26 21:17 /dev/sda brw-rw----. 1 root disk 8, 1 Mar 26 21:17 /dev/sda1 brw-rw----. 1 root disk 8, 2 Mar 26 21:17 /dev/sda2 brw-rw----. 1 root disk 8, 5 Mar 26 21:17 /dev/sda5 brw-rw----. 1 root disk 8, 6 Mar 26 21:17 /dev/sda6 brw-rw----. 1 root disk 8, 7 Mar 26 21:17 /dev/sda7
2. Insert the USB drive in a USB socket. And check SCSI disk devices again. Since USB drives are considered as SCSI disk devices on Linux system. You will see more devices are detected and represented as /dev/sd* files. In my example below, I see /dev/sdb representing the USB as a single storage as a whole, and /dev/sdb1 representing the first FAT32 formatted partition.
herong$ ls -l /dev/sd* brw-rw----. 1 root disk 8, 0 Mar 26 21:17 /dev/sda brw-rw----. 1 root disk 8, 1 Mar 26 21:17 /dev/sda1 brw-rw----. 1 root disk 8, 2 Mar 26 21:17 /dev/sda2 brw-rw----. 1 root disk 8, 5 Mar 26 21:17 /dev/sda5 brw-rw----. 1 root disk 8, 6 Mar 26 21:17 /dev/sda6 brw-rw----. 1 root disk 8, 7 Mar 26 21:17 /dev/sda7 brw-rw----. 1 root disk 8, 16 Apr 4 02:25 /dev/sdb brw-rw----. 1 root disk 8, 17 Apr 4 02:25 /dev/sdb1
3. Find a mounting point on the root file system on my CentOS 8 computer, and mount the USB formatted partition device, /dev/sdb1. You may see different mounting points on other Linux systems. By the way, you can not mount /dev/sdb, because it is not a formatted file system.
herong$ ls -l / lrwxrwxrwx. 1 root root 7 May 10 2019 bin -> usr/bin dr-xr-xr-x. 6 root root 4096 Mar 26 21:18 boot drwxr-xr-x. 20 root root 3700 Apr 4 08:25 dev drwxr-xr-x. 144 root root 8192 Mar 30 07:37 etc drwxr-xr-x. 3 root root 20 Mar 26 17:11 home lrwxrwxrwx. 1 root root 7 May 10 2019 lib -> usr/lib drwxr-xr-x. 2 root root 6 May 10 2019 media drwxr-xr-x. 2 root root 6 May 10 2019 mnt drwxr-xr-x. 2 root root 6 May 10 2019 opt ... herong$ ls -l /media total 0 herong$ sudo mount /dev/sdb1 /media
4. Verify the formatted partition of the USB drive as a mounted file system:
herong$ df Filesystem 1K-blocks Used Available Use% Mounted on ... /dev/sdb1 7813124 1146116 6667008 15% /media
5. Check the "System Volume Information" folder, which usually exists on the formatted partition of any USB drive.
herong$ ls -l "/media/System Volume Information" total 256 -rwxrwxrwx 1 herong staff 76 Apr 2 20:43 IndexerVolumeGuid -rwxrwxrwx 1 herong staff 12 Apr 2 20:43 WPSettings.dat
6. Remember to umount the USB file system before taking the USB drive out of the USB socket to avoid any data damage.
herong$ sudo umount /dev/sdb1 (or) herong$ sudo umount /media
Now I am ready to use /media to copy files from and to the USB drive.
Table of Contents
Cockpit - Web Portal for Administrator
"df" - Display Free Space of File System
►Mount USB Drive as File System
"dd" - Copy Data from/to Storage Devices
Use "dd" Command to Test I/O Speed
"du" - Display Disk Usage of Directories
Mount Windows NTFS File System
Access Persmissions on "ntfs-3g" File System
Reformat NTFS Partition into EXT4 Partition
Mount NFS (Network File System) on macOS
/etc/mtab and /etc/fstab Files
Unreachable Remote File Systems
SELinux - Security-Enhanced Linux
SSH Protocol and ssh/scp Commands
Software Package Manager on CentOS - DNF and YUM
vsftpd - Very Secure FTP Daemon