How to mount USB flash drive in Linux

To mount USB flash drive on any Linux system you will first need to know the disk partition name for the USB drive. Finding the partition name is an easy task. Follow the steps below to find the partition name and mounting it on a directory of your choice.

1. Check for the /var/log/messages file for the messages related to the USB flash drive. As soon as you connect a flash drive you would see messages about it.

Oct  6 19:03:32 localhost kernel: usb 1-1: new high-speed USB device number 2 using ehci-pci
Oct  6 19:03:32 localhost kernel: usb 1-1: New USB device found, idVendor=1058, idProduct=1023
Oct  6 19:03:32 localhost kernel: usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Oct  6 19:03:32 localhost kernel: usb 1-1: Product: Elements 1023
Oct  6 19:03:32 localhost kernel: usb 1-1: Manufacturer: Western Digital
Oct  6 19:03:32 localhost kernel: usb 1-1: SerialNumber: 57584A314135315034373736
Oct  6 19:03:32 localhost mtp-probe: checking bus 1, device 2: "/sys/devices/pci0000:00/0000:00:11.0/0000:02:02.0/usb1/1-1"
Oct  6 19:03:32 localhost mtp-probe: bus: 1, device: 2 was not an MTP device
Oct  6 19:03:32 localhost kernel: usb-storage 1-1:1.0: USB Mass Storage device detected
Oct  6 19:03:32 localhost kernel: scsi host3: usb-storage 1-1:1.0
Oct  6 19:03:32 localhost kernel: usbcore: registered new interface driver usb-storage
Oct  6 19:03:32 localhost kernel: usbcore: registered new interface driver uas
Oct  6 19:03:33 localhost kernel: scsi 3:0:0:0: Direct-Access     WD       Elements 1023    2005 PQ: 0 ANSI: 4
Oct  6 19:03:33 localhost kernel: sd 3:0:0:0: Attached scsi generic sg4 type 0
Oct  6 19:03:33 localhost kernel: sd 3:0:0:0: [sdd] 976769024 512-byte logical blocks: (500 GB/465 GiB)
Oct  6 19:03:33 localhost kernel: sd 3:0:0:0: [sdd] Test WP failed, assume Write Enabled
Oct  6 19:03:33 localhost kernel: sd 3:0:0:0: [sdd] Asking for cache data failed
Oct  6 19:03:33 localhost kernel: sd 3:0:0:0: [sdd] Assuming drive cache: write through
Oct  6 19:03:33 localhost kernel: sdd: sdd1 sdd2
Oct  6 19:03:33 localhost kernel: sd 3:0:0:0: [sdd] Attached SCSI disk

Instead of this you can also scroll through the output of ‘fdisk -l’ command to find out the newly attached USB flash drive. For example :

# fdisk -l
...
Disk /dev/sdd: 500.1 GB, 500105740288 bytes, 976769024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


#         Start          End    Size  Type            Name
 1           40       409639    200M  EFI System      EFI System Partition
 2       411648    976766975  465.6G  Microsoft basic WD

2. As shown from the output above, USB device named as sdd is detected by the system. We can use this device to mount it on a directory.

3. Create a directory to mount the USB flash drive onto.

# mkdir /mnt/usb

4. Now mount the appropriate partition onto the directory to access the data on USB flash drive.

# fdisk -l /dev/sdd
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sdd: 500.1 GB, 500105740288 bytes, 976769024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


#         Start          End    Size  Type            Name
 1           40       409639    200M  EFI System      EFI System Partition
 2       411648    976766975  465.6G  Microsoft basic WD

As seen from the output above the second partition contains data. We will use /dev/sdd2 to mount.

# mount /dev/sdd2 /mnt/usb
Related Post