Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Using wpa_supplicant.conf file on the emonSD boot partition

i understand this, but I am using Raspberry PI zero and I am thinking in First boot without Ethernet.

Now I start the process with a Raspberry 2 with ethernet and then I move the SD to a Raspberry PI zero, I am trying to configure Wifi user and password before frist boot.

I am working with Virutal Box Ubuntu, I think nowadays there is not another solution.

Thank you Paul

Ah, yes. That is a weakness of the current emonSD.

I would certainly expect so, but I have no experience with using Virtual Box.

How many first boots are you anticipating? For one or two, accessing the image to edit via a linux OS (or utility) is going to be ok.

If you are deloying lots of Pi zero’s or expacting to reinstall often, you could do my suggested move and symlink to one image using the Pi2 and create your own image for deploying to ther devices with an editable /boot/wifi.conf.

Or why not just keep a standard Raspbian SDcard for use in the Pi2 and plug your emonSD cards into that with a card reader for editing?

I am using http://www.ext2fsd.com/?page_id=16

I am accesing to Linux partition without any problem.

Any of the other solutions you provied are more complicated for me.

I think the best option is to make this with a Pure Linux Distribution in a laptop (not a virtualbox). Virtualbox is a bit hard because I have to create a raw partition to access SD and I must do it manually and one by one.

I am very interested in this solution. Can you explain me better? I do not understand symlink and I do not understand the process in general.

Thank you very much Paul

Hi again:

Finally it is difficult to solve the Read only system problem using only Windows.

I could do the change or wifi ssid and password doing that:

1- Virtual box installation UBUNTU
2- Create a Raw SATA HDD referencing SD (PHYSICAL DRIVE 2 in my case). VirtualBox direct access to SD Card in Windows – Sandy Scott's Web Spot
3- In Ubuntu terminal.
sudo chmod 777 -R ‘folder to change’
4- Change network/interfaces configuration

I would like to do easily. Any recomendation to change read-only permisson faster or any solution with less steps.

Thanks!

I am thinking one thing?

Is it there any problem if I “open” the permissons to etc/network folder and I am able to change interfaces with Notepad ++ in Windows directly using Ext2fsd application

Is it any security inconvenient?

Any other option?

Thanks.

If I open the permissons for wpa_configuration folder Will copy/paste boot partition wpa_configuration file to the raspberry?

I will test it now, I will report in a while.

I need to take a closer look at this as I had forgotten that the emonSD images wpa_supplicant file is already symlinked and placed on the writable /data partition. This may play havoc on trying to edit the file whilst it is mounted on another host OS, either VM or Linux box etc.

The emonSD image is altered this way so that the wifi page from emoncms can edit the wifi details.

I think symlinking the file from /boot to /data might be easiest, I will need to study the emonpi fs again and give it a try to be sure.

This is for me the best option.

Efectively wpa_supplicant is the configuration file and it is moved by symlink according to the emonSD guidelines to home/pi

I do not know how to change boot script. How can I do it? Any tutorial or something?

Thanks.

Unfortunately it might not be that straight forward because of the way the emoncms wifi config module, the read-only filesystem and the windows compatible boot partition work.

In theory you could move and symlink the ~/data/wpa_supplicant.conf file to the /boot partition so that everyone can find it and you can edit it in windows, however from the Raspbian OS, only root can write to the /boot partition, so the emoncms module may fail to write to the symlinked file on the /boot partition. You could try it I guess…

sudo mv /home/pi/data/wpa_supplicant.conf /boot/wifi.conf
sudo ln -s /boot/wifi.conf /home/pi/data/wpa_supplicant.conf

…actually, having just checked the file location I can see the wpa_supplicant file is already owned by root:root so it should work…

let us know…

It’s easy using Linux, just pop the SD card out of the RasPi and into your computer than edit ~/data/wpa_supplicant.conf .

On windows it should be quite straightforward to use something mount the ext file system using one of them methods mentioned below:

Or just use a linux VM.

Moving the file to the /boot partition is an option but I would do this with caution as it may cause unintended consequences and cause issues with future updates.

OK, the right address is /data/wpa_supplicant.conf

I prefer to edit it via Virtual Box UBUNTU, When I use ExtFsd or other Pure Windows Tools I can not write because it is a Only-Read Partition.
How I can fix it using only windows? I can not change this without open Windows

Is it /data/wpa_supplicant.conf a writtable folder?

Thanks Glyn

It maybe when using a windows utility…

The correct address when mounted on the emonSD’d OS is /home/pi/data/wpa_supplicant.conf Glyn’s reference of~/data/wpa_supplicant.conf uses “~” which is a linux shortcut for “the current users home/root directory” which only when accessed via the emonSD by user pi will be /home/pi.

Since the 3rd partition is mounted as /home/pi/data that is the most accurate path whilst mounted ie via the emonSD OS.

data is an ext2 linux partition, when using a “windows reader utility” to read the linux partition, it is not writable. However it is writable when mounted in a linux OS. The windows readers tend to make a copy of the file that windows can read, in which case any edits will be to a windows only copy file and not to the original linux file, so no change when you put the card back in the emonpi.

The ONLY way of doing it with “windows only” is to put the file on the vfat formatted boot partition, it is the only partition that is recognized by both linux and windows, that is the reason it exists.

This is always good advice, more so when editing the emonSD as it’s difficult to predict what may change. But since the wpa_supplicant.conf cannot be “just overwritten” by the emonpi updater deleting and replacing it without losing users wifi settings, it is unlikely this move will prevent future updates. The one time I would predict trouble would be IF the OS was writable and a wpa_supplicant.conf file was accidentally added to the boot partition before a reboot, since the OS is RO and this function doesn’t work, this is unlikely to happen.

Any move from “stock” emonSD could comeback and bite you. But it is the only way to do this without a 2nd linux OS (VM or Pi etc) AFAICT.

1 Like

So, finally the best options are:

1- Use Extfsd Windows aplication (it is able to write in writtable ext2 partitions). I like this option I will try it.

2- As Paul explain before make a symlink from data/wa_supplicant.conf to boot/wifi.conf. In this option I do not why you change the name of the file. I supouse you are preventing any problem copy/pasting a “wpa_supplicant.conf” file accidentaly as you explain.

I think I have more than enough solutions to do it very fast.

Cheers!

Just be sure to thoroughly test it. This is a quote from the link Glyn provided, about ext2fsd.

“While you can theoretically enable support for writing to Linux partitions, I haven’t tested this. I’d be worried about this option, myself—a lot can go wrong. Read-only support is fine, though, and doesn’t carry a risk of messing anything up.”

Which I would agree with, just because you CAN write to a linux file from a windows utility, it doesn’t mean the file will still be 100% intact from linux’s perspective. We would hope so though…

Yes I know it.

So the best option is to symlink to boot, thats right?

Any final recommendation?

Thanks.

Try both and go with the one that works best or you are most comfortable with. Personally I would hope using the symlink would work as I do not like using thousands of different utilities for various different jobs, I try to keep things as simple, generic and clean as possible.

It works very very well!!!

This feature must be introduced STANDARD in SD image. It is very easy to work with Raspberry PI ZERO like this.

You are the best!

Thanks!

I only have to advice one thing: If you are starting with STANDARD SD image you must to boot first to create automatically /data/wpa_supplicant.conf AFTER that you can symlink to boot/wifi.conf

THANKS AGAIN GUYS

Thank you for letting us know.

Good to hear, for the benefit of anyone else looking at this thread please could you post the steps you used to make this work.

The steps are:

1- Burn a standard SD image
2- Run a standard SD image (it will create wpa_supplicant.conf file in /data folder)
3- Symplink /data/wpa_supplicant to boot/wifi.conf with the following lines (always with -rw in ssh or linux console)

sudo mv /home/pi/data/wpa_supplicant.conf /boot/wifi.conf
sudo ln -s /boot/wifi.conf /home/pi/data/wpa_supplicant.conf

4- Switch off (sudo shutdown now)
5- Save the “WIFI.CONF image” to have this to copy to other SD
6- Introduce “WIFI CONF image SD” in windows, Linux or Mac and change wifi.conf with NOTE ++. Use NOTE ++ to not change the format of .conf file.

network={
ssid= “networkSSID”
psk=“password”
}

7- Introduce SD in the favourite Raspberry Pi with WIFI device and … HURRAY!!!

Thanks Paul and Glyn for your amazing support.

1 Like