[SOLVED] Mount USB at boot (reboot) and copy file

SilSil New Member Posts: 29 ✭✭
edited May 2019 in UP Squared Linux

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 reboot

  • Insetion 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

Sign In or Register to comment.