LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices

Reply
 
Search this Thread
Old 01-27-2005, 01:28 AM   #1
leiavoia
Member
 
Registered: Mar 2002
Distribution: Debian Testing & Kubuntu
Posts: 72

Rep: Reputation: 15
Juggling USB devices (fstab related)


First of all, *everythig is working*. I want to make it work better.

I have two USB mass-storage devices: an external HD that i just bought for making total backups. I also have a card reader. I do not plan to keep the external HD on unless i am backing up, and i do not plan to have a card plugged into the reader at all times.

When you plug a USB device into the system, hotplug will pick it up and slap it into the nearest convenient device slot: /dev/sda, /dev/sdb, and so on. The problem is that when the actual hardware is not permanantly plugged in and turned on, i cannot always expect to plug in the card reader and have it always be sda1 or anything else. It all depends on what is already plugged into the system.

This is a problem for fstab. For instance, if i want to write a backup script that says "mount /backup", fstab looks it up and sees that it is tied to /dev/sda1, which i expect to be a HD. But at the moment in this example, it's the card reader. Ha!

Is there a way to permanantly assign a device file to a device so that fstab always mounts the same hardware to the same slots?

Thanks for your help. I appreciate it.
 
Old 01-27-2005, 08:26 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

Have a look here:
http://www.redhat.com/docs/manuals/e...-devlabel.html

I'm looking into this myself.

Dave

Edit: Maybe not - apparently, devlabel was deprecated by udev. "udev is the preferred solution".

Last edited by ilikejam; 01-27-2005 at 08:32 AM.
 
Old 01-27-2005, 10:06 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Are you using udev/hotplug/hald? (does "hald" appear in 'ps -A')? If so, then I have a solution.

It's a bit involved, but it lets you set a mount point for specific devices, so that they mount in the same place no matter what.

Dave
 
Old 01-27-2005, 11:02 AM   #4
leiavoia
Member
 
Registered: Mar 2002
Distribution: Debian Testing & Kubuntu
Posts: 72

Original Poster
Rep: Reputation: 15
Aparently not. 'ps -A' gives me this:

PID TTY TIME CMD
1 ? 00:00:00 init
2 ? 00:00:00 keventd
3 ? 00:00:06 ksoftirqd_CPU0
4 ? 00:00:27 kswapd
5 ? 00:00:13 bdflush
6 ? 00:00:00 kupdated
103 ? 00:00:01 kjournald
229 ? 00:00:00 kjournald
368 ? 00:00:00 knodemgrd_0
468 ? 00:00:00 khubd
835 ? 00:00:02 usb-storage-0
836 ? 00:00:00 scsi_eh_1
837 ? 00:00:00 usb-storage-1
838 ? 00:00:00 scsi_eh_2
893 ? 00:00:00 dhclient
897 ? 00:00:00 portmap
919 ? 00:00:00 kwacomd
1065 ? 00:00:00 syslogd
1068 ? 00:00:00 klogd
1101 ? 00:00:00 exim4
1106 ? 00:00:11 famd
1111 ? 00:00:00 inetd
1115 ? 00:00:00 lpd
1122 ? 00:00:00 sshd
1183 ? 00:00:00 bash
1185 ? 00:00:00 bash
1186 ? 00:00:00 bash
1190 ? 00:00:00 Xprt
1195 ? 00:00:00 rpc.statd
1198 ? 00:00:00 ntpd
1201 ? 00:00:00 atd
1237 ? 00:00:00 cron
1248 ? 00:00:00 apache
1253 ? 00:00:00 apache
1254 ? 00:00:00 apache
1255 ? 00:00:00 apache
1256 ? 00:00:00 apache
1257 ? 00:00:00 apache
1266 ? 00:00:00 kdm
1273 tty1 00:00:00 getty
1274 tty2 00:00:00 getty
1275 tty3 00:00:00 getty
1276 tty4 00:00:00 getty
1277 tty5 00:00:00 getty
1278 tty6 00:00:00 getty
1279 ? 00:03:37 XFree86
1282 ? 00:00:00 kapmd
1540 ? 00:00:00 kjournald
1572 ? 00:00:00 kdm
1582 ? 00:00:01 enlightenment
1638 ? 00:00:00 ssh-agent
1640 ? 00:00:01 gkrellm
1646 ? 00:00:00 xmms
1647 ? 00:00:00 xmms
1648 ? 00:00:00 xmms
1653 ? 00:00:00 xmms
1654 ? 00:00:08 kmail
1656 ? 00:00:00 kdeinit
1659 ? 00:00:00 kdeinit
1661 ? 00:00:00 kdeinit
1663 ? 00:00:00 kdeinit
1667 ? 00:00:00 kdeinit
1673 ? 00:01:09 firefox-bin
1683 ? 00:00:00 firefox-bin
1684 ? 00:00:00 firefox-bin
1686 ? 00:00:00 gconfd-2
1688 ? 00:00:00 firefox-bin
1989 ? 00:00:00 firefox-bin
1994 ? 00:00:02 artsd
1995 ? 00:00:00 artsd
2006 ? 00:00:00 kdeinit
2018 ? 00:00:00 kdeinit
2026 ? 00:00:00 kdeinit
2047 ? 00:00:01 kdeinit
2048 ? 00:00:00 kdeinit
2050 ? 00:00:00 kdeinit
2051 ? 00:00:00 kdeinit
2054 ? 00:00:00 kdeinit
2055 ? 00:00:00 kdeinit
2056 ? 00:00:00 kdeinit
2061 ? 00:00:00 Eterm
2062 pts/0 00:00:00 bash
2065 pts/0 00:00:00 bash
2125 pts/0 00:00:00 ps
 
Old 01-27-2005, 11:02 AM   #5
Wells
Member
 
Registered: Nov 2004
Location: Florida, USA
Distribution: Debian, Redhat
Posts: 383

Rep: Reputation: 31
Quote:
Originally posted by ilikejam
Are you using udev/hotplug/hald? (does "hald" appear in 'ps -A')? If so, then I have a solution.

It's a bit involved, but it lets you set a mount point for specific devices, so that they mount in the same place no matter what.

Dave
If you could post that here somewhere, that would be greatly appreciated. I am running into the same problem with a couple of the machines that I support, and this sort of fix would be wonderful.
 
Old 01-27-2005, 12:29 PM   #6
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
leiavoia: Have a look at that devlabel thing in post #2, I think it's probably what you're looking for.

Wells: Here we go:

Basically, what you want to do is add hal config files (.fdi files), so that the mount point is something other than the usual usbdisk or whatever, depending on some feature or another of the volume.

In FC3, the hal files are in /usr/share/hal/fdi
There should be a few directories starting with numbers, like 10generic and so on.
The main config is in 90defaultpolicy

This is the file I created to change the mount point of my Sony USB stick to 'sony':
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> 

<deviceinfo version="0.2">
  <device>
    <match key="info.bus" string="block">
      <match key="volume.uuid" string="41C7-EE93">
        <merge key="volume.policy.desired_mount_point" type="string">sony</merge>
      </merge>
    </match>
  </device>
</deviceinfo>
I called the file sony.fdi, and put it in /usr/share/hal/fdi/95userpolicy, so that it gets looked at *after* the main config in 90defaultpolicy.

It's one device per file.

You get the volume.uuid above by plugging in the device, then running 'lshal'. At the top of the output you should see a load of stuff about the drive. This is the output of lshal when the Sony device is in:
Code:
udi = '/org/freedesktop/Hal/devices/block_41C7-EE93'
  volume.mount_point = ''  (string)
  volume.policy.mount_option.iocharset=utf8 = true  (bool)
  volume.policy.mount_option.noatime = true  (bool)
  volume.policy.mount_option.sync = true  (bool)
  volume.policy.desired_mount_point = 'sony'  (string)
  volume.policy.mount_filesystem = 'vfat'  (string)
  volume.policy.should_mount = true  (bool)
  info.udi = '/org/freedesktop/Hal/devices/block_41C7-EE93'  (string)
  volume.partition.msdos_part_table_type = 11  (0xb)  (int)
  volume.size = 131046400  (0x7cf9c00)  (uint64)
  volume.block_size = 512  (0x200)  (int)
  volume.num_blocks = 255950  (0x3e7ce)  (int)
  volume.partition.number = 1  (0x1)  (int)
  volume.is_partition = true  (bool)
  volume.is_mounted = false  (bool)
  volume.is_disc = false  (bool)
  volume.uuid = '41C7-EE93'  (string)
  volume.label = ''  (string)
  volume.fsversion = 'FAT16'  (string)
  volume.fsusage = 'filesystem'  (string)
  volume.fstype = 'vfat'  (string)
  info.product = 'Volume (vfat)'  (string)
  block.storage_device = '/org/freedesktop/Hal/devices/block_8_16'  (string)
  block.minor = 17  (0x11)  (int)
  block.major = 8  (0x8)  (int)
  info.capabilities = 'block volume'  (string)
  info.category = 'volume'  (string)
  info.parent = '/org/freedesktop/Hal/devices/block_8_16'  (string)
  block.device = '/dev/sdb1'  (string)
  block.is_volume = true  (bool)
  block.have_scanned = false  (bool)
  block.no_partitions = false  (bool)
  linux.sysfs_path_device = '/sys/block/sdb/sdb1'  (string)
  linux.sysfs_path = '/sys/block/sdb/sdb1'  (string)
  info.bus = 'block'  (string)

udi = '/org/freedesktop/Hal/devices/block_8_16'
  storage.policy.should_mount = true  (bool)
  info.udi = '/org/freedesktop/Hal/devices/block_8_16'  (string)
  storage.requires_eject = false  (bool)
  storage.hotpluggable = true  (bool)
  storage.removable = true  (bool)
  info.product = 'Storage Media'  (string)
  info.vendor = 'Sony'  (string)
  storage.drive_type = 'disk'  (string)
  block.storage_device = '/org/freedesktop/Hal/devices/block_8_16'  (string)
  storage.physical_device = '/org/freedesktop/Hal/devices/usb_usb_device_54c_8b_1_-1_noserial_0'  (string)
  storage.vendor = 'Sony'  (string)
  storage.model = 'Storage Media'  (string)
  storage.automount_enabled_hint = true  (bool)
  storage.no_partitions_hint = false  (bool)
  storage.media_check_enabled = true  (bool)
  storage.bus = 'usb'  (string)
  block.minor = 16  (0x10)  (int)
  block.major = 8  (0x8)  (int)
  info.capabilities = 'block storage'  (string)
  info.category = 'storage'  (string)
  info.parent = '/org/freedesktop/Hal/devices/scsi_26_0_0_0'  (string)
  block.device = '/dev/sdb'  (string)
  block.is_volume = false  (bool)
  block.have_scanned = false  (bool)
  block.no_partitions = false  (bool)
  linux.sysfs_path_device = '/sys/block/sdb'  (string)
  linux.sysfs_path = '/sys/block/sdb'  (string)
  info.bus = 'block'  (string)
You could use any unique identifier for the volume, but uuid is probably a safe bet. If there is no uniquely identifying features at the volume level, then things get a bit more complex, but it's still do-able (it's possible to reference the parent device from the volume, and use its attributes to distingish).

As long as all the match key statements in your .fdi file are true, then the merge key assignment will be done, and with that you can change your mount point.

That probably makes no sense, so hit me back and I'll clarify.
 
Old 01-27-2005, 08:48 PM   #7
leiavoia
Member
 
Registered: Mar 2002
Distribution: Debian Testing & Kubuntu
Posts: 72

Original Poster
Rep: Reputation: 15
looks like debian doesn't have devlabel support and udev requires kernel 2.6, i'm on 2.4.x :-(

I could try upgrading my kernel but i've never actually been successfull in doing so.
 
Old 01-28-2005, 05:38 AM   #8
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
You can grab the source for devlabel from here:
http://linux.dell.com/devlabel/devlabel.html

Dave
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Boot difficulty related to Grub and fstab? ? jiapei100 Linux From Scratch 1 02-26-2005 07:07 AM
Multi Boot difficulty related to Grub and fstab jiapei100 Linux - General 2 02-26-2005 07:07 AM
Editing fstab to mount devices? apachedude Suse/Novell 7 12-03-2004 04:35 AM
fstab and loop devices MBH Linux - Hardware 3 10-21-2004 08:58 AM
fstab and devices (making) TheBman Linux - Hardware 14 12-31-2003 09:55 AM


All times are GMT -5. The time now is 07:44 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration