这个补丁的主要作用是使pmount
使用方法很简单。比如,在/etc/fstab中添加一行:
如果想将U盘挂载到某一个指定的地方,方法稍微复杂一点。因为U盘可能因为插入的顺序不同使其设备名发生变化,所以我们需要先知道所要挂在U盘分区的UUID,而UUID是永远不变的,除非你重新格式化。此ID可以通过运行blkid获得。比如在终端下运行blkid后得到:
需要注意的是挂载目录名不能包含空格,另外fstab中的UUID字符串不需要加双引号。
以下是这个补丁的内容:
- 正确挂载有中文文件名的cd和ntfs/fat分区
- 根据fstab中的设定,选取设备的挂载点
使用方法很简单。比如,在/etc/fstab中添加一行:
/dev/hda1 /root/C盘 auto noauto,rw 0 0之后使用打过补丁的pmount就可以将/dev/hda1挂载到/root/C盘,而不是默认的/mnt/hda1。如果要挂载到别的地方,后面"auto noauto,rw 0 0"几个参数不需要改动,只要改第二个参数就可以了。
如果想将U盘挂载到某一个指定的地方,方法稍微复杂一点。因为U盘可能因为插入的顺序不同使其设备名发生变化,所以我们需要先知道所要挂在U盘分区的UUID,而UUID是永远不变的,除非你重新格式化。此ID可以通过运行blkid获得。比如在终端下运行blkid后得到:
# blkid /dev/loop1: UUID="52f8f4ce-245b-426c-972c-d0a580efcade" TYPE="ext2" /dev/sda1: UUID="F057-D3D4" TYPE="vfat" /dev/sdb1: SEC_TYPE="msdos" LABEL="STAPLES" UUID="D837-7888" TYPE="vfat"其中/dev/sda1是我经常使用的kingston的U盘,我想每次都将它挂载到/mnt/kingston,那么就在etc/fstab中加入一行:
UUID=F057-D3D4 /mnt/kingston auto noauto,rw 0 0这样插入那个U盘以后,运行pmount就可以将它挂载到指定目录。
需要注意的是挂载目录名不能包含空格,另外fstab中的UUID字符串不需要加双引号。
以下是这个补丁的内容:
--- /initrd/pup_ro2/usr/sbin/pmount 2008-04-07 06:11:00.000000000 -0400
+++ pmount 2008-05-17 19:35:05.000000000 -0400
@@ -205,19 +205,39 @@
DODEV="`echo -n "$EXIT" | cut -f 2 -d '_'`"
DEVNAME="`echo -n "$DODEV" | cut -f 3 -d '/'`"
DOFS="`echo -n "$EXIT" | cut -f 3 -d '_'`"
- mkdir -p /mnt/$DEVNAME
+
+ MNTPT="`cat /etc/fstab | awk -v "DEV=$DODEV" '$1==DEV {print $2; exit}'`"
+ if [ -z "$MNTPT" ]; then
+ UUID="`blkid | grep "^$DODEV:" | grep -o 'UUID=\"[^\"]*' | sed 's/\"//g'`"
+ MNTPT="`cat /etc/fstab | awk -v "DEV=$UUID" 'toupper($1)==toupper(DEV) {print $2; exit}'`"
+ fi
+ if [ -z "$MNTPT" ]; then
+ MNTPT=/mnt/$DEVNAME
+ else
+ MNTPT="`echo -n "$MNTPT" | sed 's/\\\\040/ /g'`"
+ # It seems that mount in PUP4 doesn't work if the mountpoint contains space character,
+ # so we fall back to old mountpoint in this case. If PUP4 fixes this problem in future,
+ # remove the following line, and this comment, of course.
+ echo -n "$MNTPT" | grep " " && MNTPT=/mnt/$DEVNAME
+ fi
+
+ mkdir -p "$MNTPT"
case $DOFS in
ntfs)
#'mount' is a script that takes care of mounting ntfs...
- mount -t ntfs $DODEV /mnt/$DEVNAME
+ mount -t ntfs -o nls=utf8 $DODEV "$MNTPT"
RETVAL1=$?
;;
vfat)
- mount -t vfat -o shortname=mixed $DODEV /mnt/$DEVNAME
+ mount -t vfat -o shortname=mixed,utf8 $DODEV "$MNTPT"
+ RETVAL1=$?
+ ;;
+ iso9660)
+ mount -t iso9660 -o utf8 $DODEV "$MNTPT"
RETVAL1=$?
;;
*)
- mount -t $DOFS $DODEV /mnt/$DEVNAME
+ mount -t $DOFS $DODEV "$MNTPT"
RETVAL1=$?
;;
esac
@@ -230,7 +250,7 @@
done
usleep 100000
#v3.95 -x option to rescan...
- exec rox -x /mnt/$DEVNAME -d /mnt/$DEVNAME #want this window on top.
+ exec rox -x "$MNTPT" -d "$MNTPT" #want this window on top.
#exit
else
xmessage -bg red -center -title "Pmount" "ERROR: unable to mount $DEVNAME" - 13948 次点击

发表新评论