![]() |
|
USB mont sometime failed - Printable Version +- LogicMachine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: USB mont sometime failed (/showthread.php?tid=2653) |
USB mont sometime failed - SigmaTec - 23.05.2020 Hi all, I developed an Lua script which writes "csv" files on a USB 2.0 key. This cyclic script performs regular "mount / umount" (every 6 hours) to guarantee the maximum number of correct files in the event of micro power cuts. It works fine, but I have random errors on the mount as : "mounting / dev / sda1 on / mnt failed: no such file or directory". Do you have any explanations for this problem? Than'k in advance for your help ! --- here is the umout/mount standard script I user --- Code: devs = io.ls('/sys/class/block/')
table.sort(devs)
for _, dev in ipairs(devs) do
if dev:match('^sd%a%d$') then
part = dev
break
elseif not devn and dev:match('^sd%a$') then
devn = dev
end
end
part = part or devn
if part then
os.execute('umount -f /mnt 2>&-')
res, stat = io.readproc('mount /dev/' .. part .. ' /mnt 2>&1')
if stat == 0 then
alert('USB mount OK')
else
alert('USB mount failed: ' .. tostring(res)) -----------> this line returns the random errors...
end
else
alert('No valid USB devices found')
endRE: USB mont sometime failed - admin - 25.05.2020 (23.05.2020, 15:30)SigmaTec Wrote: This cyclic script performs regular "mount / umount" (every 6 hours) to guarantee the maximum number of correct files in the event of micro power cuts. This does not provide any benefit. You can mount once then simply run os.execute('sync') after writing to synchronize data to disk. RE: USB mont sometime failed - SigmaTec - 25.05.2020 Hi Admin, many thank for your answer. Have a good new week ! |