<HTML ><HEAD ><TITLE > Making the memory stick accessible to users</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="USB Flash Memory HOWTO" HREF="index.html"><LINK REL="PREVIOUS" TITLE=" Setting up a dual partition" HREF="mixed.html"><LINK REL="NEXT" TITLE=" Maintenance" HREF="maintain.html"></HEAD ><BODY CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >USB Flash Memory HOWTO</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="mixed.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="maintain.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="users" ></A >10. Making the memory stick accessible to users</H1 ><P > What we have described so far, are simply the procedures of setting up the system and formatting memory sticks. We have to make the mounting of the USB filesystem more permanent, and we have to make mounting of such a device easier for non-root users. There are only a few things to be done. </P ><P > The procedure described below is for the more complex situation of a memory stick with a dual partition (<A HREF="mixed.html" >Section 9</A >). If the partition is a single ext2, the procedure should be simplified by leaving out the line referring to the vfat part and changing <TT CLASS="filename" >sda2</TT > to <TT CLASS="filename" >sda1</TT >. </P ><P > Suppose that the mount points <TT CLASS="filename" > /mnt/memstick</TT > and <TT CLASS="filename" > /mnt/fatstick</TT > have been created. You do not have to use those words and they don't even have to be sub-directories of <TT CLASS="filename" > /mnt</TT > </P ><P > To make remembering easier, create the following symbolic links: </P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="screen" > <TT CLASS="prompt" >#</TT > <TT CLASS="userinput" ><B ><B CLASS="command" >ln</B > -s /dev/sda1 /dev/fatflash</B ></TT > <TT CLASS="prompt" >#</TT > <TT CLASS="userinput" ><B ><B CLASS="command" >ln</B > -s /dev/sda2 /dev/flash</B ></TT > </PRE ></FONT ></TD ></TR ></TABLE ><P > For smoother and easier mounting add the following lines to <TT CLASS="filename" > /etc/fstab</TT > : (<EM > See NOTE at the end of </EM > <A HREF="verifications.html#mounting" >Section 7.3</A > )</P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="screen" > none /proc/bus/usb usbfs defaults 0 0 /dev/flash /mnt/memstick ext2,vfat rw,user,noauto 0 0 /dev/fatflash /mnt/fatstick vfat rw,user,noauto 0 0 </PRE ></FONT ></TD ></TR ></TABLE ><P > The middle line enables mounting either in ext2 or vfat. The last two lines make it possible for any user to mount the device by the command </P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="screen" > <TT CLASS="prompt" >$</TT ><TT CLASS="userinput" ><B ><B CLASS="command" > mount</B > /dev/flash</B ></TT > [for ext2 or vfat] <TT CLASS="prompt" >$</TT ><TT CLASS="userinput" ><B ><B CLASS="command" > mount</B > /dev/fatflash</B ></TT > [for vfat] </PRE ></FONT ></TD ></TR ></TABLE ><P > It is possible to mount both partitions simultaneously. See <A HREF="mixed.html" >Section 9</A >. </P ><P > In the case of an ext2-formatted device it does not seem possible for a user (other than root) to mount in read-write mode. The solution is to create a directory on the memory stick owned by the particular user with complete permissions. Root should do that: </P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="screen" > <TT CLASS="prompt" >#</TT > <TT CLASS="userinput" ><B ><B CLASS="command" >mount </B >/dev/flash </B ></TT > <TT CLASS="prompt" ># </TT ><TT CLASS="userinput" ><B ><B CLASS="command" >mkdir</B > -m 777 /mnt/memstick/superdir </B ></TT > <TT CLASS="prompt" ># </TT ><TT CLASS="userinput" ><B ><B CLASS="command" >chown</B > charles:charles /mnt/memstick/superdir </B ></TT > </PRE ></FONT ></TD ></TR ></TABLE ><P > If the device is in the vfat format, this step is unnecessary. </P ><P > In conclusion, here is a small script I use to mount and unmount my (ext2) flash drive: </P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="programlisting" > #!/bin/bash EXCODE="keepit" green='\033[0;32m' yellow='\033[0;33m' ## ___________________________ ## Function to echo in colours echo_in_color () { message=$2 message1=$4 color=$1 color1=$3 echo -e -n $color echo -n $message echo -e -n $color1 " " echo -n $message1 " " tput sgr0 return } ## ___________________________ clear mount /dev/flash echo_in_color $green "Flash drive mounted" sleep 2 while [ $EXCODE != "flexit" ] do clear echo_in_color $yellow "Enter [flexit] to unmount and exit:" read EXCODE done umount /dev/flash exit </PRE ></FONT ></TD ></TR ></TABLE ><P > I call this from an FVWM menu by <TT CLASS="userinput" ><B > Exec exec xterm -geometry 43x2+1250+0 -e /home/nikos/bin/flashdrive</B ></TT > which places it on a tiny x-term in one corner of the screen. The horizontal displacement of 1250 may have to be modified according to the horizontal resolution of your screen. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="mixed.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="maintain.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Setting up a dual partition</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Maintenance</TD ></TR ></TABLE ></DIV ></BODY ></HTML >