fstab entries for two different pendrives? 

Newsgroups:  gmane.linux.debian.user
Date:        Sat, 26 Aug 2006 14:28:56 +0200
> yesterday I bought a new 256 MB pendrive, that wants to be mounted as
> `/dev/sda' whereas the other one I have wants `/dev/sda1'. Now, if in
> /etc/fstab I put the sda entry first, then can't mount sda1; and vice
> versa, if I put sda1 first then I can't mount sda.

If you install the "pmount" package and add your user to the "plugdev" group then you will not need fstab entries for pluggable devices anymore. (You should then just comment these entries out or remove them entirely.) Devices will be mounted at the correct mount point automatically. Even better, if you use the "pmount-hal" command then the devices will be mounted by their volume label so that you can address each medium unambiguously and independent of the order in which you attached them. This is also fully integrated in e.g. KDE and Gnome.

Florian Kulzer

fstab entries for two different pendrives? 

> > Devices will be mounted at the correct mount point automatically.
>
> Don't they get mounted at some random point in /media?

OK, my statement is somewhat misleading. I was assuming, maybe mistakenly, that the OP needed a way to make sure that he could always address each of his two USB sticks in a deterministic way, regardless of the order in which they were plugged in. To my knowledge the easiest way to achieve this is to either use pmount-hal (if you are scripting yourself) or to rely on the built-in functionality of (some) modern desktop environments. If you have to bring both worlds together you can always use "lshal" and a bit of awk/grep/sed to find a specific device.

> (/me stabs repeatedly whatever fool decided the world needed two places
> to mount things...)

Well, somebody probably thought "media" is easier to understand than "mnt". I am not sure if it matters so much; the people who write their own scripts can (p)mount where they please and the other ones just click on the icon and often do not really have to know the mount point at all.

> > Even better, if you use the "pmount-hal" command then the devices will
> > be mounted by their volume label so that you can address each medium
> > unambiguously and independent of the order in which you attached them.
>
> Pre-supposing that the device *has* a volume label, and that you *know*
> what it is, so that you can find it in /media.

You can set the volume label yourself to provide unique identifiers for your stuff. (At least for USB sticks; I have never tried this with a camera.) If this is not feasible then you can normally use the uuid (universally unique identifier). For example, if I run "lshal —monitor" and plug in my USB stick, I see this:

Start monitoring devicelist:

usb_device_67b_2515_noserial added
usb_device_67b_2515_noserial_if0 added usb_device_67b_2515_noserial_usbraw
added usb_device_67b_2517_noserial added
usb_device_67b_2517_noserial_if0 added usb_device_67b_2517_noserial_usbraw
added usb_device_67b_2517_noserial_if0_scsi_host added
usb_device_67b_2517_noserial_if0_scsi_host_scsi_device_lun0 added
usb_device_67b_2517_noserial_if0_scsi_host_scsi_device_lun0 property
info.linux.driver = 'sd' (new)
storage_serial_Prolific_Technology_Inc__USB_Mass_Storage_Device added
volume_uuid_44E1_54A2 added

I can specify the desired mount point by generating a file named /usr/share/hal/fdi/policy/custom.fdi (or whatever.fdi) with the following contents:

<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- --> <deviceinfo
version="0.2">
<device>
  <match key="block.is_volume" bool="true">
    <match key="volume.fsusage" string="filesystem">
      <match key="volume.uuid" string="44E1-54A2">
        <merge key="volume.policy.desired_mount_point"
        type="string">usbstick-flo1</merge>
      </match>
    </match>
  </match>
</device>
</deviceinfo>

This device should now be mounted at /media/usbstick-flo1 by every DE, daemon, etc. that uses the hardware abstraction layer to handle devices.

> > This is also fulls integrated in e.g. KDE and Gnome.
>
> Fortunately, everyone does not use KDE or Gnome.

I did not mean to imply that everyone should. I know that the "automatic" mechanism which uses pmount and hal works for these two DEs, therefore I mentioned them; I would assume that it works on others, too, if they follow the freedesktop.org specifications.

If you write your own (auto)mounting scripts then you probably only need to use a udev rule to make sure a unique device symlink is created; see Alan Chandler's nice summary earlier in this thread.

Florian Kulzer

fstab entries for two different pendrives? 

> I have the following problem: ...
> Any suggestion to be able to mount both?

Use udev to recognise the pendrive from its manufactures name, and create a symlink (or actual device) called /dev/flash. Mount that in /etc/fstab

[Sorry about mail wordwrap in the stuff below - you need to un wordwrap it in the real file]

I have a file in /etc/udev/rules.d called 01akcspecialrules that is shown below. I am not doing the same thing, but you would use a similar thing to my first two devices, except something like this (where the jumpdrive is not partitioned and the other device is)

# Portable Flash Storage
 BUS=="usb", SYSFS{product}=="JUMPDRIVE ELITE", KERNEL=="sd*",
 NAME="flash"
SYMLINK="jumpdrive flash"
 BUS=="usb", SYSFS{product}=="USB DISK 2.0", KERNEL=="sd?1", NAME="flash"
SYMLINK="integral_storage flash"
# use this line to get rid of the /dev/sda type entry for the partitioned
device
 BUS=="usb", SYSFS{product}=="USB DISK 2.0", KERNEL=="sd*", NAME=""
SYMLINK="integral_storage flash"

udevinfo

something like

udevinfo -a -p /block/sdc/sda1

Example 1. My 01akcspecialrules

# Portable Flash Storage
 BUS=="usb", SYSFS{product}=="JUMPDRIVE ELITE", KERNEL=="sd?1",
SYMLINK="jumpdrive flash"
 BUS=="usb", SYSFS{product}=="USB DISK 2.0", KERNEL=="sd?1",
SYMLINK="integral_storage flash"


# IRiver T30
 BUS=="usb" SYSFS{product}=="t30", KERNEL=="sd?1", NAME="iriver_t30",
SYMLINK="audioplayer", GROUP="audio"

# Digital Camera (either the C745UZ or the C220Z)
 BUS=="usb", SYSFS{product}=="C220Z", KERNEL=="sd?1", NAME="olympus_c220z"
 ,
SYMLINK="camera"
 BUS=="usb", SYSFS{product}=="C740UZ", KERNEL=="sd?1",
 NAME="olympus_c745uz",
SYMLINK="camera"

Alan Chandler