Changes

Jump to: navigation, search

FAQs (XUELK)

7,123 bytes added, 10:50, 1 March 2017
no edit summary
= Introduction =
This page collects Frequently Asked Questions (FAQs) regarding [[http://wiki.dave.eu/index.php/AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)|AXEL ULite and SBC Lynx Embedded Linux Kit (XUELK)]].
This page collects all = Q: How to enable USB storage auto-mount? ='''A''': USB storage auto-mount can be enabled by adding specific <code>udev</code> rules. The following example has been tested with this file system: https://mirror.dave.eu/lynx/xuelk-1.1.0/xuelk-1.1.0_lynx-image-networking-sbc-lynx.tar.bz2, and makes use of two files. The first one is called <code>automount.rules</code>. It contains the additional rules, and it has to be copied in <code>/etc/udev/rules.d/</code>. It looks like this:<pre class="board-terminal">root@sbc-lynx:~# cat /etc/udev/rules.d/automount.rules# There are a number of modifiers that are allowed to be used in some# of the different fields. They provide the following subsitutions:## %n the "kernel number" of the device.# For example, 'sda3' has a "kernel number" of '3'# %e the smallest number for that name which does not matches an existing node# %k the kernel name for the device# %M the kernel major number for the device# %m the kernel minor number for the device# %b the bus id for the device# %c the string returned by the PROGRAM# %s{filename} the content of a sysfs attribute# %% the '%' char itself# # Media automountingSUBSYSTEM=="block", ACTION=="add" RUN+="/etc/udev/scripts/mount.sh"SUBSYSTEM=="block", ACTION=="remove" RUN+="/etc/udev/scripts/mount.sh"</pre> The second file is a script that can be copied in <code>/etc/udev/scripts/</code>. It looks like this:<pre class="board-terminal">root@sbc-lynx:~# cat /etc/udev/scripts/mount.sh#!/bin/sh## Called from udev## Attempt to mount any added block devices and umount any removed devices  MOUNT="/bin/mount"PMOUNT="/usr/bin/pmount"UMOUNT="/bin/umount"for line in `grep -v ^# /etc/udev/mount.blacklist`do if [ ` expr match "$DEVNAME" "$line" ` -gt 0 ]; then logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring" exit 0 fidone automount() { name="`basename "$DEVNAME"`"  ! test -d "/media/$name" && mkdir -p "/media/$name" # Silent util-linux's version of mounting auto if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ; then MOUNT="$MOUNT -o silent" fi  if ! $MOUNT -t auto $DEVNAME "/media/$name" then #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/run/media/$name\" failed!" rm_dir "/media/$name" else logger "mount.sh/automount" "Auto-mount of [/media/$name] successful" touch "/tmp/.automount-$name" fi} rm_dir() { # We do not want to rm -r populated directories if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1" then ! test -z "$1" && rm -r "$1" else logger "mount.sh/automount" "Not removing non-empty directory [$1]" fi} if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" ]; then if [ -x "$PMOUNT" ]; then $PMOUNT $DEVNAME 2> /dev/null elif [ -x $MOUNT ]; then $MOUNT $DEVNAME 2> /dev/null fi  # If the Frequently Asked Question regarding device isn't mounted at this point, it isn't # configured in fstab (note the root filesystem can show up as # /dev/root in /proc/mounts, so check the device number too) if expr $MAJOR "*" 256 + $MINOR != `stat -c %d /`; then grep -q "^$DEVNAME " /proc/mounts || automount fifi   if [ "$ACTION" = "remove" ] && [-x "$UMOUNT" ] && [-n "$DEVNAME" ]; then for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " ` do $UMOUNT $mnt done  # Remove empty directories from auto-mounter name="`basename "$DEVNAME"`" test -e "/tmp/.automount-$name" && rm_dir "/media/$name"fi</pre>
 After creating these two files, restart <code>udev</code> to make the changes take effect:<pre class="board-terminal">udevadm control --reload-rules</pre> The following console dump shows the process of auto-mounting/auto-unmounting of a FAT32 partition, stored on a USB flash drive.<pre class= Q"board-terminal">root@sbc-lynx:~# [ 611.238221] usb 1-1: new high-speed USB device number 3 using ci_hdrc[ 611.406307] usb-storage 1-1:1.0: How to enable USB Mass Storage device detected[ 611.424566] scsi1 : usb-storage auto1-1:1.0[ 612.431396] scsi 1:0:0:0: Direct-Access Generic FIash Disk 8.07 PQ: 0 ANSI: 2[ 612.456387] sd 1:0:0:0: [sda] 15663104 512-byte logical blocks: (8.01 GB/7.46 GiB)[ 612.474787] sd 1:0:0:0: [sda] Write Protect is off[ 612.485226] sd 1:0:0:0: [sda] No Caching mode page found[ 612.491238] sd 1:0:0:0: [sda] Assuming drive cache: write through[ 612.504934] sd 1:0:0:0: [sda] No Caching mode page found[ 612.511000] sd 1:0:0:0: [sda] Assuming drive cache: write through[ 612.577162] sda: sda1[ 612.591581] sd 1:0:0:0: [sda] No Caching mode page found[ 612.596934] sd 1:0:0:0: [sda] Assuming drive cache: write through[ 612.606655] sd 1:0:0:0: [sda] Attached SCSI removable disk[ 613.219100] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck. root@sbc-lynx:~# mountrootfs on / type rootfs (rw)192.168.0.13:/opt/nfsroot/lynx/xuelk-1.1.0-networking on / type nfs (rw,relatime,vers=3,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.13,mountvers=3,mountproto=tcp,local_lock=all,addr=192.168.0.13)devtmpfs on /dev type devtmpfs (rw,relatime,size=220568k,nr_inodes=55142,mode=755)proc on /proc type proc (rw,relatime)sysfs on /sys type sysfs (rw,relatime)debugfs on /sys/kernel/debug type debugfs (rw,relatime)tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)tmpfs on /var/volatile type tmpfs (rw,relatime)devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)/dev/sda1 on /media/sda1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)...root@sbc-lynx:~# [ 631.627230] usb 1-1: USB disconnect, device number 3root@sbc-lynx:~# mount? rootfs on / type rootfs (rw)192.168.0.13:/opt/nfsroot/lynx/xuelk-1.1.0-networking on / type nfs (rw,relatime,vers=3,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.13,mountvers=3,mountproto=tcp,local_lock=all,addr=192.168.0.13)devtmpfs on /dev type devtmpfs (rw,relatime,size=220568k,nr_inodes=55142,mode=755)proc on /proc type proc (rw,relatime)sysfs on /sys type sysfs (rw,relatime)debugfs on /sys/kernel/debug type debugfs (rw,relatime)tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)'''A'''tmpfs on /var/volatile type tmpfs (rw,relatime)devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)root@sbc-lynx: In case~# ls -la /media/drwxr-xr-x 7 root root 4096 Mar 1 2017 .drwxr-xr-x 17 root root 4096 Feb 28 2017 ..drwxr-xr-x 2 root root 4096 Dec 13 15:55 mmcblk0p1drwxr-xr-x 2 root root 4096 Feb 2 16:02 mmcblk0p2</pre>
4,650
edits

Navigation menu