Difference between revisions of "USB storage devices"

From ArchWiki
Jump to: navigation, search
(Added instructions for using UUID in fstab)
m (remove contractions)
Line 13: Line 13:
 
==Manual mounting==
 
==Manual mounting==
  
{{Note|Before you decide that your Arch Linux doesn't mount your USB device, be sure to check all available ports. Since some might not share the same controller, and will then not be able to mount the device.}}
+
{{Note|Before you decide that your Arch Linux does not mount your USB device, be sure to check all available ports. Since some might not share the same controller, and will then not be able to mount the device.}}
  
 
===Getting a kernel that supports usb_storage===
 
===Getting a kernel that supports usb_storage===
Line 28: Line 28:
 
*running fdisk -l as root lists all available partition tables
 
*running fdisk -l as root lists all available partition tables
 
*search in the output of {{Codeline|dmesg}} for the kernel device name, you can use {{Codeline|grep}} to help you find what you are looking for: {{Codeline|<nowiki>dmesg | grep -e "sd[a-z]"</nowiki>}}
 
*search in the output of {{Codeline|dmesg}} for the kernel device name, you can use {{Codeline|grep}} to help you find what you are looking for: {{Codeline|<nowiki>dmesg | grep -e "sd[a-z]"</nowiki>}}
{{Note|If you can't find your device you can use lsusb to verify that it is indeed recognized by the system.}}
+
{{Note|If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.}}
  
 
You also need to create the directory in which you are going to mount the device:
 
You also need to create the directory in which you are going to mount the device:
 
  # mkdir /mnt/usbstick
 
  # mkdir /mnt/usbstick
  
Finally you can mount the device as root with this command (don't forget to replace '''device_node''' by the path you found):
+
Finally you can mount the device as root with this command (do not forget to replace '''device_node''' by the path you found):
 
  # mount '''device_node''' /mnt/usbstick
 
  # mount '''device_node''' /mnt/usbstick
  
 
If {{Codeline|mount}} does not recognized the format of the device you can try to use the {{Codeline|-t}} argument, see {{Codeline|man mount}} for details.
 
If {{Codeline|mount}} does not recognized the format of the device you can try to use the {{Codeline|-t}} argument, see {{Codeline|man mount}} for details.
  
{{Note|If mounting your stick doesn't work you can try to repartition it, see [[Format a device]].}}
+
{{Note|If mounting your stick does not work you can try to repartition it, see [[Format a device]].}}
  
 
===Mounting the USB stick as normal user with mount ===
 
===Mounting the USB stick as normal user with mount ===
Line 77: Line 77:
  
 
* Reexecute '''blkid'''
 
* Reexecute '''blkid'''
''' Notice a new device and UUID? That's your USB storage'''
+
''' Notice a new device and UUID? That is your USB storage'''
  
 
* The storage likely has a label. If not use the device node path. Execute '''as superuser''':
 
* The storage likely has a label. If not use the device node path. Execute '''as superuser''':

Revision as of 06:04, 16 August 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

This document describes how to use the popular USB memory sticks with Linux. However, it is also valid for other devices such as digital cameras that act as if they were just a USB storage.

If you have an up-to-date system with the standard Arch kernel, udev and a modern Desktop Environment your device should just show up on your desktop, no need to open a console.

Otherwise see Manual mounting below.

Auto-mounting of USB devices

See Udev:Auto mounting USB devices

Manual mounting

Note: Before you decide that your Arch Linux does not mount your USB device, be sure to check all available ports. Since some might not share the same controller, and will then not be able to mount the device.

Getting a kernel that supports usb_storage

If you do not use a custom-made kernel, you are ready to go, for all Arch Linux stock kernels are properly configured. If you do use a custom-made kernel, ensure it is compiled with SCSI-Support, SCSI-Disk-Support and usb_storage. If you use the latest udev, you may just plug your device in and the system will automatically load all necessary kernel modules. Older releases of udev would need hotplug installed too. Otherwise, you can do the same thing manually:

# modprobe usb-storage
# modprobe sd_mod      (only for non SCSI kernels)

Mounting USB memory

In order to mount the device you need to know the path to the device node, there are at least two ways of finding out:

Note: If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.

You also need to create the directory in which you are going to mount the device:

# mkdir /mnt/usbstick

Finally you can mount the device as root with this command (do not forget to replace device_node by the path you found):

# mount device_node /mnt/usbstick

If Template:Codeline does not recognized the format of the device you can try to use the Template:Codeline argument, see Template:Codeline for details.

Note: If mounting your stick does not work you can try to repartition it, see Format a device.

Mounting the USB stick as normal user with mount

If you want non-root users to be able to write to the USB stick, you can issue the following command:

sudo mount -o rw,noauto,async,user,umask=1000 /dev/sda1 /mnt/usbstick

Mounting the USB stick as normal user with Fstab

If you want non-root users to be able to mount a USB memory stick via fstab, add the following line to your Template:Filename file:

/dev/sda1 /mnt/usbstick vfat rw,noauto,async,user 0 0
Note: Where /dev/sda1 is replaced with the path to your own usbstick, see Mounting USB memory.

Now, any user can mount it with:

$ mount /mnt/usbstick

And unmount it with:

$ umount /mnt/usbstick

Mounting the USB stick as normal user using Fstab with flush option

The flush option for mounting vfat has been added since kernel 2.6.19 as a replacement to async. It basically makes data to flush more often, thus making copy dialogs or progress bars to stays up until things are on the disk. [1] If you would like to utilize the flush option, add the following line to your Template:Filename file:

/dev/sda1 /mnt/usbstick vfat rw,noauto,flush,user 0 0

Mounting the USB stick using UUID

  • Every drive creates a UUID (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie Template:Filename).

To find the current UUIDs execute:

# blkid

At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.

  • Now connect your USB device and wait for a few seconds . . .
  • Reexecute blkid

Notice a new device and UUID? That is your USB storage

  • The storage likely has a label. If not use the device node path. Execute as superuser:
# blkid | grep YOURLABEL >> /etc/fstab
  • Now create an easy to remember directory listing for the device:
# mkdir /media/patriot


/dev/sdd: LABEL="patriot" UUID="E8F1-5438" TYPE="vfat"

to

UUID=E8F1-5438  /media/patriot  vfat   user,noauto,noexec  0 0