Mounting and unmounting removable devices in linux
Mounting and unmounting removable devices in linux
Display the currently connected devices and available partitions:
fdisk -l
Example: A usb keyring will usually appear as /dev/sda. This device may be considered the 'root' of the device. Each partition is accessible by one of the sub-devices of /dev/sda. In this case /dev/sda1, /dev/sda2. The output from the fdisk command above shows the structure of the device tree.
godel:~# fdisk -l /dev/sda # type name length base ( size ) system /dev/sda1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map /dev/sda2 DOS_FAT_32 DOS_FAT_32_Untitled_2 507824 @ 64 (248.0M) Unknown /dev/sda3 Apple_Free 16 @ 507888 ( 8.0k) Free space Block size=512, Number of Blocks=507904 DeviceType=0x0, DeviceId=0x0 /dev/hda # type name length base ( size ) system /dev/hda1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map /dev/hda2 Apple_Bootstrap untitled 1954 @ 64 (977.0k) NewWorld bootblock /dev/hda3 Apple_UNIX_SVR2 untitled 232939454 @ 2018 (111.1G) Linux native /dev/hda4 Apple_UNIX_SVR2 swap 1500176 @ 232941472 (732.5M) Linux swap Block size=512, Number of Blocks=234441648 DeviceType=0x0, DeviceId=0x0
As you can see we have two physical devices, /dev/hda and /dev/sda, representing the internal hard disk, and a USB pen drive. USB are considered to be SCSI devices and as such are named sdxx.
To mount the main filesystem of the USB drive, the filesystem named "DOS_FAT_32_Untitled_2", we need to refer to this partition. In this case /dev/sda2. So the command to mount FAT filesystem on the USB drive is:
mount -t vfat /dev/sda2 /mnt/keyring
This will of course be automated in the end.