[SOLVED] Mount USB at boot (reboot) and copy file
Dear all,
I am trying to mount a usb immediately after the boot and copy two files on my system.
At the moment I made the folllwing steps:
- creation of the directory /mnt/usb.
creation the following script startup with the following code for the user "pi"
sudo mount /dev/sda1 /mnt/usb -o uid=pi,gid=pi
sudo cp /mnt/usb/interfaces /etc/network/interfaces
sudo cp /mnt/usb/resolv.conf /etc/resolv.conf
if [ -f /mnt/usb/interfaces ]; then
sudo mv /mnt/usb/interfaces /mnt/usb/interfaces.done
fi
if [ -f /mnt/usb/resolv.conf ]; then
sudo mv /mnt/usb/resolv.conf /mnt/usb/resolv.conf.done
fi
sudo rebootInsetion of the script to the crontab file by adding the following row:
@reboot /home/pi/startup
The problem is that it does not work.
In the past I made a similar thing on my Raspberry but I cannot find out how to make it.
Note that, of course, we can use different usb stick with the files to be copied on the system.
Thanks.
Silvano
Eng. Silvano Bertoldo, PhD
Comments
-
Hi @Sil ,
Which Linux OS are you using on UP Squared?
What do you mean by it doesn't work? Is the USB stick not mounted? Also can you attach the log file?
-
Hello @DCleri,
I am using the Ublinux 4.0 dowloaded here: https://emutex.com/products/ubilinux.
"It does not work" means that it does not do anything. Apparently the content of the file is ignored.
I also tryed to add it in the crontab of root, but anything happens. It does not mount the USB in the case above only because it is the first operation, but, even if I try to create a directory it does not do anything.Silvano
Eng. Silvano Bertoldo, PhD
-
Actually the problem is the USB that is not mounted at startup...
Eng. Silvano Bertoldo, PhD
-
Please note the solution I reported here https://forum.up-community.org/discussion/3687/mount-usb-at-boot-reboot-and-copy-file#latest for mounting USB at boot.
@Sil said:
I solved my problem: please note that the ubilinux OS automount the USB key in /media/[user]/[USBlabel] immediately when it is plugged, and also when you boot the system.
After the boot, if you go to that folder you can find your USB.Silvano
The commanda @reboot works.
To avoid problem in lounching scripts @reboot ad a delay in the entry of root crontab file (to access this file type sudo crontab -e):
@reboot sleep 10 && yourscriptEng. Silvano Bertoldo, PhD
-
Hi @Sil
Thank you very much for your contribution and providing your workaround!