Udev (正體中文)

From ArchWiki
Revision as of 20:07, 15 May 2006 by PJ (talk | contribs) (rm spam, spammer: Digdug)
Jump to navigation Jump to search

Tango-preferences-desktop-locale.pngThis article or section needs to be translated.Tango-preferences-desktop-locale.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Udev (正體中文)#)

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

其他關於 udev 的資訊可以參考下面的連接 :

從 initscripts 0.7 版開始, Arch 正式支援 Udev. 要在 Arch 內使用 Udev, 你的系統必須符合下面幾個要求:

  • initscripts v 0.7 或是更新的版本
pacman -Qs initscripts
  • kernel version 2.6.x
uname -r

要把系統轉換到 Udev 下,你需要執行下列幾個步驟.

修改系統的 kernel 啟動命令列

Arch 的 kernels 目前 (2.6.13 以前的版本) 在預設的狀況下會自動採用 devfs. 你必須修改系統啟動的命令, 加上 "devfs=nomount" 來告訴系統不要再繼續使用 devfs 了 :

GRUB: /boot/grub/menu.lst

kernel /vmlinuz26 root=/dev/discs/disc0/part3 ro devfs=nomount

LILO: /etc/lilo.conf

boot=/dev/hdx append="devfs=nomount"

(不要忘記在修改完畢後執行 /sbin/lilo)

接著你必須確定你的 bootloader 不再繼續使用 devfs 對硬碟分割區的命名規則:

udev        DevFS                 
/dev/fd0    /dev/floppy/0         
/dev/hda    /dev/discs/disc0/disc 
/dev/hdb2   /dev/discs/disc1/part2
/dev/hda3   /dev/discs/disc0/part3

所以, 在 grub 內, 以上面的例子作為範例, 正確的 kernel 命令列應該是

kernel /vmlinuz26 root=/dev/hda3 ro devfs=nomount

請注意 : 從 kernel 2.6.13 版開始, devfs 的支援已經在預設的狀況下被取消了. 所以如果你使用的 kernel 版本是 2.6.13 或是更新的版本, 你就不需要在 kernel 命令列上再指定 devfs=nomount 這個選項了

安裝 udev 套件

pacman -S udev

編輯 /etc/fstab

請先把 sysfs 這一行設定註解掉,然後 "usbdevfs" 這一行設定必須改為使用 "usbfs" (在同一行內有兩個地方要修改). 最後, 請檢查 /etc/fstab 內是否一行設定包含了 /dev/shm 這個指定. 在編輯完 /etc/fstab 後,上面提到的這幾行應該看起來如同下面列出的一般 :

#sysfs /sys sysfs defaults 0 0
usbfs /proc/bus/usb usbfs defaults 0 0
none /dev/shm tmpfs defaults 0 0
none /dev/pts devpts defaults 0 0

你可能還需要把 /etc/fstab 這個檔案內的其他設定也依照上面的解釋一併修正,以符合 udev 的命名規則.

Make sure you use the /dev/hda1 format and not /dev/discs/disc0/part1 in /etc/fstab or you will get a false report of corrupt disk on booting.


大功告成, 系統轉換完畢.

警告 : 無法開啟一個 initial console


WARNING: Unable to open an initial console
  • 拿出你的 ArchLinux 安裝光碟然後用他來開機
  • 掛載上你的 root 硬碟分割區 (例如 : "mount /dev/discs/disc0/part3 /mnt")
  • 鍵入 chroot 轉移到新的掛載目錄上 (例如 : "chroot /mnt")
  • 用下面的指令在 /dev 下建立缺少的 static nodes (靜態節點) :
cd /dev
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3

These nodes are required for starting Udev. You might have both/only one of them/none missing.

More information here.


如果你的系統一直不停的連續重啟, 你可能需要把 menu.lst 裡面的下面這一行移除 :


然後當系統啟動完畢後, 請在終端機模式的命令列下鍵入:


現在,你可以再把 devfs=nomount 這一行放回 menu.lst 這個檔案內然後重新啟動系統. 這應該可以解決系統連續重啟的問題.

使用者自訂 Udev

When udev starts up, it will read all .rules files in /etc/udev/rules.d/. When udev is adding a device node, it reads these rules files in lexicographical order until it finds a match. That means that if you need any customizations, you should create a file that is lexicographically-less than the default file, udev.rules. It is the Arch custom to use 00.rules for customizations, but obviously you can be more creative if you wish.

You should not edit the /etc/udev/rules.d/udev.rules file yourself, as it is used by the developers to improve the default ruleset for new users. If you need to tweak a rule from the default ruleset, just copy the line(s) and paste them into a 00.rules file.

下面這一部份只適用於 udev >= 053


The latest version of udev has some upstream changes in the configuration layout.

Permissions and user/group ownership are no longer defined in separate files -- instead they are specified within the rules file itself. Look at /etc/udev/rules.d/udev.rules for examples.

This means that any custom permissions need to be moved into a rules file like /etc/udev/rules.d/udev.rules or /etc/udev/rules.d/00-my.rules. The old files in etc/udev/permissions.d/ have no effect anymore and can be removed.

See the udev(8) manpage for more information on writing rules. The files in etc/udev/permissions.d/ have no effect anymore and can be removed.

The normal user shouldn't need to define new rules, all you have to do is to add the user to the right groups in /etc/group:

gpasswd -a <username> video
gpasswd -a <username> audio
gpasswd -a <username> optical
gpasswd -a <username> floppy
gpasswd -a <username> storage
gpasswd -a <username> scanner

關於 group 權限的解說 :

video: enable tv cards, framebuffer devices (not! graphic cards they belong to users group)
audio: get access to sound devices and rtc
optical: allow burning and ripping from cd/dvd devices
floppy: allow formating and partitioning on floppy devices
storage: allow formating and partitioning on removable storage devices, like usbsticks or usb harddrives.
scanner: allow using the scanner devices

Symlinks of cd/dvd devices are done automatically and should fit your needs.


  • 如果你更新到 udev >=053 同時系統無法辨識你的 usb 拇指碟,請記得從新開機,然後一切應該都會恢復正常了

下面的部分只適用於 udev <= 050


The ruleset used by Udev is located in /etc/udev/*. If you modify them, be sure to add the files to a NoUpgrade rule in your pacman.conf.

It may be easier, however just to create your own rules and permissions files. Udev behavior for a given device is governed by the first rule it finds that matches that device. By using a prefix of '00-' (those are zeros not 'oh's) on your files, you can make sure that your rules are seen first. The file name must end in either .rules or .permissions, otherwise it is ignored.

An example permissions file (/etc/udev/permissions.d/00-myrules.permissions):

# audio devices

# disk devices for having access to audioripping and burning

# v4l devices for tv and radio cards

# scsi devices, for scsi scanners or cd writers

Some other notes

    If you cannot get any sound out of your boxes, although you have configured your permissions right, try running alsaconf as root that adds some aliases to modprobe.conf and use a mixer like alsamixer to check if not any "special" feature like 3D Sound or something else is activated and check the volumes too. After that add to your rc.conf modules list:
    snd-card-0 snd-pcm-oss
    and it should be done.
    If you want to access your cdrom for audioripping or cdburning you must change the permissions of the \"real\" disc device (eg hd*). Changing the permissions on symlinks won't work.
    ttyS* needn't to be set if pppd is run suid root
    For printing nothing has to be changed. cups runs as root.
    usb-sticks and harddisks usually have an entry in fstab and so if "users" is set in fstab no problem with that
    usbscanners don't need to be changed. Most scanner applications use libusb which does not talk to the device nodes. You have to set up hotplug properly to get the scanners to work. if they worked before they should work with udev too.

Symlinking devices

this is only an example but it should be clear how it works. Add this at the /etc/udev/rules.d/00-myrules.rules:

# cdrom/cdrw links
KERNEL="hdc", SYMLINK="dvd"
KERNEL="hdd", SYMLINK="cdrom cdrecorder"
#important for modem users, change to ttyS1 if serial port 2 is used
KERNEL="ttyS0", SYMLINK="modem"

to check if your symlinks work or to restart udev: