Read on to know, how to mount a USB drive in Linux.
Say, you have attached a USB device to your computer running on the Linux operating system, but you are unable to find out why you can’t access the data in it. So, how to mount a USB drive in Linux? The question may sound very difficult, but the answer is practically very simple.
In Linux, the devices do not themselves mount into the system. You need to create a mount point and mount your external USB device at that mount point.
- First, you need to find out the name that Linux has given to your external USB drive. Once you find out the name, the process is just a single command.
- Simply attach your USB device to one of the ports. Once you are done, check out in /dev, under which Linux names the different drives, to find out which is your external drive.
- Simply type the command df on the terminal window. It will display all the drives in the system along with their memory space. Of course, you must be aware of the amount of disk space that is present in your USB drive. If you know this, you will easily be able to pinpoint which drive stands for your USB drive. In general it is located at /dev/sda1.
- Once you are done with this, simply create a mount point. The command to do so is as follows – mkdir /mnt/usbdevice.
- Once you are done with creating the mount point, you need to mount the USB device at that mount point. You can do it with the following command – mount /mnt/usbdevice /dev/sda1.
- Assuming that your USB device is at the location /dev/sda1 and you are logged in as the root user. Whenever you need to access the files in your USB device, you can simply do so by accessing the /mnt/usbdevice folder.
- Once you are done with accessing the device, to unmount the device, you can type the following command – umount /mnt/usbdevice.
How to Permanently Mount a USB Drive in Linux
This is essential so that you do not have to use the mount command, every time your computer boots up. To do so, let us continue with the previous example. Your device is recognized by Linux, at the location /dev/sda1.
Now, to mount the USB drive in Linux, you need to edit the /etc/fstab file. Simply type the command, vi/etc/fstab, at the command prompt. On the last line of the file, simply type the following line:
/dev/sda1 /mnt/usbdevice ext3 defaults 0 0
/dev/sda1 indicates which device to mount and /mnt/usbdevice is the mount point. The argument ext3 stands for the filesystem type, so that Linux applies the same options to the USB device that it does in case of other devices. The fourth option is set to default. The last two 0s indicate if the USB device needs to be backed up using the dump utility.
For most of the machines, you will find you will find that the USB device is located at /dev/sda1. However, if you are using one of the newer machines with a SATA or SCSI drive, you may find the drive at /dev/sdb or /dev/sdc. Nevertheless, you can always figure it out with the df command.