10

I am running Debian. I can plug in and view the contents of my flashdrive using filemanager under X, but how can I do this from the command line, and how can I safely remove it when I am done?

closed as off topic by finnw, Jivings, keyser, ramblinjan Jul 10 '12 at 18:19

Questions on Raspberry Pi Stack Exchange are expected to relate to raspberry pi within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

10

If you're interested in the drives mounting automatically when you plug them in then you can try installing usbmount:

sudo apt-get install usbmount

When you insert a flash drive it will detect and mount it to /media/usb[0-7] and will unmount it when it is removed.

Note:

You will want to edit your /etc/usbmount/usbmount.conf
To configure automounting as writeable for your user.

To do this, edit the FS_MOUNTOPTIONS option to match your UID.
Run id to find your UID. Example:

FS_MOUNTOPTIONS="uid=1000,gid=1000"

source

8

After plugging in your flashdrive. Run the following command:

grep "SCSI removable disk" /var/log/messages

you should see something like the following

Jun 16 23:48:58 raspberrypi kernel: sd 2:0:0:0: [sda] Attached SCSI removable disk

The important part is the bit in the square brackets, in this case "sda"

next enter the following command to create a mount point:

mkdir ~/myflashdrive

then mount the drive by entering the following command (replace the x's with the results of the grep command you ran above e.g. sda):

sudo mount -t vfat -o rw,users /dev/xxx1 ~/myflashdrive

now you can change to the directory where you mounted your flash drive using the following command:

cd ~/myflashdrive

to list the contents of the directory enter the following command:

ls -la

When you are done and want to remove the flashdrive return to your home directory with the follwoing command (you can't unmount the drive if you are currently working in one of its directories.)

cd ~

this will take you back to your home directory. you can then use the following command to unmount the drive (note the spelling of the command):

sudo umount ~/myflashdrive

you can now safely remove your flashdrive.

This applies to fat32 formatted flash drives (nearly all flash drives are fat32 formatted drives).

Not the answer you're looking for? Browse other questions tagged or ask your own question.