Page 1 of 2

Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Fri Oct 06, 2017 11:14 pm
by arqeco
Hello friends.

Thank you for DietPi.

I have DietPi running on a Raspberry Pi 3, updated and fully configured, working fine on my local wifi network.

But I need to move it to another place, in another city, where it will be used as a temporary headless server.

In this new place, let's say, there is no monitor and keyboard available for the Pi. And I need to reconfigure the Pi wi-fi settings for the new place wifi network, with ssid and password that I'll know only when I come there. But my Windows 10 laptop with a SDcard reader will be available.

Is it possible to change the DietPi wifi settings editing some file on the SDcard with the Windows laptop?

Thanks,
Marcio

Re: Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Sun Oct 08, 2017 6:05 pm
by Fourdee
Hi,

WiFi creds can be pre-entered in /boot/dietpi.txt, after SD write, before 1st boot:
https://github.com/Fourdee/DietPi/blob/ ... txt#L7-L17

However, this only takes effect on a fresh image installation of DietPi. Has no effect on existing installations.

Re: Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Mon Oct 09, 2017 1:41 am
by WarHawk
recommended to use notepad++ on a windows machine to modify/tweak those files, otherwise it could cause the carriage returns to not work and thus bork the /boot file

There is a portable version so you don't have to install it...
https://portableapps.com/apps/developme ... p_portable

Re: Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Mon Oct 09, 2017 5:55 pm
by arqeco
Here is the solution I have found to be able to write to the linux partition of a sd card using a Windows laptop, and edit the interfaces file.

You will need VirtualBox, a laptop with a sd card reader, and a Linux distro installed on VirtualBox. I have used Xubuntu desktop because it's simple to use and will automount the card partitions.

1. Open VirtualBox, select the Linux VM, and click on Settings.

2. Click on "USB" and, on the USB page, click on the icon with a plus symbol, to add a new USB filter.

3. Select the sd card reader on the list that appears below the add filter icon. In my case it was "Generic Flash Card Reader/Writer (0100)". Then, click on "Ok". Now start the virtual machine.

4. Login on the Linux virtual machine.

5. Open File Manager.

6. Now insert the sd card in the laptop sd card reader. After a while all the sd card partitions will automatically be mounted and made available inside the Linux virtual machine. Check on the File Manager the newly mounted partitions.

6. Open a terminal and type:

sudo nano /media/USERNAME/rootfs/etc/network/interfaces

7. Edit the the interfaces file for your new network settings. Remember to put the same values on "wireless-essid" and "wpa-ssid", and on "wireless-key" and "wpa-psk", if you are using wpa-psk. After editing, use "Ctrl-o", "Enter", "ctrl-x", to save and exit nano.

- Original interfaces file: https://github.com/Fourdee/DietPi/blob/ ... interfaces

Code: Select all

#/etc/network/interfaces
#Please use DietPi-Config to modify network settings.

# Local
auto lo
iface lo inet loopback

# Ethernet
#allow-hotplug eth0
iface eth0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
#dns-nameservers 8.8.8.8 8.8.4.4

# Wifi
#allow-hotplug wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid FuzonWifi
wireless-key abcde12345
wireless-mode Managed
wireless-power off
wpa-ssid FuzonWifi
wpa-psk abcde12345
#dns-nameservers 8.8.8.8 8.8.4.4	

- More info on network configuration: https://wiki.debian.org/NetworkConfiguration
- If changing interfaces file does not works you must read this post. I would like very much if somebody could check if this applies to DietPi too: https://raspberrypi.stackexchange.com/q ... interfaces

8. On File Manager, click on the eject icon besides "rootfs". Remove the sd card from the reader.

9. Put the sd card on the single-board computer and boot it.

10. Use ssh to connect to your single-board computer.

11. If, for some reason, you've decided to use DHCP instead of a static IP, you may use Angry IP Scanner on the laptop to try to find the IP issued to the single-board computer.

Thank you for the answers.

Marcio

Re: Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Mon Oct 09, 2017 8:45 pm
by johnvick
Perhaps an easier way is to put the SD in an adapter and plug it into a Pi. Mount the card. Then connect to the device with WinSCP and edit.

John

Re: Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Mon Oct 09, 2017 9:02 pm
by arqeco
John, may you please explain it better?

Thank you,
Marcio

Re: Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Tue Oct 10, 2017 9:47 pm
by johnvick
[quote="arqeco"]John, may you please explain it better?

Ideally you need two Pi devices, one running an OS OK. The second device is the one you are trying to setup.

Flash the SD card with DietPi.

Install WinSCP on your Windows machine.

Put the SD card in an SD-USB adapter and put it in the working Pi (on any other Linux box). Mount the SD card on that device.

Using WinSCP SSH into the device that has your SD card mounted and then navigate to the files you want to edit. The WinSCP editor does the job nicely.

Re: Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Wed Oct 11, 2017 10:22 am
by WarHawk
Ah if running a SSH shell on the Pi and the Pi is up and operational, like Fourdee said...

The interface config file is /etc/network/interfaces as arqeco said
Edit that file with nano or vi of the new remote site SSID and passcode then save normally.

Code: Select all

    #/etc/network/interfaces
    #Please use DietPi-Config to modify network settings.

    # Local
    auto lo
    iface lo inet loopback

    # Ethernet
    #allow-hotplug eth0
    iface eth0 inet dhcp
    address 192.168.0.100
    netmask 255.255.255.0
    gateway 192.168.0.1
    #dns-nameservers 8.8.8.8 8.8.4.4

    # Wifi
    #allow-hotplug wlan0
    iface wlan0 inet dhcp
    address 192.168.0.100
    netmask 255.255.255.0
    gateway 192.168.0.1
    wireless-essid FuzonWifi
    wireless-key abcde12345
    wireless-mode Managed
    wireless-power off
    wpa-ssid FuzonWifi
    wpa-psk abcde12345
    #dns-nameservers 8.8.8.8 8.8.4.4   
Powerdown, and ship the RPi and card to remote location...fire it up and it should come up as long

Re: Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Wed Oct 11, 2017 3:14 pm
by dianakev
WarHawk wrote:Ah if running a SSH shell on the Pi and the Pi is up and operational, like Fourdee said...

The interface config file is /etc/network/interfaces as arqeco said
Edit that file with nano or vi of the new remote site SSID and passcode then save normally.

Code: Select all

    #/etc/network/interfaces
    #Please use DietPi-Config to modify network settings.

    # Local
    auto lo
    iface lo inet loopback

    # Ethernet
    #allow-hotplug eth0
    iface eth0 inet dhcp
    address 192.168.0.100
    netmask 255.255.255.0
    gateway 192.168.0.1
    #dns-nameservers 8.8.8.8 8.8.4.4

    # Wifi
    #allow-hotplug wlan0
    iface wlan0 inet dhcp
    address 192.168.0.100
    netmask 255.255.255.0
    gateway 192.168.0.1
    wireless-essid FuzonWifi
    wireless-key abcde12345
    wireless-mode Managed
    wireless-power off
    wpa-ssid FuzonWifi
    wpa-psk abcde12345
    #dns-nameservers 8.8.8.8 8.8.4.4   
Powerdown, and ship the RPi and card to remote location...fire it up and it should come up as long
btw why it stated dhcp while we want to set it as static?

Code: Select all

    iface wlan0 inet dhcp
    address 192.168.0.100

Re: Change DietPi Wi-Fi Settings Editing the SDcard on a PC

Posted: Wed Oct 11, 2017 3:59 pm
by WarHawk
correct make it static