How to mount usb drive

From IPLOG
Revision as of 11:40, 14 December 2020 by Z033 (talk | contribs)
Jump to: navigation, search

This site is under construction! Detecting USB hard drive
After you plug in your USB device to your USB port, Linux system adds a new block device into /dev/ directory. At this stage, you are not able to use this device as the USB filesystem needs to be mouted before you can retrieve or store any data. To find out what name your block device file have you can run fdisk -l command.

root@iplog:/media# fdisk -l

Disk /dev/mmcblk0: 7458 MB, 7820279808 bytes, 15273984 sectors
238656 cylinders, 4 heads, 16 sectors/track
Units: cylinders of 64 * 512 = 32768 bytes

Device       Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/mmcblk0p1    0,1,1       1023,3,16           16    3818495    3818480 1864M 83 Linux
/dev/mmcblk0p2    1023,3,16   1023,3,16      3818496    7636991    3818496 1864M 83 Linux
/dev/mmcblk0p3    1023,3,16   1023,3,16      7636992   11455487    3818496 1864M 83 Linux
/dev/mmcblk0p4    1023,3,16   1023,3,16     11455488   15273983    3818496 1864M 83 Linux
Disk /dev/sda: 3860 MB, 4047503360 bytes, 7905280 sectors
492 cylinders, 255 heads, 63 sectors/track
Units: cylinders of 16065 * 512 = 8225280 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sda1    0,14,31     491,254,63         912    7905279    7904368 3859M  c Win95 FAT32 (LBA)
Partition 1 has different physical/logical end:
     phys=(491,254,63) logical=(492,20,40)

Create mount point
Before we are able to use mount command to mount the USB partition, we need to create a mount point. Mount point can be any new or existing directory within your host filesystem. Use mkdir command to create a new mount point directory where you want to mount your USB device:

root@iplog:/# mkdir /media/usb-drive

Mount USB Drive
At this stage we are ready to mount our USB's partition /dev/sda1 into /media/usb-drive mount point.

root@iplog:~# mount /dev/sda1 /media/usb-drive/

Check the files

root@iplog:~# ls -l /media/usb-drive/
total 60604
-rwxr-xr-x    1 root     root      35522560 Dec  8 09:43 12.0.11207.tar
drwxr-xr-x    2 root     root          4096 Dec  8 10:05 System Volume Information
-rwxr-xr-x    1 root     root       1337382 Oct 15 11:50 puzzle.ai
-rwxr-xr-x    1 root     root         51887 Dec 10 10:42 puzzle.png
-rwxr-xr-x    1 root     root      23845926 Dec 10 10:42 puzzle.tif
-rwxr-xr-x    1 root     root       1287308 Dec 10 10:42 puzzle2.ai

USB Unmount
Close your shell or navigate away from USB mount point and execute the following linux command to unmount your USB drive:

root@iplog:~# umount /media/usb-drive