Ubuntu Server: How to Mount a USB flashdrive from a Terminal CodeUnit 15 APR 2011

By default, an Ubuntu server installation does not auto mount USB flashdrives that are plugged into it. Thankfully though, doing this yourself is not particularly difficult.

Plug your USB thumb drive into the machine and run:

sudo fdisk -l

This displays a list of devices currently detected. Locate your device in the list – it will probably be something like /dev/sdb1

Now we need to create a mount point for the device. It makes sense to create it in the /media folder, so run:

sudo mkdir /media/external

In the above example we have decided to name the mount point external. You can name it anything you want, but avoid using spaces for multiple words – rather join multiple words with an underscore _ character.

Now to actually mount the drive. If the device is FAT16 or FAT32 (which most USB drives are), run:

sudo mount -t vfat /dev/sdb1 /media/external -o uid=1000,gid=100,utf8,dmask=027,fmask=137

If however you are plugging in a NTFS external hard drive, you would run:

sudo mount -t ntfs-3g /dev/sdb1 /media/external

Done. You can now access the contents on the USB flashdrive by accessing /media/external.

When you finish using the drive, it is critical to unmount it before removing – this will prevent corrupt data and drive failures. To unmount:

sudo umount /media/external


Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.