|
樓主 |
發表於 2013-3-27 17:47:57
|
顯示全部樓層
令 Cubox 可以播放 USB 手指上的音樂檔
繼上文, 把 Cubox 改成 read-only file system 後, 個 music folder 改為 "/music/nas", 以下會講如何教系統自己detect 到有 USB 手指而去 mount.
先改番 root 做 read-write mode:生一個新 file:- vi /etc/udev/rule.d/11-auto-mount.rules
複製代碼 輸入以下後 save:- KERNEL=="mmc*", GOTO="auto_mount_end"
- KERNEL!="sd[a-z]*", GOTO="auto_mount_end"
- ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="auto_mount_end"
- # Set environment
- ACTION=="add", IMPORT{program}="/sbin/blkid -o udev -p -s TYPE -s LABEL %N"
- # Global mount options
- ACTION=="add", ENV{mount_options}="ro,relatime,users,umask=0"
- # Filesystem specific options
- ACTION=="add", ENV{ID_FS_TYPE}=="vfat", ENV{mount_options}="%E{mount_options},showexec"
- ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", ENV{mount_options}="%E{mount_options},utf8"
- # Get mount point
- # use basename to correctly handle labels such as ../mnt/foo
- ACTION=="add", ENV{ID_FS_LABEL}=="?*", PROGRAM="/usr/bin/basename '%E{ID_FS_LABEL}'", ENV{dir_name}="%c"
- ACTION=="add", ENV{dir_name}!="?*", ENV{dir_name}="usbhd-%k"
- # Main action
- ACTION=="add", ENV{dir_name}=="?*", RUN+="/bin/mkdir -p '/usb/usb/%E{dir_name}'", RUN+="/bin/mount -o %E{mount_options} /dev/%k '/run/usb/%E{dir_name}'"
- ACTION=="remove", ENV{dir_name}=="?*", RUN+="/bin/umount -l '/run/usb/%E{dir_name}'", RUN+="/bin/rmdir '/run/usb/%E{dir_name}'", RUN+="/bin/ln -s '/run/usb/%E{dir_name}' '/music/%E{dir_name}'"
- LABEL="auto_mount_end"
- # label must be cleared
- ENV{ID_FS_LABEL}=""
複製代碼 咁就OK了. 唔使 reboot, 只要插入 usb 手指 (可以係 ntfs / fat / ext2...) 咁 "music" 內會多左個 "usb" folder, 入去會見到有 USB 手指的 partition, 再入去會有手指內的歌 (MPD 要按 "update database" 或者 set 左 auto update) |
評分
-
1
查看全部評分
-
|