08-06-2015 09:04 AM
Hi all,
we have a cRIO-9030 with a USB-stick. Sometimes after power loss the USB-stick filesystem (FAT32) gets corrupted and has to be checked/fixed. How can I configure cRIO LinuxRT to do that?
I've checked /etc/fstab, but it looks that the USB-stick is mounted somewhere else. I run mount - here is the line:
/dev/sdc1 on /media/sdc1 type vfat (ro,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,quiet,errors=remount-ro)
It would be nice if I can run fsck.vfat /dev/sdc1 every boot or when an error is detected.
Thanks in advance,
Nikolai
Solved! Go to Solution.
08-12-2015 03:57 AM
Hi NickViz,
My name is Ed form National Instruments Technical Support, I have researched into the topic and found that it is possible to use the 'System Exec.vi' to complete the command during the initialization of your RT application.
You simply need to input your commands as a string just as you would to command prompt/terminal (depending on OS), you can also execute commands via SSH however this is one way communication between the RT application and the command shell.
I have included some links below to articles which describe the methodology as well as give some further explanation into the NI Linux Real-Time OS.
http://digital.ni.com/public.nsf/allkb/AFCAC25164CDBD4C86257C6A00545CD5?OpenDocument
http://digital.ni.com/public.nsf/allkb/9822A3A39B1D0CBB86257C55006B962A
http://www.ni.com/white-paper/14626/en/
I hope this is helpful and you achieve what it is you need, do note you will need to enable SSH scripting as described in the article on using PuTTY for your Real Time device.
Kind Regards,
Ed
09-04-2015 02:47 AM
Hello,
well actually it's not what I needed, so I had to discover everything myself. Anyway here is the solution, as it might be useful for somebody:
Here is the check script:
cat /etc/init.d/usb-check.sh
#!/bin/bash
umount /media/sdc1
fsck.vfat -a -f -w /dev/sdc1 >> /var/log/boot
mount /dev/sdc1 /media/sdc1
#mount -o remount,sync /media/sdc1
Installation:
The only one drawback I see in this solution is that for the heavily loaded USB stick with thousands of files the check might take noticeable time and slow down unit boot…
09-07-2015 02:36 AM
Hi NickViz,
Apologies that this was not the solution you were searching for, thank you for your response providing your solution. What I'll do is replicate the methodology and then create an article so that in future when this question is asked, the answer can be found in the public resources.
Once again thank you for your solution and I hope you are successful in your application.
Best Regards,
Ed
02-03-2020 02:28 PM - edited 02-03-2020 02:29 PM
Thanks for this great guide NickViz. One note, in step one of the installation, I had to run the command fsck.vfat instead of vfat.fsck .
@edjones93 does NI have any official documentation on this process yet? I couldn't find it with a cursory googling.
02-23-2020 04:00 PM
I ran into additional difficulty with this solution, and I thought I would post my solution here for the benefit of others. I was unable to write to the usb stick after boot from within a labview program. I was able to work around this by giving the lvuser read/write permissions while mounting the usb stick.
My script looks like the following:
#!/bin/bash
umount /media/sdb1 > /home/lvuser/usb_repair.log
fsck.vfat -a -f -w /dev/sdb1 >> /home/lvuser/usb_repair.log
# get UID and GID for the lvuser from the password file
LVUSER_UID=$(grep -oP "lvuser:\w:\K\d+" /etc/passwd)
LVUSER_GID=$(grep -oP "lvuser:\w:\d+:\K\d+" /etc/passwd)
mount /dev/sdb1 /media/sdb1 -o rw,uid=$LVUSER_UID,gid=$LVUSER_GID >> /home/lvuser/usb_repair.log
#mount -o remount,sync /media/sdb1