« 上一篇下一篇 »

Padavan系统无法修改USB硬盘挂载目录和smb共享名的解决

问题:

自定义脚本无法设置自定义USB-disk的挂载目录。导致samba共享名无法改成自己喜欢的

研判:

1、自定义脚本里有判断语句,如果曾经挂载了/dev/sda1之类的,就不再挂载之

2、启动过程中,有多处调用了automount $MDEV AiDisk_%c%s,导致即使自定义,也晚了

        观察 /tmp/syslog.log 可见,在启动初期即有 automount.sh /dev/sda1  /media/AiDisk_a1 的记录

3、(?存疑)run_ftpsamba 语句会 调用 automount.sh $MDEV AiDisk_%c%s 从而影响挂载名称

4、mtd_storage.sh 以及在 /sbin 下的都是只读系统,无法修改这些sh

5、本例出现在Hiboyhiboy编译20-05-1版本。

        另一台9-06-18版 插tf卡,未出现automount /dev/mmcblk0p1现象


非完美解决方法:   在自定义脚本中,

1、注释掉,判断是否已经挂载的语句。即使有挂载过,此处仍旧挂载

            TF卡这里:# [ ! -z "$(df -m | grep $mmc_mount )" ] && continue

和,usb-disk这里:# [ ! -z "$(df -m | grep $sd_mount )" ] && continue


2、减除之前automount /dev/sda1 /media/AiDisk_a1 的影响

在启动后脚本里,各个automount语句之前,umount上述挂载(详见最后)。


3、小修正,挂载若干分区而非整个硬盘或tf卡:

如果查询/dev/sda* 时候出现 /dev/sda 结果,不需要挂载,应退出本次for循环

即:修改     # [ -z "$partno" ] && partno=1

                  [ -z "$partno" ] && continue

同理,修改tf卡的这一部分:

                   #[ -z "$partno" ] && partno=1

                    [ -z "$partno" ] && continue


其他:无法定时重启问题,是crond进程因各种原因被kill掉了,

解决:在自定义脚本,启动后脚本,的最后面加上重启crond

#重启动crond

/usr/sbin/crond &

logger -t "【运行路由器启动后】" "crond此前被kill了,再启动之。"


===========

相关知识

===========

Padavan 系统中大部分目录都是只读的,可只有少数会提示 Read only file system ,其他没提示的目录看似可写,但写入的内容并不会被保存,在重启之后就消失了。 https://panfake.com/2019/01/padavan-settings-files-lost-after-reboot/

只有/etc/storage目录的内容会在重启之后被保存。所以为了文件不丢失,都需要传到该目录下。


但需要注意的是,由于Padavan系统的特殊性,关键目录以外的目录均为 tmpfs ,可以理解为是把数据暂存在内存上。因此在/etc/storage目录里所做的修改,如果没有执行保存脚本,就并没有真正的写入 Rom 里,重启之后文件还会丢失。


因此在上传文件后,需要执行保存脚本:/sbin/mtd_storage.sh save

或在Padavan后台页面中,在 高级设置>系统管理>“保存 /etc/storage/ 内容到闪存” 点击提交。


httpd: write textarea to file storage MTD partition : started_script.sh

May 22 19:05:37  == mtd_storage.sh == : 保存 /etc/storage/ 内容到闪存!请勿关机

May 22 19:05:42  == mtd_storage.sh == : 保存 /etc/storage/ 内容到闪存!执行完成

===========

相关知识

===========

在众多 /sbin/下面的程序里都有调用 /sbin/automount.sh $MDEV AiDisk_%c%s

[Padavan /sbin]# grep -r "AiDisk" .

./ddns_updated:/sbin/automount.sh $MDEV AiDisk_%c%s

./detect_internet:/sbin/automount.sh $MDEV AiDisk_%c%s

./detect_link:/sbin/automount.sh $MDEV AiDisk_%c%s

./detect_wan:/sbin/automount.sh $MDEV AiDisk_%c%s

./ejall:/sbin/automount.sh $MDEV AiDisk_%c%s

./ejusb:/sbin/automount.sh $MDEV AiDisk_%c%s

./ejusb1:/sbin/automount.sh $MDEV AiDisk_%c%s

./halt:/sbin/automount.sh $MDEV AiDisk_%c%s

./hotplug:/sbin/automount.sh $MDEV AiDisk_%c%s

./init:/sbin/automount.sh $MDEV AiDisk_%c%s

./lan_eeprom_mac:/sbin/automount.sh $MDEV AiDisk_%c%s

./leds_ether:/sbin/automount.sh $MDEV AiDisk_%c%s

./leds_front:/sbin/automount.sh $MDEV AiDisk_%c%s

./mdev_lp:/sbin/automount.sh $MDEV AiDisk_%c%s

./mdev_net:/sbin/automount.sh $MDEV AiDisk_%c%s

./mdev_sd:/sbin/automount.sh $MDEV AiDisk_%c%s

./mdev_sg:/sbin/automount.sh $MDEV AiDisk_%c%s

./mdev_sr:/sbin/automount.sh $MDEV AiDisk_%c%s

./mdev_tty:/sbin/automount.sh $MDEV AiDisk_%c%s

./mdev_wdm:/sbin/automount.sh $MDEV AiDisk_%c%s

./mtd_storage.sh:/sbin/automount.sh $sd_mount AiDisk_$device_name$partno

./mtk_esw:/sbin/automount.sh $MDEV AiDisk_%c%s

./mtk_gpio:/sbin/automount.sh $MDEV AiDisk_%c%s

./ntpc_updated:/sbin/automount.sh $MDEV AiDisk_%c%s

./ovpn_export_client:/sbin/automount.sh $MDEV AiDisk_%c%s

./pids:/sbin/automount.sh $MDEV AiDisk_%c%s

./radio2_disable:/sbin/automount.sh $MDEV AiDisk_%c%s

./radio2_eeprom_mac:/sbin/automount.sh $MDEV AiDisk_%c%s

./radio2_enable:/sbin/automount.sh $MDEV AiDisk_%c%s

./radio2_guest_disable:/sbin/automount.sh $MDEV AiDisk_%c%s

./radio2_guest_enable:/sbin/automount.sh $MDEV AiDisk_%c%s

./radio2_restart:/sbin/automount.sh $MDEV AiDisk_%c%s

./radio2_toggle:/sbin/automount.sh $MDEV AiDisk_%c%s

./radio2_toggle_off:/sbin/automount.sh $MDEV AiDisk_%c%s

./radio2_toggle_on:/sbin/automount.sh $MDEV AiDisk_%c%s

./rc:/sbin/automount.sh $MDEV AiDisk_%c%s

./reboot:/sbin/automount.sh $MDEV AiDisk_%c%s

./reset_to_defaults:/sbin/automount.sh $MDEV AiDisk_%c%s

./restart_dhcpd:/sbin/automount.sh $MDEV AiDisk_%c%s

./restart_dns:/sbin/automount.sh $MDEV AiDisk_%c%s

./restart_firewall:/sbin/automount.sh $MDEV AiDisk_%c%s

./restart_networkmap:/sbin/automount.sh $MDEV AiDisk_%c%s

./restart_vpn_client:/sbin/automount.sh $MDEV AiDisk_%c%s

./restart_vpn_server:/sbin/automount.sh $MDEV AiDisk_%c%s

./restart_wan:/sbin/automount.sh $MDEV AiDisk_%c%s

./rstats:/sbin/automount.sh $MDEV AiDisk_%c%s

./run_aria:/sbin/automount.sh $MDEV AiDisk_%c%s

./run_ftp:/sbin/automount.sh $MDEV AiDisk_%c%s

./run_ftpsamba:/sbin/automount.sh $MDEV AiDisk_%c%s

./run_nfsd:/sbin/automount.sh $MDEV AiDisk_%c%s

./run_samba:/sbin/automount.sh $MDEV AiDisk_%c%s

./run_telnetd:/sbin/automount.sh $MDEV AiDisk_%c%s

./shutdown:/sbin/automount.sh $MDEV AiDisk_%c%s

./start_ddns:/sbin/automount.sh $MDEV AiDisk_%c%s

./stop_aria:/sbin/automount.sh $MDEV AiDisk_%c%s

./stop_ftp:/sbin/automount.sh $MDEV AiDisk_%c%s

./stop_ftpsamba:/sbin/automount.sh $MDEV AiDisk_%c%s

./stop_nfsd:/sbin/automount.sh $MDEV AiDisk_%c%s

./stop_samba:/sbin/automount.sh $MDEV AiDisk_%c%s

./stop_wan:/sbin/automount.sh $MDEV AiDisk_%c%s

./usb5v:/sbin/automount.sh $MDEV AiDisk_%c%s

./wan_eeprom_mac:/sbin/automount.sh $MDEV AiDisk_%c%s

./watchdog:/sbin/automount.sh $MDEV AiDisk_%c%s

./zerocd:/sbin/automount.sh $MDEV AiDisk_%c%s

===========

相关知识: 修改 启动后脚本

===========

#!/bin/sh

### Custom user script

### Called after router started and network is ready

### Example - load ipset modules

modprobe ip_set

modprobe ip_set_hash_ip

modprobe ip_set_hash_net

modprobe ip_set_bitmap_ip

modprobe ip_set_list_set

modprobe xt_set


/etc/storage/www_sh/menu_title.sh &


#confdir=`grep "/tmp/ss/dnsmasq.d" /etc/storage/dnsmasq/dnsmasq.conf | sed 's/.*\=//g'`

#if [ -z "$confdir" ] ; then

   confdir="/tmp/ss/dnsmasq.d"

#fi

[ ! -d "$confdir" ] && mkdir -p $confdir


# SMB资源挂载(局域网共享映射,无USB也能挂载储存空间)

# 说明:【192.168.123.66】为共享服务器的IP,【nas】为共享文件夹名称

# 说明:username=、password=填账号密码,删除代码前面的#启用功能。

#sleep 10

#modprobe -q ext4

#modprobe des_generic

#modprobe cifs CIFSMaxBufSize=64512

#mkdir -p /media/cifs

#mount -t cifs //192.168.123.66/nas /media/cifs -o username=user,password=pass,dynperm,nounix,noserverino,file_mode=0777,dir_mode=0777

sleep 5

stop_ftpsamba

sleep 3

#mdev -s


# 挂载SD卡

for mmc_mount in `/usr/bin/find  /dev -name 'mmcblk[0-9]*' | awk '{print $1}'`

do

#[ ! -z "$(df -m | grep $mmc_mount )" ] && continue

mmc_mount=$(basename $mmc_mount | awk '{print $1}')

echo $mmc_mount

device_name=`echo ${mmc_mount:6:1}`

partno=`echo ${mmc_mount:8:1}`

#[ -z "$partno" ] && partno=1

    [ -z "$partno" ] && continue

   umount /media/AiCard_$device_name$partno

/sbin/automount.sh $mmc_mount  TFCard$device_name$partno

done


# 挂载USB存储设备

for sd_mount in `/usr/bin/find  /dev -name 'sd[a-z]*' | awk '{print $1}'`

do

# [ ! -z "$(df -m | grep $sd_mount )" ] && continue

sd_mount=$(basename $sd_mount | awk '{print $1}')

echo $sd_mount

device_name=`echo ${sd_mount:2:1}`

partno=`echo ${sd_mount:3:1}`

# 仅挂载分区,如果第三位是空,说明是整个硬盘,退出该次循环

# [ -z "$partno" ] && partno=1

     [ -z "$partno" ] && continue

   umount /media/AiDisk_$device_name$partno

/sbin/automount.sh $sd_mount  UsbDisk$device_name$partno

done


#点亮USB的LED(本例里是 GPIO39)

echo 39 > /sys/module/usbcore/parameters/usb_led_gpio

mtk_gpio -w 39 1

logger -t "【运行路由器启动后】" "mount U盘,mtk_gpio -w 39 1,桔黄LED"


sleep 3

run_ftpsamba   #重启动ftp、samba服务

sleep 3


### 运行脚本1

/etc/storage/script_script.sh

/etc/storage/script/sh_ezscript.sh 3 & #更新按钮状态

logger -t "【运行路由器启动后】" "脚本完成"


#启动流量监控脚本

mkdir -p /tmp/bwmon

/usr/sbin/bwmon &


#重启动crond

/usr/sbin/crond &

logger -t "【运行路由器启动后】" "crond此前被kill了,再启动之"