PDA

View Full Version : [all variants] Mount a USB drive via CLI



/usr/bin/hacked?
May 16th, 2008, 07:14 AM
How do I mount a usb drive via the command line and access it (the access part is important too!)

EXCiD3
May 16th, 2008, 07:19 AM
Pretty simple, here is an example:

sudo mkdir /media/USBSTICK
mount -t vfat /dev/sdb1 /media/USBSTICK
cd /media/USBSTICKExplanation: mkdir creates a directory for the drive to be mounted, mount sets the drive to be mounted in the directory and cd changes the current working directory to where you mounted it to so you can access it.

/usr/bin/hacked?
May 16th, 2008, 06:29 PM
How do I find the name of the usb stick though (/dev/hdx)?

EXCiD3
May 16th, 2008, 06:37 PM
It will be in the /dev folder on your system, most likely it will be the /dev/sdX1 with the X being the last letter in the alphabet of the sdX's listed last letter since it was added most recently. Make sure you use /dev/sdX1 in order to mount the first partition of the usb drive (most will only have 1 anyways). If you use /dev/sdX it will try to mount the MBR which you cannot access the drive to write to if mounted like that.

Monicker
May 16th, 2008, 06:48 PM
You can also use


sudo fdisk -l

Then it should be easy enough to distinguish, based on the size of the usb stick.

/usr/bin/hacked?
May 20th, 2008, 09:37 PM
Awesome, thank you muchly!

chochem
May 24th, 2008, 06:06 PM
Easier still, use a label and mount it with

sudo mount -L [label] [mount point]

If you haven't labelled your drive, check this article (https://help.ubuntu.com/community/RenameUSBDrive) on the wiki.

samosamo
May 25th, 2008, 01:13 AM
you might be interested in autofs package for this, mounts it automatically when you "cd /misc/usb" or however you set it up