Reflashing your device

#1

Your device contains an SD card with the AutoPi Core preinstalled. The SD card is located inside the device.

If you find yourself in need of reflashing your device, then you can always get the latest AutoPi Core image right here:

The image will work for all editions. We recommend using Etcher for flashing, it will take the GZ image directly and flash it:

Once you have flashed your device, you will need to have it re-accepted in the AutoPi Cloud. To do so, just send an e-mail to support@autopi.io with your device ID. Alternatively, prior to flashing you can manually backup the key files in /etc/salt/pki/minion. By copying these files to the same location on the new installation, you do not need to have your device re-accepted.

When your device comes online the first time, the WiFi hotspot will have the following setup:

WiFI
SSID: AutoPi-Initial
Password: autopi2018

Remember to update your device from the cloud after you reflash it, as that will ensure that all the configuration values are properly configured (like the WiFi SSID and password), and that the device has the correct authentication token for uploading data to the cloud.

best
Peter

3 Likes
Pair autopi Bluetooth with my car radio
No Modem with RPI3
No data in the Cloud after reflashing
[SOLVED] Problems with external power supply for DIY edition
Hostapd broken after update/upgrade
Problem with software update
Software update on the 4th of April - Bug fixes, Alerts and some stability fixes
Can't use AutoPi software on RPi. Local API is not yet ready
#2

yes, but we can’t because the sd card is protected from writing

I already found the folder, I can save it, but I can’t write. how can I do ?

#3

I assume you are talking about the location to where you want to copy the files and not the card it self being write protected.
You need to give the PI user (that’s the pre-setup system user you are logging in with) the access to write to the folder you want to copy the files to, or you can “sudo su root” and copy the files from a network source directly to the folder. Also be sure that the file and folder rights are the same before and after the copy, so system has the right access to read/write/execute the files.

#4

Thanks.

Yes, it is what I try to do, but still don’t know how to do.

Sudo su root, from autopi web terminal ?
Because ssh I can’t

#5

Im assuming you you have re-flashed your card and you have SSH access to the device?
Are you connecting to the AutoPi from Windows, Mac or Linux ?

#6

For me is best with Mac
Yes, because I had reflashing it few days ago, I can’t accès to ssh
I have pc windows too, so, I can try with but I don’t know how

#7

Ok, Im a Microsoft guy so cant help you with Mac “how to” since Mac is just a reskinned Linux in my Microsoft fan boy world :wink: but I can give you the steps I do when I re-flash my AutoPi. Do note that the way I do the Linux steps are not by any means the best Linux way to do it, im just a Microsfot guy so there is probably some better way to do the Linux commands and elevation of user access for the folders and pi user.

Before you re-flash the device, SSH in to AutoPi and manually backup the key files in /etc/salt/pki/minion to the computer you are SSH’ íng from. In my case that is a Microsoft PC connected to the AutoPi Wifi hotspot and using Putty (https://www.putty.org/) to SSH to the AutoPi.

  • To copy the minion files I use WinSCP (https://winscp.net/) to copy the files to my Windows PC.
  • in SSH session go to /etc/salt/pki/ and run the commands:

This command will copy the minion folder to new folder (This is not needed if you will scrap/re-flash the same card and not take a full backup of the card), I do this step since I usually take a full backup of the card in case I want to restore it later (Here I use foldername_DateofCopy: minioncopy09022019, but you can use any folder name you want).

sudo cp minion minioncopy09022019

This command will give owner rights access to User “pi” for the copied folder, this is required since WinSCP will use AutoPi user ‘pi’ to connect and we need the access rights to copy the folder content.

sudo chown pi minioncopy09022019

*Connect to your AutoPi with WinSCP and copy the content of the folder “minioncopy09022019” or the original “minion” if you did not make a copy and just gave pi user access to the original folder.

  • Re-flash the AutoPi card with the above instructions in the Guide.

  • Add the card back in to your hardware and boot up the AutoPi.

  • Connect to the AutoPi Wifi hotspot (since the re-flashed AutoPi now has the core images User and Password, you need to connect with User:pi Password: autopi2018)
    if you have connected with putty previously to the AutoPi then you will get a security warning about the host key windows has for the device (mac address) does not match the existing one:
    image
    Ignore the security warning as this will change again with the next steps (i.e select ‘yes’).

  • Open WinSCP and connect to your AutoPi and copy the backup of the minion folder from you computer to AutoPi.


    I copy my backup to the pi user location ‘/home/pi/’ but you can add it to any location on the AutoPi you think makes sense.

  • Open a SSH session to AutoPi and change user to root:

‘sudo su root’

  • And copy the files from the folder “minioncopy” to the folder /etc/salt/pki/minion
    Go to your backup folder that you copied over to AutoPi, in my case:

root@raspberrypi:/etc/salt/pki/minion# cd /home/pi/minioncopy09022019/

Copy the backup files to the minion folder:

root@raspberrypi:/home/pi/minioncopy09022019# cp minion_master.pub minion.pem minion.pub /etc/salt/pki/minion/

  • reboot the AutoPi so it can re-read the copied config files and connect to internet so it can re-connect with AutoPi server, go to https://my.autopi.io on any device of your choice and check that your AutoPi is online and then perform the update or other task you want from https://my.autopi.io .
1 Like
#8

Thank’s you so much ! I will try tomorow.
I wknown_hostsill try to do step by step.
But the first problem I have is that:

I know I should delete the “known_hosts” but I don’t know how

Then, when i solve this ssh problem, I can fellow your tuto.

#9

And where are you getting that error? On the AutoPi when trying to SSH in to it?
If you have the AutoPi connected to a screen through HDMI cable, just add a keyboard to it and log on locally on the AutoPi using the pi user and fix the SSH access rights or approved hosts access.

Br,
Mikael

1 Like
#10

Hello.
I am too bad because I can’t do it
I connect with WinSCP (ok)
I am connect as : pi (ok)
I use putty from scp and login as : pi
I write: cp /etc/salt/pki
Then I am in the folder
I write: sudo cp minion minioncopy
Then i have this: sudo: unable to resolve host autopi-ddfd00ac3465
So I try to login a root
I write: sudo su root
Then try again login as root:
Same problem

#11

Hi Remy

You can just ignore the “unable to resolve host”, it is a minor bug in our code, and will be fixed soon.

The last error in your screenshot is that you need to use the argument “-r” when copying the minion directory, this is needed when copying directories.
So instead try with the -r argument like so.

cp -r minion minioncopy

You only need to use sudo in the command, if you have not already executed “sudo -s”.
If the line in your terminal starts with “root@” like in your screenshot, then you are already running with the root privileges.

Best regards
/Malte

1 Like
#12

thanks
i succed …:grimacing::nerd_face:

2 Likes
#13

Yeap sorry, missed the -r argument while I was writing up the steps.

1 Like
#14

No problem :sweat_smile:
I am ready to flash again :slight_smile:

I just want to found before the known_hosts folder.
I can’t find on WinSCP

I need delete/edit ? the line where i usually connect from my Mac

#15

If you have no issue with SSH in to you device then ignore the error and continue.

#16

I just want to log again with my Mac ;).