This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

USB mont sometime failed
#1
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')
end
Reply
#2
(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.
Reply
#3
Hi Admin,

many thank for your answer.

Have a good new week !
Reply


Forum Jump: