https://wiki.archlinux.org/api.php?action=feedcontributions&user=Alx14&feedformat=atomArchWiki - User contributions [en]2024-03-28T21:47:43ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=USB_storage_devices&diff=216692USB storage devices2012-08-06T18:43:39Z<p>Alx14: /* Auto-mounting with udev */</p>
<hr />
<div>[[Category:Storage]]<br />
[[es:USB Storage Devices]]<br />
[[it:USB Storage Devices]]<br />
[[ru:USB Storage Devices]]<br />
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.<br />
<br />
== Mounting USB devices ==<br />
If you have an up-to-date system with the standard Arch kernel and a modern [[Desktop Environment]] your device should just show up on your desktop, no need to open a console.<br />
<br />
Otherwise see sections below.<br />
<br />
=== Auto-mounting with udev ===<br />
See [[Udev#Auto mounting USB devices|Udev:Auto mounting USB devices]].<br />
<br />
A lightweight solution to automount harddrives using udev, '''for single-user systems''', is the following: create a file named {{Ic|/etc/udev/rules.d/automount.rules}} with the following content: <br />
{{bc|<nowiki>ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N"</nowiki>}}<br />
and a file (executable by root) named {{Ic|/usr/lib/udev/domount}} with (set the variables on top to the correct values):<br />
<br />
{{bc|<nowiki><br />
#!/bin/sh<br />
<br />
#edit the following variables to suit your needs<br />
MYUID=1000 # your user uid<br />
MYGID=1000 # your user gid<br />
MYLOGIN=al # your login<br />
TERM=lxterminal # your terminal emulator<br />
MYSHELL=zsh # your shell<br />
export DISPLAY=:0 # your X display<br />
<br />
<br />
TMPFILE=/run/automount.$RANDOM<br />
DIR=`cat /etc/fstab | grep -v '#' | grep $* | awk '{print $2;}'`<br />
if [ "x$DIR" = "x" ]; then<br />
MYUUID=`blkid -o value -s UUID $*`<br />
if [ "x$MYUUID" = "x" ]; then<br />
MYUUID="unknown"<br />
fi<br />
DIR=/run/media/$MYUUID<br />
fi<br />
mkdir -p /run/media<br />
mkdir -p $DIR<br />
cat > $TMPFILE << EOF<br />
#!/bin/sh<br />
echo "$* will be mounted on $DIR. "<br />
sudo mount -o uid=$MYUID,gid=$MYGID $* $DIR<br />
cd $DIR<br />
zsh<br />
cd<br />
sudo umount $DIR<br />
EOF<br />
chmod a+x $TMPFILE<br />
su $MYLOGIN -c "$TERM -t 'Terminal - $* mounted on $DIR' -e $TMPFILE"<br />
sleep 1; rm -f $TMPFILE<br />
</nowiki>}}<br />
<br />
When an harddrive is inserted, it will be mounted, and a Terminal will pop-up. To umount the device, simply press Control+D in the terminal window. The mountpoint is looked for in {{Ic|/etc/fstab}} or, if absent, generated from the UUID of the partition. <br />
<br />
To prevent your password to be asked at umount, add (replace {{Ic|you}} with your login name):<br />
<br />
{{bc|<nowiki>you ALL=(ALL) NOPASSWD: /bin/umount</nowiki>}}<br />
<br />
to {{Ic|/etc/sudoers}}.<br />
<br />
=== Manual mounting ===<br />
{{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.}}<br />
<br />
==== Getting a kernel that supports usb_storage ====<br />
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:<br />
<br />
# modprobe usb-storage<br />
# modprobe sd_mod (only for non SCSI kernels)<br />
<br />
==== Identifying device ====<br />
First thing one need to access storage device is it's identifier assigned by kernel.<br />
<br />
===== Using device node names ( /sd* ) =====<br />
This is the simplest way, but assigned name depends on order of insertion. Ways to get node name:<br />
<br />
* search in the output of {{Ic|dmesg}} for the kernel device name, you can use {{Ic|grep}} to help you find what you are looking for:<br />
$ dmesg | egrep "sd[a-z]"<br />
* running<br />
# fdisk -l<br />
lists all available partition tables.<br />
<br />
{{Note|If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.}}<br />
<br />
===== Using UUID =====<br />
Every drive creates a [[Wikipedia:UUID|UUID]] (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie {{Ic|/dev/sda}}).<br />
<br />
To find the current UUIDs execute:<br />
{{hc|# blkid -o list -c /dev/null|<nowiki><br />
device fs_type label mount point UUID<br />
------------------------------------------------------------------------------------------<br />
/dev/sda1 ext2 /boot 7f4cef7e-7ee2-489a-b759-d52ba23b692c<br />
/dev/sda2 swap (not mounted) a807fff3-e89f-46d0-ab17-9b7ad3efa7b5<br />
/dev/sda3 ext4 / 81917291-fd1a-4ffe-b95f-61c05cfba76f<br />
/dev/sda4 ext4 /home c4c23598-19fb-4562-892b-6fb18a09c7d3<br />
/dev/sdb1 ext4 X2 /mnt/X1 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdc1 ext4 X1 /mnt/X2 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdd1 ext4 Y2 /mnt/Y2 8a976a06-3e56-476f-b73a-ea3cad41d915<br />
/dev/sde1 ext4 Z2 /mnt/Z2 9d35eaae-983f-4eba-abc9-434ecd4da09c<br />
/dev/sdf1 ext4 Y1 /mnt/Y1 e2ec37a9-0689-46a8-a07b-0609ce2b7ea2<br />
/dev/sdg1 ext4 Z1 /mnt/Z1 9fa239c1-720f-42e0-8aed-39cf53a743ed<br />
/dev/sdj1 ext4 RAPT (not mounted) a9ed7ecb-96ce-40fe-92fa-e07a532ed157<br />
/dev/sdj2 swap <swap> 20826c74-eb6d-46f8-84d8-69b933a4bf3f<br />
</nowiki>}}<br />
<br />
'' At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.''<br />
<br />
* Now connect your USB device and wait for a few seconds . . . <br />
<br />
* Reexecute {{Ic|blkid -o list -c /dev/null}}<br />
'' Notice a new device and UUID? That is your USB storage''<br />
<br />
{{Tip| If {{Ic|blkid}} does not work as expected, You can look for the UUIDs in {{Ic|/dev/disk/by-uuid/}}:<br />
<br />
$ ls -lF /dev/disk/by-uuid/<br />
<br />
}}<br />
<br />
==== Mounting USB memory ====<br />
You need to create the directory in which you are going to mount the device:<br />
# mkdir /mnt/usbstick<br />
<br />
===== As root =====<br />
Mount the device as root with this command (do not forget to replace '''device_node''' by the path you found):<br />
# mount '''device_node''' /mnt/usbstick<br />
or<br />
# mount -U '''UUID''' /mnt/usbstick<br />
<br />
If {{Ic|mount}} does not recognized the format of the device you can try to use the {{Ic|-t}} argument, see {{Ic|man mount}} for details.<br />
<br />
{{Note|If mounting your stick does not work you can try to repartition it, see [[Format a device]].}}<br />
<br />
===== As normal user with mount =====<br />
If you want non-root users to be able to write to the USB stick, you can issue the following command:<br />
<br />
$ sudo mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick<br />
<br />
===== As normal user with fstab =====<br />
If you want non-root users to be able to mount a USB memory stick via [[fstab]], add the following line to your {{ic|/etc/fstab}} file:<br />
/dev/sda1 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
or better:<br />
UUID=E8F1-5438 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
(see description of '''user''' and other options in the [[Fstab|main article]])<br />
<br />
{{Note|Where {{Ic|/dev/sda1}} is replaced with the path to your own usbstick, see [[USB_Storage_Devices#Mounting_USB_memory|Mounting USB memory]].}}<br />
<br />
Now, any user can mount it with:<br />
$ mount /mnt/usbstick<br />
<br />
And unmount it with:<br />
$ umount /mnt/usbstick<br />
<br />
===== Poor copy performance to USB pendrive =====<br />
If you experienced slow copy speed to pendrive (mainly in KDE), then merge this three line to the end of your /etc/rc.local:<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/enabled<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/defrag<br />
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag<br />
And paste these at the end of your /etc/sysctl.conf<br />
kernel.shmmax=134217728<br />
vm.dirty_background_bytes = 4194304<br />
vm.dirty_bytes = 4194304<br />
And reboot. This also reduces the freezes of the KDE's panel.</div>Alx14https://wiki.archlinux.org/index.php?title=USB_storage_devices&diff=216691USB storage devices2012-08-06T18:43:02Z<p>Alx14: /* Auto-mounting with udev */</p>
<hr />
<div>[[Category:Storage]]<br />
[[es:USB Storage Devices]]<br />
[[it:USB Storage Devices]]<br />
[[ru:USB Storage Devices]]<br />
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.<br />
<br />
== Mounting USB devices ==<br />
If you have an up-to-date system with the standard Arch kernel and a modern [[Desktop Environment]] your device should just show up on your desktop, no need to open a console.<br />
<br />
Otherwise see sections below.<br />
<br />
=== Auto-mounting with udev ===<br />
See [[Udev#Auto mounting USB devices|Udev:Auto mounting USB devices]].<br />
<br />
A lightweight solution to automount harddrives using udev, for systems with only one user, is the following: create a file named {{Ic|/etc/udev/rules.d/automount.rules}} with the following content: <br />
{{bc|<nowiki>ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N"</nowiki>}}<br />
and a file (executable by root) named {{Ic|/usr/lib/udev/domount}} with (set the variables on top to the correct values):<br />
<br />
{{bc|<nowiki><br />
#!/bin/sh<br />
<br />
#edit the following variables to suit your needs<br />
MYUID=1000 # your user uid<br />
MYGID=1000 # your user gid<br />
MYLOGIN=al # your login<br />
TERM=lxterminal # your terminal emulator<br />
MYSHELL=zsh # your shell<br />
export DISPLAY=:0 # your X display<br />
<br />
<br />
TMPFILE=/run/automount.$RANDOM<br />
DIR=`cat /etc/fstab | grep -v '#' | grep $* | awk '{print $2;}'`<br />
if [ "x$DIR" = "x" ]; then<br />
MYUUID=`blkid -o value -s UUID $*`<br />
if [ "x$MYUUID" = "x" ]; then<br />
MYUUID="unknown"<br />
fi<br />
DIR=/run/media/$MYUUID<br />
fi<br />
mkdir -p /run/media<br />
mkdir -p $DIR<br />
cat > $TMPFILE << EOF<br />
#!/bin/sh<br />
echo "$* will be mounted on $DIR. "<br />
sudo mount -o uid=$MYUID,gid=$MYGID $* $DIR<br />
cd $DIR<br />
zsh<br />
cd<br />
sudo umount $DIR<br />
EOF<br />
chmod a+x $TMPFILE<br />
su $MYLOGIN -c "$TERM -t 'Terminal - $* mounted on $DIR' -e $TMPFILE"<br />
sleep 1; rm -f $TMPFILE<br />
</nowiki>}}<br />
<br />
When an harddrive is inserted, it will be mounted, and a Terminal will pop-up. To umount the device, simply press Control+D in the terminal window. The mountpoint is looked for in {{Ic|/etc/fstab}} or, if absent, generated from the UUID of the partition. <br />
<br />
To prevent your password to be asked at umount, add (replace {{Ic|you}} with your login name):<br />
<br />
{{bc|<nowiki>you ALL=(ALL) NOPASSWD: /bin/umount</nowiki>}}<br />
<br />
to {{Ic|/etc/sudoers}}.<br />
<br />
=== Manual mounting ===<br />
{{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.}}<br />
<br />
==== Getting a kernel that supports usb_storage ====<br />
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:<br />
<br />
# modprobe usb-storage<br />
# modprobe sd_mod (only for non SCSI kernels)<br />
<br />
==== Identifying device ====<br />
First thing one need to access storage device is it's identifier assigned by kernel.<br />
<br />
===== Using device node names ( /sd* ) =====<br />
This is the simplest way, but assigned name depends on order of insertion. Ways to get node name:<br />
<br />
* search in the output of {{Ic|dmesg}} for the kernel device name, you can use {{Ic|grep}} to help you find what you are looking for:<br />
$ dmesg | egrep "sd[a-z]"<br />
* running<br />
# fdisk -l<br />
lists all available partition tables.<br />
<br />
{{Note|If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.}}<br />
<br />
===== Using UUID =====<br />
Every drive creates a [[Wikipedia:UUID|UUID]] (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie {{Ic|/dev/sda}}).<br />
<br />
To find the current UUIDs execute:<br />
{{hc|# blkid -o list -c /dev/null|<nowiki><br />
device fs_type label mount point UUID<br />
------------------------------------------------------------------------------------------<br />
/dev/sda1 ext2 /boot 7f4cef7e-7ee2-489a-b759-d52ba23b692c<br />
/dev/sda2 swap (not mounted) a807fff3-e89f-46d0-ab17-9b7ad3efa7b5<br />
/dev/sda3 ext4 / 81917291-fd1a-4ffe-b95f-61c05cfba76f<br />
/dev/sda4 ext4 /home c4c23598-19fb-4562-892b-6fb18a09c7d3<br />
/dev/sdb1 ext4 X2 /mnt/X1 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdc1 ext4 X1 /mnt/X2 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdd1 ext4 Y2 /mnt/Y2 8a976a06-3e56-476f-b73a-ea3cad41d915<br />
/dev/sde1 ext4 Z2 /mnt/Z2 9d35eaae-983f-4eba-abc9-434ecd4da09c<br />
/dev/sdf1 ext4 Y1 /mnt/Y1 e2ec37a9-0689-46a8-a07b-0609ce2b7ea2<br />
/dev/sdg1 ext4 Z1 /mnt/Z1 9fa239c1-720f-42e0-8aed-39cf53a743ed<br />
/dev/sdj1 ext4 RAPT (not mounted) a9ed7ecb-96ce-40fe-92fa-e07a532ed157<br />
/dev/sdj2 swap <swap> 20826c74-eb6d-46f8-84d8-69b933a4bf3f<br />
</nowiki>}}<br />
<br />
'' At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.''<br />
<br />
* Now connect your USB device and wait for a few seconds . . . <br />
<br />
* Reexecute {{Ic|blkid -o list -c /dev/null}}<br />
'' Notice a new device and UUID? That is your USB storage''<br />
<br />
{{Tip| If {{Ic|blkid}} does not work as expected, You can look for the UUIDs in {{Ic|/dev/disk/by-uuid/}}:<br />
<br />
$ ls -lF /dev/disk/by-uuid/<br />
<br />
}}<br />
<br />
==== Mounting USB memory ====<br />
You need to create the directory in which you are going to mount the device:<br />
# mkdir /mnt/usbstick<br />
<br />
===== As root =====<br />
Mount the device as root with this command (do not forget to replace '''device_node''' by the path you found):<br />
# mount '''device_node''' /mnt/usbstick<br />
or<br />
# mount -U '''UUID''' /mnt/usbstick<br />
<br />
If {{Ic|mount}} does not recognized the format of the device you can try to use the {{Ic|-t}} argument, see {{Ic|man mount}} for details.<br />
<br />
{{Note|If mounting your stick does not work you can try to repartition it, see [[Format a device]].}}<br />
<br />
===== As normal user with mount =====<br />
If you want non-root users to be able to write to the USB stick, you can issue the following command:<br />
<br />
$ sudo mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick<br />
<br />
===== As normal user with fstab =====<br />
If you want non-root users to be able to mount a USB memory stick via [[fstab]], add the following line to your {{ic|/etc/fstab}} file:<br />
/dev/sda1 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
or better:<br />
UUID=E8F1-5438 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
(see description of '''user''' and other options in the [[Fstab|main article]])<br />
<br />
{{Note|Where {{Ic|/dev/sda1}} is replaced with the path to your own usbstick, see [[USB_Storage_Devices#Mounting_USB_memory|Mounting USB memory]].}}<br />
<br />
Now, any user can mount it with:<br />
$ mount /mnt/usbstick<br />
<br />
And unmount it with:<br />
$ umount /mnt/usbstick<br />
<br />
===== Poor copy performance to USB pendrive =====<br />
If you experienced slow copy speed to pendrive (mainly in KDE), then merge this three line to the end of your /etc/rc.local:<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/enabled<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/defrag<br />
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag<br />
And paste these at the end of your /etc/sysctl.conf<br />
kernel.shmmax=134217728<br />
vm.dirty_background_bytes = 4194304<br />
vm.dirty_bytes = 4194304<br />
And reboot. This also reduces the freezes of the KDE's panel.</div>Alx14https://wiki.archlinux.org/index.php?title=USB_storage_devices&diff=216679USB storage devices2012-08-06T15:17:00Z<p>Alx14: /* Auto-mounting with udev */</p>
<hr />
<div>[[Category:Storage]]<br />
[[es:USB Storage Devices]]<br />
[[it:USB Storage Devices]]<br />
[[ru:USB Storage Devices]]<br />
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.<br />
<br />
== Mounting USB devices ==<br />
If you have an up-to-date system with the standard Arch kernel and a modern [[Desktop Environment]] your device should just show up on your desktop, no need to open a console.<br />
<br />
Otherwise see sections below.<br />
<br />
=== Auto-mounting with udev ===<br />
See [[Udev#Auto mounting USB devices|Udev:Auto mounting USB devices]].<br />
<br />
A lightweight solution to automount harddrives using udev, for systems with only one user, is the following: create a file named {{Ic|/etc/udev/rules.d/automount.rules}} with the following content:<br />
{{bc|<nowiki>ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N"</nowiki>}}<br />
and a file (executable by root) named {{Ic|/usr/lib/udev/domount}} with:<br />
<br />
{{bc|<nowiki>#!/bin/sh<br />
<br />
export DISPLAY=:0<br />
DIR=`cat /etc/fstab|grep $*|awk '{print $2;}'`<br />
if [ "x$DIR" = "x" ]; then<br />
DIR=/run/media/`blkid -o value -s UUID $*` <br />
fi<br />
mkdir -p /run/media<br />
mkdir -p $DIR<br />
mount -o uid=1000,gid=1000,users $* $DIR<br />
cat > /tmp/script << EOF<br />
#!/bin/sh<br />
cd $DIR<br />
zsh<br />
cd<br />
sudo umount $DIR<br />
EOF<br />
chmod a+x /tmp/script<br />
su al -c 'lxterminal -e /tmp/script'<br />
sleep 1; rm -f /tmp/script</nowiki>}}<br />
<br />
(replace the {{Ic|1000}} with your UID and GID, {{Ic|lxterminal}} with your favorite terminal emulator, and {{Ic|zsh}} with your shell).<br />
<br />
When an harddrive is inserted, it will be mounted, and a Terminal will pop-up. To umount the device, simply press Control+D in the terminal window. The mountpoint is looked for in {{Ic|/etc/fstab}} or, if absent, generated from the UUID of the partition. <br />
<br />
To prevent your password to be asked at umount, add (replace {{Ic|you}} with your login name):<br />
<br />
{{bc|<nowiki>you ALL=(ALL) NOPASSWD: /bin/umount</nowiki>}}<br />
<br />
to {{Ic|/etc/sudoers}}.<br />
<br />
=== Manual mounting ===<br />
{{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.}}<br />
<br />
==== Getting a kernel that supports usb_storage ====<br />
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:<br />
<br />
# modprobe usb-storage<br />
# modprobe sd_mod (only for non SCSI kernels)<br />
<br />
==== Identifying device ====<br />
First thing one need to access storage device is it's identifier assigned by kernel.<br />
<br />
===== Using device node names ( /sd* ) =====<br />
This is the simplest way, but assigned name depends on order of insertion. Ways to get node name:<br />
<br />
* search in the output of {{Ic|dmesg}} for the kernel device name, you can use {{Ic|grep}} to help you find what you are looking for:<br />
$ dmesg | egrep "sd[a-z]"<br />
* running<br />
# fdisk -l<br />
lists all available partition tables.<br />
<br />
{{Note|If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.}}<br />
<br />
===== Using UUID =====<br />
Every drive creates a [[Wikipedia:UUID|UUID]] (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie {{Ic|/dev/sda}}).<br />
<br />
To find the current UUIDs execute:<br />
{{hc|# blkid -o list -c /dev/null|<nowiki><br />
device fs_type label mount point UUID<br />
------------------------------------------------------------------------------------------<br />
/dev/sda1 ext2 /boot 7f4cef7e-7ee2-489a-b759-d52ba23b692c<br />
/dev/sda2 swap (not mounted) a807fff3-e89f-46d0-ab17-9b7ad3efa7b5<br />
/dev/sda3 ext4 / 81917291-fd1a-4ffe-b95f-61c05cfba76f<br />
/dev/sda4 ext4 /home c4c23598-19fb-4562-892b-6fb18a09c7d3<br />
/dev/sdb1 ext4 X2 /mnt/X1 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdc1 ext4 X1 /mnt/X2 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdd1 ext4 Y2 /mnt/Y2 8a976a06-3e56-476f-b73a-ea3cad41d915<br />
/dev/sde1 ext4 Z2 /mnt/Z2 9d35eaae-983f-4eba-abc9-434ecd4da09c<br />
/dev/sdf1 ext4 Y1 /mnt/Y1 e2ec37a9-0689-46a8-a07b-0609ce2b7ea2<br />
/dev/sdg1 ext4 Z1 /mnt/Z1 9fa239c1-720f-42e0-8aed-39cf53a743ed<br />
/dev/sdj1 ext4 RAPT (not mounted) a9ed7ecb-96ce-40fe-92fa-e07a532ed157<br />
/dev/sdj2 swap <swap> 20826c74-eb6d-46f8-84d8-69b933a4bf3f<br />
</nowiki>}}<br />
<br />
'' At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.''<br />
<br />
* Now connect your USB device and wait for a few seconds . . . <br />
<br />
* Reexecute {{Ic|blkid -o list -c /dev/null}}<br />
'' Notice a new device and UUID? That is your USB storage''<br />
<br />
{{Tip| If {{Ic|blkid}} does not work as expected, You can look for the UUIDs in {{Ic|/dev/disk/by-uuid/}}:<br />
<br />
$ ls -lF /dev/disk/by-uuid/<br />
<br />
}}<br />
<br />
==== Mounting USB memory ====<br />
You need to create the directory in which you are going to mount the device:<br />
# mkdir /mnt/usbstick<br />
<br />
===== As root =====<br />
Mount the device as root with this command (do not forget to replace '''device_node''' by the path you found):<br />
# mount '''device_node''' /mnt/usbstick<br />
or<br />
# mount -U '''UUID''' /mnt/usbstick<br />
<br />
If {{Ic|mount}} does not recognized the format of the device you can try to use the {{Ic|-t}} argument, see {{Ic|man mount}} for details.<br />
<br />
{{Note|If mounting your stick does not work you can try to repartition it, see [[Format a device]].}}<br />
<br />
===== As normal user with mount =====<br />
If you want non-root users to be able to write to the USB stick, you can issue the following command:<br />
<br />
$ sudo mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick<br />
<br />
===== As normal user with fstab =====<br />
If you want non-root users to be able to mount a USB memory stick via [[fstab]], add the following line to your {{ic|/etc/fstab}} file:<br />
/dev/sda1 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
or better:<br />
UUID=E8F1-5438 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
(see description of '''user''' and other options in the [[Fstab|main article]])<br />
<br />
{{Note|Where {{Ic|/dev/sda1}} is replaced with the path to your own usbstick, see [[USB_Storage_Devices#Mounting_USB_memory|Mounting USB memory]].}}<br />
<br />
Now, any user can mount it with:<br />
$ mount /mnt/usbstick<br />
<br />
And unmount it with:<br />
$ umount /mnt/usbstick<br />
<br />
===== Poor copy performance to USB pendrive =====<br />
If you experienced slow copy speed to pendrive (mainly in KDE), then merge this three line to the end of your /etc/rc.local:<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/enabled<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/defrag<br />
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag<br />
And paste these at the end of your /etc/sysctl.conf<br />
kernel.shmmax=134217728<br />
vm.dirty_background_bytes = 4194304<br />
vm.dirty_bytes = 4194304<br />
And reboot. This also reduces the freezes of the KDE's panel.</div>Alx14https://wiki.archlinux.org/index.php?title=USB_storage_devices&diff=216678USB storage devices2012-08-06T15:16:41Z<p>Alx14: </p>
<hr />
<div>[[Category:Storage]]<br />
[[es:USB Storage Devices]]<br />
[[it:USB Storage Devices]]<br />
[[ru:USB Storage Devices]]<br />
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.<br />
<br />
== Mounting USB devices ==<br />
If you have an up-to-date system with the standard Arch kernel and a modern [[Desktop Environment]] your device should just show up on your desktop, no need to open a console.<br />
<br />
Otherwise see sections below.<br />
<br />
=== Auto-mounting with udev ===<br />
See [[Udev#Auto mounting USB devices|Udev:Auto mounting USB devices]].<br />
<br />
A lightweight solution to automount harddrives using udev, for systems with only one user, is the following: create a file named {{Ic|/etc/udev/rules.d/automount.rules}} with the following content:<br />
{{bc|<nowiki>ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N"</nowiki>}}<br />
and a file (executable by root) named {{Ic|/usr/lib/udev/domount}} with:<br />
<br />
{{bc|<nowiki>#!/bin/sh<br />
<br />
export DISPLAY=:0<br />
DIR=`cat /etc/fstab|grep $*|awk '{print $2;}'`<br />
if [ "x$DIR" = "x" ]; then<br />
DIR=/run/media/`blkid -o value -s UUID $*` <br />
fi<br />
mkdir -p /run/media<br />
mkdir -p $DIR<br />
mount -o uid=1000,gid=1000,users $* $DIR<br />
cat > /tmp/script << EOF<br />
#!/bin/sh<br />
cd $DIR<br />
zsh<br />
cd<br />
sudo umount $DIR<br />
EOF<br />
chmod a+x /tmp/script<br />
su al -c 'lxterminal -e /tmp/script'<br />
sleep 1; rm -f /tmp/script</nowiki>}}<br />
<br />
(replace the {{Ic|1000}} with your UID and GID, {{Ic|lxterminal}} with your favorite terminal emulator, and {{Ic|zsh}} with your shell).<br />
<br />
When an harddrive is inserted, it will be mounted, and a Terminal will pop-up. To umount the device, simply press Control+D in the terminal window. The mountpoint is looked for in {{Ic|/etc/fstab}} or, if absent, generated from the UUID of the device. <br />
<br />
To prevent your password to be asked at umount, add (replace {{Ic|you}} with your login name):<br />
<br />
{{bc|<nowiki>you ALL=(ALL) NOPASSWD: /bin/umount</nowiki>}}<br />
<br />
to {{Ic|/etc/sudoers}}.<br />
<br />
=== Manual mounting ===<br />
{{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.}}<br />
<br />
==== Getting a kernel that supports usb_storage ====<br />
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:<br />
<br />
# modprobe usb-storage<br />
# modprobe sd_mod (only for non SCSI kernels)<br />
<br />
==== Identifying device ====<br />
First thing one need to access storage device is it's identifier assigned by kernel.<br />
<br />
===== Using device node names ( /sd* ) =====<br />
This is the simplest way, but assigned name depends on order of insertion. Ways to get node name:<br />
<br />
* search in the output of {{Ic|dmesg}} for the kernel device name, you can use {{Ic|grep}} to help you find what you are looking for:<br />
$ dmesg | egrep "sd[a-z]"<br />
* running<br />
# fdisk -l<br />
lists all available partition tables.<br />
<br />
{{Note|If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.}}<br />
<br />
===== Using UUID =====<br />
Every drive creates a [[Wikipedia:UUID|UUID]] (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie {{Ic|/dev/sda}}).<br />
<br />
To find the current UUIDs execute:<br />
{{hc|# blkid -o list -c /dev/null|<nowiki><br />
device fs_type label mount point UUID<br />
------------------------------------------------------------------------------------------<br />
/dev/sda1 ext2 /boot 7f4cef7e-7ee2-489a-b759-d52ba23b692c<br />
/dev/sda2 swap (not mounted) a807fff3-e89f-46d0-ab17-9b7ad3efa7b5<br />
/dev/sda3 ext4 / 81917291-fd1a-4ffe-b95f-61c05cfba76f<br />
/dev/sda4 ext4 /home c4c23598-19fb-4562-892b-6fb18a09c7d3<br />
/dev/sdb1 ext4 X2 /mnt/X1 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdc1 ext4 X1 /mnt/X2 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdd1 ext4 Y2 /mnt/Y2 8a976a06-3e56-476f-b73a-ea3cad41d915<br />
/dev/sde1 ext4 Z2 /mnt/Z2 9d35eaae-983f-4eba-abc9-434ecd4da09c<br />
/dev/sdf1 ext4 Y1 /mnt/Y1 e2ec37a9-0689-46a8-a07b-0609ce2b7ea2<br />
/dev/sdg1 ext4 Z1 /mnt/Z1 9fa239c1-720f-42e0-8aed-39cf53a743ed<br />
/dev/sdj1 ext4 RAPT (not mounted) a9ed7ecb-96ce-40fe-92fa-e07a532ed157<br />
/dev/sdj2 swap <swap> 20826c74-eb6d-46f8-84d8-69b933a4bf3f<br />
</nowiki>}}<br />
<br />
'' At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.''<br />
<br />
* Now connect your USB device and wait for a few seconds . . . <br />
<br />
* Reexecute {{Ic|blkid -o list -c /dev/null}}<br />
'' Notice a new device and UUID? That is your USB storage''<br />
<br />
{{Tip| If {{Ic|blkid}} does not work as expected, You can look for the UUIDs in {{Ic|/dev/disk/by-uuid/}}:<br />
<br />
$ ls -lF /dev/disk/by-uuid/<br />
<br />
}}<br />
<br />
==== Mounting USB memory ====<br />
You need to create the directory in which you are going to mount the device:<br />
# mkdir /mnt/usbstick<br />
<br />
===== As root =====<br />
Mount the device as root with this command (do not forget to replace '''device_node''' by the path you found):<br />
# mount '''device_node''' /mnt/usbstick<br />
or<br />
# mount -U '''UUID''' /mnt/usbstick<br />
<br />
If {{Ic|mount}} does not recognized the format of the device you can try to use the {{Ic|-t}} argument, see {{Ic|man mount}} for details.<br />
<br />
{{Note|If mounting your stick does not work you can try to repartition it, see [[Format a device]].}}<br />
<br />
===== As normal user with mount =====<br />
If you want non-root users to be able to write to the USB stick, you can issue the following command:<br />
<br />
$ sudo mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick<br />
<br />
===== As normal user with fstab =====<br />
If you want non-root users to be able to mount a USB memory stick via [[fstab]], add the following line to your {{ic|/etc/fstab}} file:<br />
/dev/sda1 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
or better:<br />
UUID=E8F1-5438 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
(see description of '''user''' and other options in the [[Fstab|main article]])<br />
<br />
{{Note|Where {{Ic|/dev/sda1}} is replaced with the path to your own usbstick, see [[USB_Storage_Devices#Mounting_USB_memory|Mounting USB memory]].}}<br />
<br />
Now, any user can mount it with:<br />
$ mount /mnt/usbstick<br />
<br />
And unmount it with:<br />
$ umount /mnt/usbstick<br />
<br />
===== Poor copy performance to USB pendrive =====<br />
If you experienced slow copy speed to pendrive (mainly in KDE), then merge this three line to the end of your /etc/rc.local:<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/enabled<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/defrag<br />
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag<br />
And paste these at the end of your /etc/sysctl.conf<br />
kernel.shmmax=134217728<br />
vm.dirty_background_bytes = 4194304<br />
vm.dirty_bytes = 4194304<br />
And reboot. This also reduces the freezes of the KDE's panel.</div>Alx14https://wiki.archlinux.org/index.php?title=USB_storage_devices&diff=216677USB storage devices2012-08-06T15:12:56Z<p>Alx14: </p>
<hr />
<div>[[Category:Storage]]<br />
[[es:USB Storage Devices]]<br />
[[it:USB Storage Devices]]<br />
[[ru:USB Storage Devices]]<br />
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.<br />
<br />
== Mounting USB devices ==<br />
If you have an up-to-date system with the standard Arch kernel and a modern [[Desktop Environment]] your device should just show up on your desktop, no need to open a console.<br />
<br />
Otherwise see sections below.<br />
<br />
=== Auto-mounting with udev ===<br />
See [[Udev#Auto mounting USB devices|Udev:Auto mounting USB devices]].<br />
<br />
A lightweight solution to automount harddrives using udev, for systems with only one user, is the following: create a file named {{Ic|/etc/udev/rules.d/automount.rules}} with the following content:<br />
{{bc|<nowiki>ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N"</nowiki>}}<br />
and a file (executable by root) named {{Ic|/usr/lib/udev/domount}} with:<br />
<br />
{{bc|<nowiki>#!/bin/sh<br />
<br />
export DISPLAY=:0<br />
DIR=`cat /etc/fstab|grep $*|awk '{print $2;}'`<br />
if [ "x$DIR" = "x" ]; then<br />
DIR=/run/media/`blkid -o value -s UUID $*` <br />
fi<br />
mkdir -p /run/media<br />
mkdir -p $DIR<br />
mount -o uid=1000,gid=1000,users $* $DIR<br />
cat > /tmp/script << EOF<br />
#!/bin/sh<br />
cd $DIR<br />
zsh<br />
cd<br />
sudo umount $DIR<br />
EOF<br />
chmod a+x /tmp/script<br />
su al -c 'lxterminal -e /tmp/script'<br />
sleep 1; rm -f /tmp/script</nowiki>}}<br />
<br />
(replace the 1000 with your UID and GID, lxterminal with your favorite terminal emulator, and zsh with your shell).<br />
<br />
When an harddrive is inserted, it will be mounted, and a Terminal will pop-up. To umount the device, simply press Control+D in the terminal window. To prevent your password to be asked at umount, add (replace {{Ic|you}} with your login name):<br />
<br />
{{bc|<nowiki>you ALL=(ALL) NOPASSWD: /bin/umount</nowiki>}}<br />
<br />
to {{Ic|/etc/sudoers}}.<br />
<br />
<br />
<br />
<br />
=== Manual mounting ===<br />
{{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.}}<br />
<br />
==== Getting a kernel that supports usb_storage ====<br />
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:<br />
<br />
# modprobe usb-storage<br />
# modprobe sd_mod (only for non SCSI kernels)<br />
<br />
==== Identifying device ====<br />
First thing one need to access storage device is it's identifier assigned by kernel.<br />
<br />
===== Using device node names ( /sd* ) =====<br />
This is the simplest way, but assigned name depends on order of insertion. Ways to get node name:<br />
<br />
* search in the output of {{Ic|dmesg}} for the kernel device name, you can use {{Ic|grep}} to help you find what you are looking for:<br />
$ dmesg | egrep "sd[a-z]"<br />
* running<br />
# fdisk -l<br />
lists all available partition tables.<br />
<br />
{{Note|If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.}}<br />
<br />
===== Using UUID =====<br />
Every drive creates a [[Wikipedia:UUID|UUID]] (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie {{Ic|/dev/sda}}).<br />
<br />
To find the current UUIDs execute:<br />
{{hc|# blkid -o list -c /dev/null|<nowiki><br />
device fs_type label mount point UUID<br />
------------------------------------------------------------------------------------------<br />
/dev/sda1 ext2 /boot 7f4cef7e-7ee2-489a-b759-d52ba23b692c<br />
/dev/sda2 swap (not mounted) a807fff3-e89f-46d0-ab17-9b7ad3efa7b5<br />
/dev/sda3 ext4 / 81917291-fd1a-4ffe-b95f-61c05cfba76f<br />
/dev/sda4 ext4 /home c4c23598-19fb-4562-892b-6fb18a09c7d3<br />
/dev/sdb1 ext4 X2 /mnt/X1 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdc1 ext4 X1 /mnt/X2 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdd1 ext4 Y2 /mnt/Y2 8a976a06-3e56-476f-b73a-ea3cad41d915<br />
/dev/sde1 ext4 Z2 /mnt/Z2 9d35eaae-983f-4eba-abc9-434ecd4da09c<br />
/dev/sdf1 ext4 Y1 /mnt/Y1 e2ec37a9-0689-46a8-a07b-0609ce2b7ea2<br />
/dev/sdg1 ext4 Z1 /mnt/Z1 9fa239c1-720f-42e0-8aed-39cf53a743ed<br />
/dev/sdj1 ext4 RAPT (not mounted) a9ed7ecb-96ce-40fe-92fa-e07a532ed157<br />
/dev/sdj2 swap <swap> 20826c74-eb6d-46f8-84d8-69b933a4bf3f<br />
</nowiki>}}<br />
<br />
'' At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.''<br />
<br />
* Now connect your USB device and wait for a few seconds . . . <br />
<br />
* Reexecute {{Ic|blkid -o list -c /dev/null}}<br />
'' Notice a new device and UUID? That is your USB storage''<br />
<br />
{{Tip| If {{Ic|blkid}} does not work as expected, You can look for the UUIDs in {{Ic|/dev/disk/by-uuid/}}:<br />
<br />
$ ls -lF /dev/disk/by-uuid/<br />
<br />
}}<br />
<br />
==== Mounting USB memory ====<br />
You need to create the directory in which you are going to mount the device:<br />
# mkdir /mnt/usbstick<br />
<br />
===== As root =====<br />
Mount the device as root with this command (do not forget to replace '''device_node''' by the path you found):<br />
# mount '''device_node''' /mnt/usbstick<br />
or<br />
# mount -U '''UUID''' /mnt/usbstick<br />
<br />
If {{Ic|mount}} does not recognized the format of the device you can try to use the {{Ic|-t}} argument, see {{Ic|man mount}} for details.<br />
<br />
{{Note|If mounting your stick does not work you can try to repartition it, see [[Format a device]].}}<br />
<br />
===== As normal user with mount =====<br />
If you want non-root users to be able to write to the USB stick, you can issue the following command:<br />
<br />
$ sudo mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick<br />
<br />
===== As normal user with fstab =====<br />
If you want non-root users to be able to mount a USB memory stick via [[fstab]], add the following line to your {{ic|/etc/fstab}} file:<br />
/dev/sda1 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
or better:<br />
UUID=E8F1-5438 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
(see description of '''user''' and other options in the [[Fstab|main article]])<br />
<br />
{{Note|Where {{Ic|/dev/sda1}} is replaced with the path to your own usbstick, see [[USB_Storage_Devices#Mounting_USB_memory|Mounting USB memory]].}}<br />
<br />
Now, any user can mount it with:<br />
$ mount /mnt/usbstick<br />
<br />
And unmount it with:<br />
$ umount /mnt/usbstick<br />
<br />
===== Poor copy performance to USB pendrive =====<br />
If you experienced slow copy speed to pendrive (mainly in KDE), then merge this three line to the end of your /etc/rc.local:<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/enabled<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/defrag<br />
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag<br />
And paste these at the end of your /etc/sysctl.conf<br />
kernel.shmmax=134217728<br />
vm.dirty_background_bytes = 4194304<br />
vm.dirty_bytes = 4194304<br />
And reboot. This also reduces the freezes of the KDE's panel.</div>Alx14https://wiki.archlinux.org/index.php?title=USB_storage_devices&diff=216675USB storage devices2012-08-06T15:10:54Z<p>Alx14: </p>
<hr />
<div>[[Category:Storage]]<br />
[[es:USB Storage Devices]]<br />
[[it:USB Storage Devices]]<br />
[[ru:USB Storage Devices]]<br />
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.<br />
<br />
== Mounting USB devices ==<br />
If you have an up-to-date system with the standard Arch kernel and a modern [[Desktop Environment]] your device should just show up on your desktop, no need to open a console.<br />
<br />
Otherwise see sections below.<br />
<br />
=== Auto-mounting with udev ===<br />
See [[Udev#Auto mounting USB devices|Udev:Auto mounting USB devices]].<br />
<br />
A lightweight solution to automount harddrives using udev, for systems with only one user, is the following: create a file named {{Ic|/etc/udev/rules.d/automount.rules}} with the following content:<br />
{{hc|<nowiki>ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N"</nowiki>}}<br />
and a file (executable by root) named {{Ic|/usr/lib/udev/domount}} with:<br />
<br />
{{hc|<nowiki>#!/bin/sh<br />
<br />
export DISPLAY=:0<br />
DIR=`cat /etc/fstab|grep $*|awk '{print $2;}'`<br />
if [ "x$DIR" = "x" ]; then<br />
DIR=/run/media/`blkid -o value -s UUID $*` <br />
fi<br />
mkdir -p /run/media<br />
mkdir -p $DIR<br />
mount -o uid=1000,gid=1000,users $* $DIR<br />
cat > /tmp/script << EOF<br />
#!/bin/sh<br />
cd $DIR<br />
zsh<br />
cd<br />
sudo umount $DIR<br />
EOF<br />
chmod a+x /tmp/script<br />
su al -c 'lxterminal -e /tmp/script'<br />
sleep 1; rm -f /tmp/script</nowiki>}}<br />
<br />
(replace the 1000 with your UID and GID, lxterminal with your favorite terminal emulator, and zsh with your shell).<br />
<br />
When an harddrive is inserted, it will be mounted, and a Terminal will pop-up. To umount the device, simply press Control+D in the terminal window. To prevent your password to be asked at umount, add (replace {{Ic|you}} with your login name):<br />
<br />
{{hc|<nowiki>you ALL=(ALL) NOPASSWD: /bin/umount</nowiki>}}<br />
<br />
to {{Ic|/etc/sudoers}}.<br />
<br />
<br />
<br />
<br />
=== Manual mounting ===<br />
{{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.}}<br />
<br />
==== Getting a kernel that supports usb_storage ====<br />
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:<br />
<br />
# modprobe usb-storage<br />
# modprobe sd_mod (only for non SCSI kernels)<br />
<br />
==== Identifying device ====<br />
First thing one need to access storage device is it's identifier assigned by kernel.<br />
<br />
===== Using device node names ( /sd* ) =====<br />
This is the simplest way, but assigned name depends on order of insertion. Ways to get node name:<br />
<br />
* search in the output of {{Ic|dmesg}} for the kernel device name, you can use {{Ic|grep}} to help you find what you are looking for:<br />
$ dmesg | egrep "sd[a-z]"<br />
* running<br />
# fdisk -l<br />
lists all available partition tables.<br />
<br />
{{Note|If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.}}<br />
<br />
===== Using UUID =====<br />
Every drive creates a [[Wikipedia:UUID|UUID]] (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie {{Ic|/dev/sda}}).<br />
<br />
To find the current UUIDs execute:<br />
{{hc|# blkid -o list -c /dev/null|<nowiki><br />
device fs_type label mount point UUID<br />
------------------------------------------------------------------------------------------<br />
/dev/sda1 ext2 /boot 7f4cef7e-7ee2-489a-b759-d52ba23b692c<br />
/dev/sda2 swap (not mounted) a807fff3-e89f-46d0-ab17-9b7ad3efa7b5<br />
/dev/sda3 ext4 / 81917291-fd1a-4ffe-b95f-61c05cfba76f<br />
/dev/sda4 ext4 /home c4c23598-19fb-4562-892b-6fb18a09c7d3<br />
/dev/sdb1 ext4 X2 /mnt/X1 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdc1 ext4 X1 /mnt/X2 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdd1 ext4 Y2 /mnt/Y2 8a976a06-3e56-476f-b73a-ea3cad41d915<br />
/dev/sde1 ext4 Z2 /mnt/Z2 9d35eaae-983f-4eba-abc9-434ecd4da09c<br />
/dev/sdf1 ext4 Y1 /mnt/Y1 e2ec37a9-0689-46a8-a07b-0609ce2b7ea2<br />
/dev/sdg1 ext4 Z1 /mnt/Z1 9fa239c1-720f-42e0-8aed-39cf53a743ed<br />
/dev/sdj1 ext4 RAPT (not mounted) a9ed7ecb-96ce-40fe-92fa-e07a532ed157<br />
/dev/sdj2 swap <swap> 20826c74-eb6d-46f8-84d8-69b933a4bf3f<br />
</nowiki>}}<br />
<br />
'' At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.''<br />
<br />
* Now connect your USB device and wait for a few seconds . . . <br />
<br />
* Reexecute {{Ic|blkid -o list -c /dev/null}}<br />
'' Notice a new device and UUID? That is your USB storage''<br />
<br />
{{Tip| If {{Ic|blkid}} does not work as expected, You can look for the UUIDs in {{Ic|/dev/disk/by-uuid/}}:<br />
<br />
$ ls -lF /dev/disk/by-uuid/<br />
<br />
}}<br />
<br />
==== Mounting USB memory ====<br />
You need to create the directory in which you are going to mount the device:<br />
# mkdir /mnt/usbstick<br />
<br />
===== As root =====<br />
Mount the device as root with this command (do not forget to replace '''device_node''' by the path you found):<br />
# mount '''device_node''' /mnt/usbstick<br />
or<br />
# mount -U '''UUID''' /mnt/usbstick<br />
<br />
If {{Ic|mount}} does not recognized the format of the device you can try to use the {{Ic|-t}} argument, see {{Ic|man mount}} for details.<br />
<br />
{{Note|If mounting your stick does not work you can try to repartition it, see [[Format a device]].}}<br />
<br />
===== As normal user with mount =====<br />
If you want non-root users to be able to write to the USB stick, you can issue the following command:<br />
<br />
$ sudo mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick<br />
<br />
===== As normal user with fstab =====<br />
If you want non-root users to be able to mount a USB memory stick via [[fstab]], add the following line to your {{ic|/etc/fstab}} file:<br />
/dev/sda1 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
or better:<br />
UUID=E8F1-5438 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
(see description of '''user''' and other options in the [[Fstab|main article]])<br />
<br />
{{Note|Where {{Ic|/dev/sda1}} is replaced with the path to your own usbstick, see [[USB_Storage_Devices#Mounting_USB_memory|Mounting USB memory]].}}<br />
<br />
Now, any user can mount it with:<br />
$ mount /mnt/usbstick<br />
<br />
And unmount it with:<br />
$ umount /mnt/usbstick<br />
<br />
===== Poor copy performance to USB pendrive =====<br />
If you experienced slow copy speed to pendrive (mainly in KDE), then merge this three line to the end of your /etc/rc.local:<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/enabled<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/defrag<br />
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag<br />
And paste these at the end of your /etc/sysctl.conf<br />
kernel.shmmax=134217728<br />
vm.dirty_background_bytes = 4194304<br />
vm.dirty_bytes = 4194304<br />
And reboot. This also reduces the freezes of the KDE's panel.</div>Alx14https://wiki.archlinux.org/index.php?title=USB_storage_devices&diff=216673USB storage devices2012-08-06T15:05:48Z<p>Alx14: </p>
<hr />
<div>[[Category:Storage]]<br />
[[es:USB Storage Devices]]<br />
[[it:USB Storage Devices]]<br />
[[ru:USB Storage Devices]]<br />
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.<br />
<br />
== Mounting USB devices ==<br />
If you have an up-to-date system with the standard Arch kernel and a modern [[Desktop Environment]] your device should just show up on your desktop, no need to open a console.<br />
<br />
Otherwise see sections below.<br />
<br />
=== Auto-mounting with udev ===<br />
See [[Udev#Auto mounting USB devices|Udev:Auto mounting USB devices]].<br />
<br />
A lightweight solution to automount harddrives using udev, for systems with only one user, is the following: create a file named {{Ic|/etc/udev/rules.d/automount.rules}} with the following content:<br />
{{hc|<nowiki>ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N"</nowiki>}}<br />
and a file (executable by root) named {{Ic|/usr/lib/udev/domount}} with:<br />
<br />
{{hc|<nowiki>#!/bin/sh<br />
<br />
export DISPLAY=:0<br />
DIR=`cat /etc/fstab|grep $*|awk '{print $2;}'`<br />
if [ "x$DIR" = "x" ]; then<br />
DIR=/run/media/`blkid -o value -s UUID $*` <br />
fi<br />
mkdir -p /run/media<br />
mkdir -p $DIR<br />
mount -o uid=1000,gid=1000,users $* $DIR<br />
cat > /tmp/script << EOF<br />
#!/bin/sh<br />
cd $DIR<br />
zsh<br />
cd<br />
sudo umount $DIR<br />
EOF<br />
chmod a+x /tmp/script<br />
su al -c 'lxterminal -e /tmp/script'<br />
sleep 1; rm -f /tmp/script</nowiki>}}<br />
<br />
(replace the 1000 with your UID and GID, lxterminal with your favorite terminal emulator, and zsh with your shell).<br />
<br />
When an harddrive is inserted, it will be mounted, and a Terminal will pop-up. To umount the device, simply press Control+D in the terminal window. <br />
<br />
<br />
<br />
=== Manual mounting ===<br />
{{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.}}<br />
<br />
==== Getting a kernel that supports usb_storage ====<br />
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:<br />
<br />
# modprobe usb-storage<br />
# modprobe sd_mod (only for non SCSI kernels)<br />
<br />
==== Identifying device ====<br />
First thing one need to access storage device is it's identifier assigned by kernel.<br />
<br />
===== Using device node names ( /sd* ) =====<br />
This is the simplest way, but assigned name depends on order of insertion. Ways to get node name:<br />
<br />
* search in the output of {{Ic|dmesg}} for the kernel device name, you can use {{Ic|grep}} to help you find what you are looking for:<br />
$ dmesg | egrep "sd[a-z]"<br />
* running<br />
# fdisk -l<br />
lists all available partition tables.<br />
<br />
{{Note|If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.}}<br />
<br />
===== Using UUID =====<br />
Every drive creates a [[Wikipedia:UUID|UUID]] (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie {{Ic|/dev/sda}}).<br />
<br />
To find the current UUIDs execute:<br />
{{hc|# blkid -o list -c /dev/null|<nowiki><br />
device fs_type label mount point UUID<br />
------------------------------------------------------------------------------------------<br />
/dev/sda1 ext2 /boot 7f4cef7e-7ee2-489a-b759-d52ba23b692c<br />
/dev/sda2 swap (not mounted) a807fff3-e89f-46d0-ab17-9b7ad3efa7b5<br />
/dev/sda3 ext4 / 81917291-fd1a-4ffe-b95f-61c05cfba76f<br />
/dev/sda4 ext4 /home c4c23598-19fb-4562-892b-6fb18a09c7d3<br />
/dev/sdb1 ext4 X2 /mnt/X1 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdc1 ext4 X1 /mnt/X2 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdd1 ext4 Y2 /mnt/Y2 8a976a06-3e56-476f-b73a-ea3cad41d915<br />
/dev/sde1 ext4 Z2 /mnt/Z2 9d35eaae-983f-4eba-abc9-434ecd4da09c<br />
/dev/sdf1 ext4 Y1 /mnt/Y1 e2ec37a9-0689-46a8-a07b-0609ce2b7ea2<br />
/dev/sdg1 ext4 Z1 /mnt/Z1 9fa239c1-720f-42e0-8aed-39cf53a743ed<br />
/dev/sdj1 ext4 RAPT (not mounted) a9ed7ecb-96ce-40fe-92fa-e07a532ed157<br />
/dev/sdj2 swap <swap> 20826c74-eb6d-46f8-84d8-69b933a4bf3f<br />
</nowiki>}}<br />
<br />
'' At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.''<br />
<br />
* Now connect your USB device and wait for a few seconds . . . <br />
<br />
* Reexecute {{Ic|blkid -o list -c /dev/null}}<br />
'' Notice a new device and UUID? That is your USB storage''<br />
<br />
{{Tip| If {{Ic|blkid}} does not work as expected, You can look for the UUIDs in {{Ic|/dev/disk/by-uuid/}}:<br />
<br />
$ ls -lF /dev/disk/by-uuid/<br />
<br />
}}<br />
<br />
==== Mounting USB memory ====<br />
You need to create the directory in which you are going to mount the device:<br />
# mkdir /mnt/usbstick<br />
<br />
===== As root =====<br />
Mount the device as root with this command (do not forget to replace '''device_node''' by the path you found):<br />
# mount '''device_node''' /mnt/usbstick<br />
or<br />
# mount -U '''UUID''' /mnt/usbstick<br />
<br />
If {{Ic|mount}} does not recognized the format of the device you can try to use the {{Ic|-t}} argument, see {{Ic|man mount}} for details.<br />
<br />
{{Note|If mounting your stick does not work you can try to repartition it, see [[Format a device]].}}<br />
<br />
===== As normal user with mount =====<br />
If you want non-root users to be able to write to the USB stick, you can issue the following command:<br />
<br />
$ sudo mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick<br />
<br />
===== As normal user with fstab =====<br />
If you want non-root users to be able to mount a USB memory stick via [[fstab]], add the following line to your {{ic|/etc/fstab}} file:<br />
/dev/sda1 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
or better:<br />
UUID=E8F1-5438 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
(see description of '''user''' and other options in the [[Fstab|main article]])<br />
<br />
{{Note|Where {{Ic|/dev/sda1}} is replaced with the path to your own usbstick, see [[USB_Storage_Devices#Mounting_USB_memory|Mounting USB memory]].}}<br />
<br />
Now, any user can mount it with:<br />
$ mount /mnt/usbstick<br />
<br />
And unmount it with:<br />
$ umount /mnt/usbstick<br />
<br />
===== Poor copy performance to USB pendrive =====<br />
If you experienced slow copy speed to pendrive (mainly in KDE), then merge this three line to the end of your /etc/rc.local:<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/enabled<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/defrag<br />
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag<br />
And paste these at the end of your /etc/sysctl.conf<br />
kernel.shmmax=134217728<br />
vm.dirty_background_bytes = 4194304<br />
vm.dirty_bytes = 4194304<br />
And reboot. This also reduces the freezes of the KDE's panel.</div>Alx14https://wiki.archlinux.org/index.php?title=USB_storage_devices&diff=216671USB storage devices2012-08-06T15:04:56Z<p>Alx14: </p>
<hr />
<div>[[Category:Storage]]<br />
[[es:USB Storage Devices]]<br />
[[it:USB Storage Devices]]<br />
[[ru:USB Storage Devices]]<br />
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.<br />
<br />
== Mounting USB devices ==<br />
If you have an up-to-date system with the standard Arch kernel and a modern [[Desktop Environment]] your device should just show up on your desktop, no need to open a console.<br />
<br />
Otherwise see sections below.<br />
<br />
=== Auto-mounting with udev ===<br />
See [[Udev#Auto mounting USB devices|Udev:Auto mounting USB devices]].<br />
<br />
A lightweight solution to automount harddrives using udev, for systems with only one user, is the following: create a file named {{Ic|/etc/udev/rules.d/automount.rules}} with the following content:<br />
{{hc|ACTION=="add", ENV{DEVTYPE}=="partition", RUN+="domount %N"}}<br />
and a file (executable by root) named {{Ic|/usr/lib/udev/domount}} with:<br />
<br />
{{hc|#!/bin/sh<br />
<br />
export DISPLAY=:0<br />
DIR=`cat /etc/fstab|grep $*|awk '{print $2;}'`<br />
if [ "x$DIR" = "x" ]; then<br />
DIR=/run/media/`blkid -o value -s UUID $*` <br />
fi<br />
mkdir -p /run/media<br />
mkdir -p $DIR<br />
mount -o uid=1000,gid=1000,users $* $DIR<br />
cat > /tmp/script << EOF<br />
#!/bin/sh<br />
cd $DIR<br />
zsh<br />
cd<br />
sudo umount $DIR<br />
EOF<br />
chmod a+x /tmp/script<br />
su al -c 'lxterminal -e /tmp/script'<br />
sleep 1; rm -f /tmp/script}}<br />
<br />
(replace the 1000 with your UID and GID, lxterminal with your favorite terminal emulator, and zsh with your shell).<br />
<br />
When an harddrive is inserted, it will be mounted, and a Terminal will pop-up. To umount the device, simply press Control+D in the terminal window. <br />
<br />
<br />
<br />
=== Manual mounting ===<br />
{{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.}}<br />
<br />
==== Getting a kernel that supports usb_storage ====<br />
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:<br />
<br />
# modprobe usb-storage<br />
# modprobe sd_mod (only for non SCSI kernels)<br />
<br />
==== Identifying device ====<br />
First thing one need to access storage device is it's identifier assigned by kernel.<br />
<br />
===== Using device node names ( /sd* ) =====<br />
This is the simplest way, but assigned name depends on order of insertion. Ways to get node name:<br />
<br />
* search in the output of {{Ic|dmesg}} for the kernel device name, you can use {{Ic|grep}} to help you find what you are looking for:<br />
$ dmesg | egrep "sd[a-z]"<br />
* running<br />
# fdisk -l<br />
lists all available partition tables.<br />
<br />
{{Note|If you cannot find your device you can use lsusb to verify that it is indeed recognized by the system.}}<br />
<br />
===== Using UUID =====<br />
Every drive creates a [[Wikipedia:UUID|UUID]] (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie {{Ic|/dev/sda}}).<br />
<br />
To find the current UUIDs execute:<br />
{{hc|# blkid -o list -c /dev/null|<nowiki><br />
device fs_type label mount point UUID<br />
------------------------------------------------------------------------------------------<br />
/dev/sda1 ext2 /boot 7f4cef7e-7ee2-489a-b759-d52ba23b692c<br />
/dev/sda2 swap (not mounted) a807fff3-e89f-46d0-ab17-9b7ad3efa7b5<br />
/dev/sda3 ext4 / 81917291-fd1a-4ffe-b95f-61c05cfba76f<br />
/dev/sda4 ext4 /home c4c23598-19fb-4562-892b-6fb18a09c7d3<br />
/dev/sdb1 ext4 X2 /mnt/X1 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdc1 ext4 X1 /mnt/X2 4bf265f7-da17-4575-8758-acd40885617b<br />
/dev/sdd1 ext4 Y2 /mnt/Y2 8a976a06-3e56-476f-b73a-ea3cad41d915<br />
/dev/sde1 ext4 Z2 /mnt/Z2 9d35eaae-983f-4eba-abc9-434ecd4da09c<br />
/dev/sdf1 ext4 Y1 /mnt/Y1 e2ec37a9-0689-46a8-a07b-0609ce2b7ea2<br />
/dev/sdg1 ext4 Z1 /mnt/Z1 9fa239c1-720f-42e0-8aed-39cf53a743ed<br />
/dev/sdj1 ext4 RAPT (not mounted) a9ed7ecb-96ce-40fe-92fa-e07a532ed157<br />
/dev/sdj2 swap <swap> 20826c74-eb6d-46f8-84d8-69b933a4bf3f<br />
</nowiki>}}<br />
<br />
'' At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.''<br />
<br />
* Now connect your USB device and wait for a few seconds . . . <br />
<br />
* Reexecute {{Ic|blkid -o list -c /dev/null}}<br />
'' Notice a new device and UUID? That is your USB storage''<br />
<br />
{{Tip| If {{Ic|blkid}} does not work as expected, You can look for the UUIDs in {{Ic|/dev/disk/by-uuid/}}:<br />
<br />
$ ls -lF /dev/disk/by-uuid/<br />
<br />
}}<br />
<br />
==== Mounting USB memory ====<br />
You need to create the directory in which you are going to mount the device:<br />
# mkdir /mnt/usbstick<br />
<br />
===== As root =====<br />
Mount the device as root with this command (do not forget to replace '''device_node''' by the path you found):<br />
# mount '''device_node''' /mnt/usbstick<br />
or<br />
# mount -U '''UUID''' /mnt/usbstick<br />
<br />
If {{Ic|mount}} does not recognized the format of the device you can try to use the {{Ic|-t}} argument, see {{Ic|man mount}} for details.<br />
<br />
{{Note|If mounting your stick does not work you can try to repartition it, see [[Format a device]].}}<br />
<br />
===== As normal user with mount =====<br />
If you want non-root users to be able to write to the USB stick, you can issue the following command:<br />
<br />
$ sudo mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick<br />
<br />
===== As normal user with fstab =====<br />
If you want non-root users to be able to mount a USB memory stick via [[fstab]], add the following line to your {{ic|/etc/fstab}} file:<br />
/dev/sda1 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
or better:<br />
UUID=E8F1-5438 /mnt/usbstick vfat '''user''',noauto,noatime,flush 0 0<br />
(see description of '''user''' and other options in the [[Fstab|main article]])<br />
<br />
{{Note|Where {{Ic|/dev/sda1}} is replaced with the path to your own usbstick, see [[USB_Storage_Devices#Mounting_USB_memory|Mounting USB memory]].}}<br />
<br />
Now, any user can mount it with:<br />
$ mount /mnt/usbstick<br />
<br />
And unmount it with:<br />
$ umount /mnt/usbstick<br />
<br />
===== Poor copy performance to USB pendrive =====<br />
If you experienced slow copy speed to pendrive (mainly in KDE), then merge this three line to the end of your /etc/rc.local:<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/enabled<br />
echo madvise > /sys/kernel/mm/transparent_hugepage/defrag<br />
echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag<br />
And paste these at the end of your /etc/sysctl.conf<br />
kernel.shmmax=134217728<br />
vm.dirty_background_bytes = 4194304<br />
vm.dirty_bytes = 4194304<br />
And reboot. This also reduces the freezes of the KDE's panel.</div>Alx14