multimico / rpi-ubuntu-cloudinit

MIT License
1 stars 0 forks source link

RPI4 USB Boot #2

Open phish108 opened 3 months ago

phish108 commented 3 months ago

Technical requirements

Steps

  1. Prepare the RPI Imager with Other General Purpose OS for UBUNTU XX.XX Server (64 bit) and change the image settings according to your network and user requirements. For details see section Image Settings.
  2. flash the USB stick. You may have to confirm to override the data on the drive with your password.

    After flashing DO NOT remove the drive from your computer.

  3. Open the system-boot partition on your computer.
  4. Locate the file network-config
  5. Open the file using your favorite text/code editor and change it as described in section Networking
  6. Locate the file user-data
  7. Open the file using your favorite text/code editor and change it as described in section System
  8. Eject the drive
  9. plug the drive into the RPI. Ensure that you use the blue USB-3 sockets.
  10. power on the RPI and wait until cloud-init completes (a login prompt may appear prior to that)

Image Settings

Tab Common:

Tab Services:

Tab Options:

Networking

The network configuration lack ethernet support by default. This should be included. The network-config should look as follows.

version: 2
renderer: networkd

ethernets:
  eth0:
    dhcp4: true
    optional: true
wifis:
  wlan0:
    dhcp4: true
    optional: true
    access-points:
      "mywifi":
        password: "c2fee4d164815217dd158e086014d3a048da7ba890a42d3b1dac1bcafa1ddd08"

System

The user-config replicates most of the settings done in the raspberry-pi Imager. The file is in YAML format, so the indentation is significant.

Below the apt section add the following lines:

package_update: true
package_upgrade: true
package_reboot_if_required: true

Add to the packages section the following lines:

packages:
  - avahi-daemon
  - jq
  - yq
  - apt-transport-https
  - ca-certificates
  - gnupg-agent

User settings:

Add the field ssh_import_id to the user configuration and include your github user as follows.

ssh_import_id: 
- gh:loginname

You need to replace loginname with your GitHub username.

You MAY add the line sudo: ALL=(ALL) NOPASSWD:ALL to your user account. This is only recommended for testing and experimenting. For production systems the line should be sudo: ALL=(ALL). This variation will ask for the configured password before granting root privileges.

You may add additional users, if needed.

If the network connection is known to work, you may set ssh_pwauth to false.

Additional commands can be set in the runcmd section.

DRSenn commented 3 months ago

For Windows users:

If you generated your SSH key on the Windows Subsystem for Linux (WSL) or Ubuntu on Windows, you'll need to use the same environment to connect to your Raspberry Pi. This means using the WSL terminal or Ubuntu terminal for the SSH connection.

phish108 commented 2 months ago

Some Windows systems come with SSH for Windows preinstalled. In this case, WSL is not needed.