First open a terminal with Alt-Ctl-T.
Enter the command:
mount
and make a list of which devices are in use.
Enter the following command to keep an eye on the syslog (log of what is happening on your system from the operating system point of view).
tail -f /var/log/syslog
Now plug in and remove the flash drive. Make sure of what device it is, and that it's not one of the ones you saw mounted above. It may be something like /dev/sdc. Also see if you see the same device with a number after it, e.g. /dev/sdc1. If you see that your flash drive is being seen by your system.
Assuming it is not you can format the drive. If /dev/sdm was the drive your flash drive becomes, plug it in once again and enter:
sudo fdisk /dev/sdm
Now you can partition the device and format those partitions as you desire.
If nothing is noted on /var/log/syslog as you plug in the drive and unplug it, it is, indeed, unusable with Ubuntu.
Plug in the device
lsblk
to find the device name of your usb device. Naming is /dev/sdXY
. Where X is any english letter and Y is integer, typically 1.
If the device was mounted, you will see the mountpoint, for example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:0 1 15.2G 0 disk
└─sdb1 8:1 1 15.2G 0 part /media/me/4C45-110F
If not, mount it. Follow to the step #3
udisksctl mount -b /dev/sdXY
, device name same as in previous step. (/dev/sdb1
in my example) The mount folder will be reported back to you to use in the next step. For example, suppose lsblk
tells me this:
sdc 8:32 1 7.5G 0 disk
└─sdc1 8:33 1 7.5G 0 part
Then I will do the following:
$ udisksctl mount -b /dev/sdc1
Mounted /dev/sdc1 at /media/xieerqi/A669-34EF.
You can see it automatically created /media/xieerqi/A669-34EF
folder and mounted my pen drive there. Also , big advantage is that you do not need sudo
.
Use rsync
or cp
or mv
to get your files to the folder reported in step 3. Consult manual pages on usage of these commands. cp
and mv
are simplest. mv FILE DESTINATION
- in my example
(where FILE is the thing you want to move to the drive)
mv FILE /media/me/4C45-110F
rsync
is the best for backup however.
For example, to backup TESTDIR
to my usb drive, I can do this:
$ rsync -av /home/xieerqi/TESTDIR/ /media/xieerqi/A669-34EF/~
sending incremental file list
created directory /media/xieerqi/A669-34EF/~
./
file1
file2
file3
sent 228 bytes received 125 bytes 706.00 bytes/sec
total size is 0 speedup is 0.00
udisksctl unmount -b /dev/sdXY
. Remove the device
Example
$ udisksctl unmount -b /dev/sdc1
Unmounted /dev/sdc1.
NOTE: some drives mount to directories that have names with spaces. If you run rsync
or mv
with not quoted names like that, your data will not be copied to correct destination. Always quote pathnames that have spaces in them.
Best Answer
1. Find what the drive is called
You'll need to know what the drive is called to mount it. To do that fire off one of the following (ranked in order of my preference):
You're looking for a partition that should look something like:
/dev/sdb1
. The more disks you have the higher the letter this is likely to be. Anyway, find it and remember what it's called.2. Create a mount point (optional)
This needs to be mounted into the filesystem somewhere. You can usually use /mnt/ if you're being lazy and nothing else is mounted there but otherwise you'll want to create a new directory:
3. Mount!
When you're done, just fire off:
This answer is almost 6 years old and while the core of it still works, things like
fdisk -l
aren't the most user-friendly options. There are also new mechanisms in higher stacks for mounting devices in a sane and standard way which might not always be available.So I've added some polish from the other answers. While you're reading this footnote and you're doing this on a desktop system, there definitely are arguments for using
udisksctl
, per wecac's answer. This mounts in the same way the desktop does —creating your own/media/$USER/device
directory— but I think there are still arguments for a static mountpoint, especially when you don't want the path to change.Udisks also relies on D-Bus, so might not be available everywhere.