AnsweredAssumed Answered

USB hotplug

Question asked by yuhundehao yuhundehao on Aug 17, 2017
Latest reply on Aug 17, 2017 by igorpadykov

我有个问题 我用的是ixm6q 文件系统支持优盘连接上后,拷贝和存储数据到优盘或者板子拔掉优盘数据不能保存

我自己做了个udev规则:

  

ACTION !="add",GOTO="farsight"
KERNEL=="sd[a-z][0-9]",RUN +="/sbin/mount-usb.sh %k"
LABEL="farsight"

ACTION !="remove",GOTO="farsight"
SUBSYSTEM !="block",GOTO="farsight"
KERNEL=="sd[a-z][0-9]",RUN +="/sbin/umount-usb.sh"
LABEL="farsight"

mount-usb.sh

#!/bin/sh
! test -d "/media/sda1" && mkdir -p "/media/sda1"
/bin/mount -t vfat /dev/$1 /media/sda1
sync

umount-usb.sh 
#!/bin/bash
sync
umount /media/sda1
cd /media
rm -rf sda1

 

但是在sync后拔掉优盘还是不能拷贝到优盘里的数据还是没有保存 rn -rf sda1都已经执行了

Outcomes