Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1812798
  • 博文数量: 473
  • 博客积分: 13997
  • 博客等级: 上将
  • 技术积分: 5953
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-22 11:52
文章分类

全部博文(473)

文章存档

2014年(8)

2013年(38)

2012年(95)

2011年(181)

2010年(151)

分类: LINUX

2012-06-22 10:49:23

    Note: HAL is deprecated. Use udev/PolicyKit/D-Bus instead.

    ()

   找到udev的页面,随便瞅了瞅,好像没有特别需要注意的,只是有提到自动挂载USB设备的问题,试了下蛮好用的,记录在这里。

   在/etc/udev/rules.d/建立文件disk.rules (名称随便取,但要以.rules为后缀),内容如下:

  KERNEL=="sd[b-z]", NAME="%k", SYMLINK+="usbhd-%k", GROUP="users", OPTIONS="last_rule"
  ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usbhd-%k", GROUP="users", NAME="%k"
  ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k"
  #ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/ln -s /media/usbhd-%k /mnt/usbhd-%k"
  ACTION=="add", KERNEL=="sd[b-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,sync,dirsync,noexec,nodev,noatime,uid=1000,gid=100,dmask=0002,fmask=0113 /dev/%k /media/usbhd-%k",   OPTIONS="last_rule"
  ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o umask=0,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
 #ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rm -f /mnt/usbhd-%k"
  ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k"
  ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"

 插入U盘后就在/media自动挂载为usbhd-sdb1,具有读写权限,搞定。

  参考 https://wiki.archlinux.org/index.php/Udev

阅读(913) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~