Saturday, December 1, 2007

How To Mount USB flash drive from Command Line

Mounting a USB flash drive in GNOME (or another Linux desktop environment) is as easy as plug and play. Yet, occasionally, you need to mount one on a server which does not run X, then you must know how to do it on the command line.

  1. Become root.

    $ sudo -s


  2. Plug in USB drive to a USB port.

  3. Identify the correct partition name corresponding to the USB drive.

    For my Debian system, it is sda, and partition 1.
    $ dmesg |grep -i 'SCSI device'
    ...
    SCSI device sda: 3903488 512-byte hdwr sectors (1999 MB)

    Alternatively,
     $ grep  SCSI /var/log/messages
    ...
    Dec 1 11:52:26 tiger kernel: SCSI device sda: 3903488 512-byte hdwr sectors (1999 MB)

  4. Mount the partition to an existing mount point (directory).

    $ mkdir -p /mnt/myusb
    $ mount -t vfat -o rw,users /dev/sda1 /mnt/myusb

    users give non-root users the ability to unmount the drive.

    You can verify the drive is indeed mounted as follows:
     $ mount

    You should see a line in the output that looks like:

    /dev/sda1 on /mnt/myusb type vfat (rw,noexec,nosuid,nodev)


To retrieve the USB drive:

  1. You must unmount the partition before physically unplugging the USB device.


    $ umount /mnt/myusb

    You can run the mount command again (with no argument) to verify that the volume is indeed mounted.

  2. Unplug USB drive.


StumbleUpon Toolbar

21 comments:

Anonymous said...

Awesome. Thank you.

Anonymous said...

Ditto - thanks also!

Søren said...

Same as the others. Thanks a lot for the help.

Anonymous said...

Bravo; with my particular distro - PuppyLinux - I found that once I saved my pup-save.2fs after first boot; then it would auto-mount the flash drive where my files were stored because the pup-save.2fs was on there.

rax said...

Linux flash drive can provide a communication channel that is safe from a possibly compromised computer. linux flash drive

Promo USB Drives said...

Thanks for the help, I've been looking around for a guide like this for quite a while now but couldn't find one. Your step by step guide is perfect for mounting the USB flash drive and I've done it now. Thanks again for your help.

Anonymous said...

very helpful

Anonymous said...

Fantastic and simple. Thanks a lot.

green pc said...
This comment has been removed by a blog administrator.
flash said...

Exactly what I need !!
Bookmarked already.

Anonymous said...

Many thanks! Exactly what I needed to know.

Clearly set out, and works like a charm :)

Anonymous said...

Thanks, were just about pulling all my hair off my head, because of that "stupid" USB thumb drive (in this case it's properly the use there are “stupid”), there were impossible to copy some files over on.

Very good that you explicitly explains all the steps, and there is not excluded anything as “already know steps/info”, so that it actually succeeds for us noobs/newbies (or what it’s called).

Keep up the good work ! it’s super nice when more and more “stupidity” leaves the world, defeated by good explanations (and my hair probably is more suitable on the head there it belongs).

(Just if others can use the info, the USB Thumb drive was a 32 GB Kingston with one FAT32 partition and 32 kilobytes “allocation units” on, just “express formatted” in Windows 7 like normal.
There are maybe something with that Linux (still?) doesn’t “talks” well with the NTFS (at least also used on) windows file system, so maybe it could be an idea to try to format your drive as/with FAT32 file system if it is tricky.
I stood in the directory where the files were located, in my case ‘/home/user/’ , and wrote:

cp * /mnt/myusb

cp – A shortening of ‘copy’, which is the equivalent in DOS/windows).
* - What files you would like to copy, here is used a “joker sign” there substitutes all filenames/replaces writing all the filenames individually.
/mnt/myusb - The place where you would like to copy the files to. )

optical storage disks said...

You cam learn how to mount usb flash drive. Read to know more

CD DVD said...

You cam learn how to mount usb flash drive. Read to know more

DVD replication said...

I have read many blogs and found good and informatics but this blog has simply thrill me with it designs, colour combination and the most important thing real information. I have found only genuine and useful information on this blog.

Printing Brochures said...

Its really a great post. I am sure that anyone would like to visit it again and again. After reading this post I got some very unique information which are really very helpful for anyone. This is a post having some crucial information. I wish that in future such posting should go on.

Anonymous said...

Cool thank you sir, amazing how convoluted it is to use a USB drive. I don't know how you Linux guys deal with this. I'm trying to re-image a NetBackup appliance and ready to pull my hair out.

Dave said...

Years later and this is still helpful!

Ramesh chauhan said...

USB flash drives use the USB mass storage standard, supported natively by modern operating systems such as Linux, OS X, Windows, and other Unix-like systems, as well as many BIOS boot ROMs.

Memory Card - East Sky provides memory card customization services including SD card, micro SD card, SD memory card, flash memory card and cheap memory cards.

FYP said...

Worked very well, thanks.

Conniegarrick said...

I loved reading your blog. It has helped me.
Thanks.