Re: which drive is it?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



V Krish wrote:

I have three external USB drives connected to an AMD
machine running FC3. These are mounted as follows:
/dev/sda1 on /mnt/usb1
/dev/sdb1 on /mnt/usb2
/dev/sdc1 on /mnt/usb3


Is there some way to figure out which physical drive
is mounted on /mnt/usb2 so I can pull that one out
after a umount (short of disconnecting each in turn)?


Thank you,
Krish


Check out the udev help files: http://fedora.redhat.com/docs/udev/. Briefly, you can write a rule so that a particular drive is always mounted the same way
either by partition name or drive name (there are other options too, but I haven't needed them!)


Scott
Title: Fedora Project, sponsored by Red Hat
Site Navigation:
 
 

FC3 users please update to at least udev-039-10.FC3.1 after installation

Due to debugging code left accidently in the FC3 udev package, SIGCHLD signals are blocked in udev, which prevents getting the proper exit status in udev.rules. This means no cdrom symlinks are created and pam_console does not apply desktop user ownerships to any cdrom devices.

All users are urged to upgrade to this version after the installation of Fedora Core 3.

This update can be downloaded from here.

fce34e8e8ab6a54d07c46d2626529e22  SRPMS/udev-039-10.FC3.1.src.rpm
e86fc1ec12edddd4f7ca68bfebe956cc  x86_64/udev-039-10.FC3.1.x86_64.rpm
8b69da0b3adb624a11fc8185f98bada6  x86_64/debug/udev-debuginfo-039-10.FC3.1.x86_64.rpm
7df95371172d0b52452df76612cf674d  i386/udev-039-10.FC3.1.i386.rpm
9897ebb971ab099de04c9ceb1ad31b57  i386/debug/udev-debuginfo-039-10.FC3.1.i386.rpm
This update can also be installed with the Update Agent; you can launch the Update Agent with the 'up2date' command.

Udev on Fedora

by Harald Hoyer

This document tries to reveal the secrets of udev and how it works on Fedora.

udev was developed by Greg Kroah-Hartman <greg@xxxxxxxxx> with much help from Dan Stekloff <dsteklof@xxxxxxxxxx>, Kay Sievers <kay.sievers@xxxxxxxx>, and many others.

The udev homepage and the Linux-hotplug-devel mailing list https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel are the main development sources.

What Does Udev Do?

udev provides a dynamic device directory containing only the files for actually present devices. It creates or removes device node files usually located in the /dev/ directory, or it renames network interfaces.

As part of the hotplug subsystem, udev is executed if a kernel device is added or removed from the system. On device creation, udev reads the sysfs directory of the given device to collect device attributes like label, serial number or bus device number. These attributes may be used as keys to determine a unique name for the device. udev maintains a database for devices present on the system. On device removal, udev queries its database for the name of the device file to be deleted.

udev gets called by hotplug, if a module is loaded, and a device is added or removed. udev looks in /sys/, if the driver provides a "dev" file, which contains the major and minor number for a device node to communicate with the driver. After looking in the udev rules (in the /etc/udev/rules.d/ directory), which specify the device node filename and symlinks, a device node is created in /dev/ with the permissions, which are specified in /etc/udev/permissions.d/.

After device node creation, removal, or network device renaming, udev executes the programs in the directory tree under /etc/dev.d/. The name of a program must end with the .dev suffix, to be recognized. In addition to the hotplug environment variables, DEVNAME is exported to make the name of the created node or the name the network device is renamed to, available to the executed program. The programs in every directory are sorted in lexical order, while the directories are searched in the following order:
  • /etc/dev.d/$(DEVNAME)/*.dev
  • /etc/dev.d/$(SUBSYSTEM)/*.dev
  • /etc/dev.d/default/*.dev

How is Udev Integrated on Fedora?

initrd / initfs

mkinitrd copies /sbin/udev.static to the initrd /sbin/udev and symlinks it to /sbin/udevstart.

After the kernel boots, it executes the nash script of the initrd. This mounts a tmpfs filesystem on /dev/. Instead of hotplug /sbin/udev is called in the initrd phase. udevstart creates all device nodes for the devices, which are compiled in the kernel and for the modules, which are loaded by nash.

Problems

The whole udev and hotplug infrastructure is not available in initrd. Thus no hotplug scripts, udev rules, and permissions and no /etc/dev.d/ scripts are executed for any hotplug event, which is sent from the kernel.

rc.sysinit

First, if SELinux is loaded and enabled, the context of /dev/ is set. rc.sysinit calls /sbin/start_udev. start_udev mounts a tmpfs filesystem on /dev/, if there is none already mounted. Then it creates some device nodes, which need module autoloading, or where there is no kernel module. After that /sbin/udevstart is called again, which simulates the hotplug events in the initrd phase, to apply the whole udev rules and permissions. After that rc.sysinit parses the ouput of /sbin/kmodule and loads every module. This should provide device nodes for all hardware found on your computer.

Console User Permissions

/etc/dev.d/default/pam_console.dev is called whenever a device node is created and calls /sbin/pam_console_setowner with the filename (and an optional symlink) of the device node. This sets the permissions for console users like specified in /etc/security/console.perms.

Customizing Udev on Fedora

Read the manpage of udev and udevinfo. Please try not to modify the files of RPM packages.

New Rules

New rules should be placed in a file, which ends in .rules in /etc/udev/rules.d/. Please do not use 50-udev.rules. The supported and preferred way is to create rules without the "NAME" tag and only create "SYMLINK"s.

A nice document describing how to write rules can be found on http://www.reactivated.net/udevrules.php.

Permissions

New permissions should be placed in a file, which ends in .permissions in /etc/udev/permissions.d/. Please do not use 50-udev.permissions.

But I Really Want My Device Node!

Put them in /etc/udev/devices/, and they will get copied to /dev/. File a bugzilla entry, if you think that should be done per default.

Updating to udev Without /dev/

The steps to upgrade without Anaconda or a rescue CD are (NOT recommended):

  • start from a kernel-2.6
  • Make sure /sys/ is mounted
  • Install the latest initscripts package
  • Install the latest udev package
  • Execute /sbin/start_udev
  • Install the latest mkinitrd package
  • Install the latest kernel package
  • Or execute mkinitrd for your existing kernel(s)

Udev without initrd

Install Fedore Core as usual and reboot. Execute the following commands


mkdir /tmp/dev
mount --move /dev /tmp/dev
sbin/MAKEDEV null console zero
mount --move /tmp/dev /dev
Install your kernel without an initrd. Reboot.

You will get some SELinux errors, and syslogd will not work as expected.

Current Problems on Fedora

All open bugs for udev

Nvidia

Quick solution: If you do not need rhgb, just load the nvidia module in /etc/rc.local

If you have udev >= 032-5, load the nvidia module:


cp -a /dev/nvidia* /etc/udev/devices
chown root.root /etc/udev/devices/nvidia*

The Bugzilla for this problem is 133900.

Palm Pilot

If you have udev >= 032-5, execute the command:


ln -s ttyUSB1 /etc/udev/devices/pilot
or you may try something like this in /etc/udev/rules.d/10-custum.rules:

BUS="usb", SYSFS{product}="palmOne Handheld*", KERNEL="ttyUSB*", NAME{ignore_remove}="pilot", MODE="666"

ISDN

If you have udev >= 032-5:


/sbin/MAKEDEV -d /etc/udev/devices isdn
 
 

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux