OS:Lede stable v17.01.4
Linux Kernel : 4.4.92
Problem:NTFS device cannot be mounted by 'block mount' command when option 'big_writes' was added to fstab.
All the package needed were installed correctly , so that when using 'mount -t ntfs -o noatime,nls=utf8,big_writes /dev/sda1 /mnt/sda1', it worked without any issue.
error log
Sat Apr 28 15:05:21 2018 kern.info kernel: [ 730.830095] usb 2-1: new high-speed USB device number 2 using ehci-platform
Sat Apr 28 15:05:21 2018 kern.info kernel: [ 730.982041] usb-storage 2-1:1.0: USB Mass Storage device detected
Sat Apr 28 15:05:21 2018 kern.info kernel: [ 730.988539] scsi host2: usb-storage 2-1:1.0
Sat Apr 28 15:05:22 2018 kern.notice kernel: [ 731.991300] scsi 2:0:0:0: Direct-Access SanDisk Cruzer Fit 1.00 PQ: 0 ANSI: 6
Sat Apr 28 15:05:22 2018 kern.notice kernel: [ 732.000895] sd 2:0:0:0: [sda] 15630336 512-byte logical blocks: (8.00 GB/7.45 GiB)
Sat Apr 28 15:05:22 2018 kern.notice kernel: [ 732.010005] sd 2:0:0:0: [sda] Write Protect is off
Sat Apr 28 15:05:22 2018 kern.debug kernel: [ 732.014838] sd 2:0:0:0: [sda] Mode Sense: 43 00 00 00
Sat Apr 28 15:05:22 2018 kern.notice kernel: [ 732.016010] sd 2:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Sat Apr 28 15:05:22 2018 kern.info kernel: [ 732.035402] sda: sda1
Sat Apr 28 15:05:22 2018 kern.notice kernel: [ 732.041852] sd 2:0:0:0: [sda] Attached SCSI removable disk
Sat Apr 28 15:05:23 2018 user.notice Auto-Mount: Block /dev/sda1 added.
Sat Apr 28 15:05:23 2018 user.notice Auto-Mount: UUID=A2F05308F052E1D9
Sat Apr 28 15:05:24 2018 user.notice Auto-Mount: New block.File system:ntfs
Sat Apr 28 15:05:25 2018 daemon.err block: /dev/ubiblock0_0 is already mounted on /rom
Sat Apr 28 15:05:25 2018 daemon.err block: /dev/ubi0_1 is already mounted on /overlay
Sat Apr 28 15:05:25 2018 kern.err kernel: [ 734.501143] ntfs: (device sda1): parse_options(): Unrecognized mount option big_writes.
Sat Apr 28 15:05:25 2018 daemon.err block: mounting /dev/sda1 (ntfs) as /mnt/sda1 failed (22) - Invalid argument
#!/bin/sh
set_fstab(){
my_fstype="`block info | grep "/dev/$device" | awk -F 'TYPE="' '{print $2}' | sed 's/\"//'`"
[ -n "$my_fstype" ] && {
logger -t Auto-Mount "New block.File system:${my_fstype}"
if [ "$my_fstype" = 'swap' ]; then
n=$(uci show fstab | grep "fstab.@swap" | grep -c "=swap")
[ $n -gt 0 ] && {
for i in $(seq 0 $n)
do
old_swap="$(uci get fstab.@swap[$i].device)"
[ "$old_swap" == "/dev/$device" ] && {
FLAG="SKIP"
break
}
done
}
[ "$FLAG" != "SKIP" ] && {
uci add fstab swap
uci set fstab.@swap[$n]="swap"
uci set fstab.@swap[$n].enabled='1'
uci set fstab.@swap[$n].device="/dev/$device"
}
else
n=$(uci show fstab | grep "fstab.@mount" | grep -c "=mount")
[ $n -gt 0 ] && {
for i in $(seq 0 $n)
do
old_mount="$(uci get fstab.@mount[$i].uuid)"
[ "$old_mount" == "${get_uuid}" ] && {
FLAG="SKIP"
break
}
done
}
[ "$FLAG" != "SKIP" ] && {
uci add fstab mount
uci set fstab.@mount[$n]="mount"
uci set fstab.@mount[$n].enabled='1'
uci set fstab.@mount[$n].uuid="${get_uuid}"
uci set fstab.@mount[$n].target="/mnt/$device"
uci set fstab.@mount[$n].fstype="$my_fstype"
case "$my_fstype" in
ext*)
uci set fstab.@mount[$n].options="noatime"
;;
'ntfs')
if [ $(lsmod | grep -c ufsd) -ge 1 ]
then
uci set fstab.@mount[$n].fstype="ufsd"
uci set fstab.@mount[$n].options="noatime,nls=utf8,force"
else
uci set fstab.@mount[$n].fstype="ntfs-3g"
uci set fstab.@mount[$n].options="noatime,iocharset=utf8,big_writes"
fi
;;
'exfat')
uci set fstab.@mount[$n].options="noatime"
;;
'vfat')
uci set fstab.@mount[$n].options="iocharset=utf8,umask=0000,dmask=0000,fmask=0000"
;;
*)
uci revert fstab
;;
esac
}
fi
uci commit fstab
}
}
del_fstab(){
del_disk=$(uci show fstab | grep "/mnt/$device" | awk -F '[' '{print $2}' | awk -F ']' '{print $1}' | sort -r )
[ -n "$del_disk" ] && {
for i in $del_disk
do
uci delete fstab.@mount[$i]
done
uci commit fstab
}
}
[ -e /etc/config/fstab ] || {
block detect > /etc/config/fstab
}
[ -e /etc/config/fstab ] && {
del_num=$(uci show fstab | grep ".enabled='0'" | awk -F '[' '{print $2}' | awk -F ']' '{print $1}' | sort -r )
[ -n "$del_num" ] && {
for i in $del_num
do
uci delete fstab.@mount[$i]
done
uci commit fstab
}
}
blkdev=`dirname $DEVPATH`
if [ `basename $blkdev` != "block" ]; then
device=`basename $DEVPATH`
mountpoint=`sed -ne "s|^[^ ]*/$device ||; T; s/ .*//p" /proc/self/mounts`
case "$ACTION" in
add)
get_uuid=`block info | grep "/dev/${device}" | awk -F "UUID=" '{print $2}'| awk -F "\"" '{print $2}'`
[ -n "$get_uuid" ] && {
mounted=`mount -l | awk '{print $1}'`
flag=0
for dev_mounted in $mounted ; do
if [ "/dev/${device}" == $dev_mounted ]; then
flag=1
fi
done
[ $flag != 1 ] && {
logger -t Auto-Mount "Block /dev/${device} added."
logger -t Auto-Mount "UUID=$get_uuid"
have_uuid=$(uci show fstab | grep -c "$get_uuid")
[ "$have_uuid" = "0" ] && {
mkdir -p /mnt/$device
chmod 777 /mnt/$device
set_fstab
block mount >> /dev/null 2>&1
}
}
}
;;
remove)
del_fstab
umount /mnt/$device
if [ $? -eq 0 ]
then
rmdir /mnt/$device
fi
esac
fi
This is my automount scrpit . No matter what filesystem devices have , finally mount them by ' block mount ' loading configuration from fstab.
fstab status:
root@PHICOMM_K3:~# uci show fstab
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@global[0].anon_mount='1'
fstab.@global[0].auto_swap='0'
fstab.@mount[0]=mount
fstab.@mount[0].enabled='1'
fstab.@mount[0].uuid='A2F05308F052E1D9'
fstab.@mount[0].target='/mnt/sda1'
fstab.@mount[0].fstype='ntfs-3g'
fstab.@mount[0].options='noatime,iocharset=utf8,big_writes'