DieterReuter / image-builder-rpi64

Build SD card image for Raspberry Pi 3 64bit
MIT License
156 stars 38 forks source link

Update cloud-init implementation #31

Closed renevo closed 4 months ago

renevo commented 6 years ago

Currently cloud-init only uses two of the four possible files:

Placeholders should be placed in /boot and copied in chroot-script.sh

The files should not be placed in /var/lib/cloud/seed/nocloud-net/ they should be placed in /var/lib/cloud/seed/nocloud/.

nocloud-net is a future directory that will be read in 17.1 and specified in the /boot/cmdline.txt if you want to remote load (See documentation for 17.1)

This also causes:

[local] Exiting. datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net] not in local mode.

There is a bit of confusion about where the hostname should be. This should be provided in the meta-data instead of user-data by default. This will require that flash is updated appropriately as well.

/meta-data

hostname: myhost

/network-config

This is actually where you configure network interfaces (e.g.) The current cloud-init version supports Network Config v1

Setting static IP in /network-config

version: 1
config:
   - type: physical
     name: eth0
     subnets:
        - type: static
          address: 192.168.1.10
          netmask: 255.255.255.0
          gateway: 192.168.1.254

/vendor-data is basically exactly like user-data, and is usually provided by hosting providers.

renevo commented 6 years ago

I would try to do these myself, but I haven't quite gotten the environment for building up and running yet (Windows dude here).

The resizefs is part of cloud-init as well, not sure if that script is still being executed or not, but it isn't neccessary.

Logs for resize below from /var/log/cloud-init.log

2017-11-04 20:50:28,990 - helpers.py[DEBUG]: Running config-resizefs using lock (<cloudinit.helpers.DummyLock object at 0x7f8e2dcb00>)
2017-11-04 20:50:28,992 - util.py[DEBUG]: Reading from /proc/430/mountinfo (quiet=False)
2017-11-04 20:50:28,994 - util.py[DEBUG]: Read 2523 bytes from /proc/430/mountinfo
2017-11-04 20:50:28,997 - cc_resizefs.py[DEBUG]: resize_info: dev=/dev/root mnt_point=/ path=/
2017-11-04 20:50:28,998 - util.py[DEBUG]: Running command ['systemd-detect-virt', '--quiet', '--container'] with allowed return codes [0] (shell=False, capture=True)
2017-11-04 20:50:29,029 - util.py[DEBUG]: Running command ['running-in-container'] with allowed return codes [0] (shell=False, capture=True)
2017-11-04 20:50:29,046 - util.py[DEBUG]: Running command ['lxc-is-container'] with allowed return codes [0] (shell=False, capture=True)
2017-11-04 20:50:29,064 - util.py[DEBUG]: Reading from /proc/1/environ (quiet=False)
2017-11-04 20:50:29,066 - util.py[DEBUG]: Read 38 bytes from /proc/1/environ
2017-11-04 20:50:29,068 - util.py[DEBUG]: Reading from /proc/self/status (quiet=False)
2017-11-04 20:50:29,069 - util.py[DEBUG]: Read 950 bytes from /proc/self/status
2017-11-04 20:50:29,071 - cc_resizefs.py[DEBUG]: Converted /dev/root to '/dev/mmcblk0p2' per kernel cmdline
2017-11-04 20:50:29,073 - cc_resizefs.py[DEBUG]: Resizing / (ext4) using resize2fs /dev/mmcblk0p2
2017-11-04 20:50:29,074 - util.py[DEBUG]: Running command ('resize2fs', '/dev/mmcblk0p2') with allowed return codes [0] (shell=False, capture=True)
2017-11-04 20:50:29,105 - util.py[DEBUG]: Resizing took 0.030 seconds
2017-11-04 20:50:29,106 - cc_resizefs.py[DEBUG]: Resized root filesystem (type=ext4, val=True)
2017-11-04 20:50:29,108 - handlers.py[DEBUG]: finish: init-network/config-resizefs: SUCCESS: config-resizefs ran successfully
StefanScherer commented 6 years ago

Thanks for the details. That makes sense. If you don't know how to build the SD card image, then you could add the .circleci/config.yml from #18 and connect your fork to CircleCI. It builds each git commit and saves the SD card ZIP file as artifact which can be downloaded from CircleCI server.

renevo commented 6 years ago

@StefanScherer will try that out tomorrow!

firecyberice commented 6 years ago

@RenEvo You are right our pre cloud-init resizefs script is not needed anymore and can be removed.