I like to solve my own problems
The problem happens when you have partitions in your harddrive/usb stick wich filesystem is not FAT/NTFS or ext. I my case, I have a swap partition and this causes the script to die abnormally (tries to calculate the size) and never removes the lock files.
My suggestion is to add a better handling for the type detection in
/etc/init.d/usb_storage. What I did was:
Before:
Code: Select all
if [ "$type" = "FAT32" ] || [ "$type" = "FAT16" ] ; then
mkdir -p "/tmp/usb_mount/$id"
chmod 777 "/tmp/usb_mount/$id"
umount "/tmp/usb_mount/$id" 2>/dev/null
err=$(mount -t vfat -o umask=0,dmask=0 "$d" "/tmp/usb_mount/$id")
elif [ "$type" = "NTFS" ] ; then
mkdir -p "/tmp/usb_mount/$id"
chmod 777 "/tmp/usb_mount/$id"
umount "/tmp/usb_mount/$id" 2>/dev/null
err=$(ntfs-3g "$d" "/tmp/usb_mount/$id")
elif [ -n "$type" ] ; then
mkdir -p "/tmp/usb_mount/$id"
chmod 777 "/tmp/usb_mount/$id"
umount "/tmp/usb_mount/$id" 2>/dev/null
err="tmp"
ext_num=4
while [ -n "$err" ] && [ $ext_num -ge 2 ] ; do
type="ext$ext_num"
err=$(mount -t $type -o noatime "$d" "/tmp/usb_mount/$id" 2>&1)
ext_num=$(($ext_num-1))
done
fi
After
Code: Select all
if [ "$type" = "FAT32" ] || [ "$type" = "FAT16" ] ; then
mkdir -p "/tmp/usb_mount/$id"
chmod 777 "/tmp/usb_mount/$id"
umount "/tmp/usb_mount/$id" 2>/dev/null
err=$(mount -t vfat -o umask=0,dmask=0 "$d" "/tmp/usb_mount/$id")
elif [ "$type" = "NTFS" ] ; then
mkdir -p "/tmp/usb_mount/$id"
chmod 777 "/tmp/usb_mount/$id"
umount "/tmp/usb_mount/$id" 2>/dev/null
err=$(ntfs-3g "$d" "/tmp/usb_mount/$id")
elif [ -n "$type" ] ; then
mkdir -p "/tmp/usb_mount/$id"
chmod 777 "/tmp/usb_mount/$id"
umount "/tmp/usb_mount/$id" 2>/dev/null
err="tmp"
ext_num=4
while [ -n "$err" ] && [ $ext_num -ge 2 ] ; do
type="ext$ext_num"
err=$(mount -t $type -o noatime "$d" "/tmp/usb_mount/$id" 2>&1)
ext_num=$(($ext_num-1))
done
else
err="not mountable partition"
fi
Note the else/err= assignment, this will cause the next if to not try to do any calculation with such useless partitions.
hope this helps someone