mirror of
https://github.com/jon4hz/debian-live-builder-vagrant.git
synced 2025-12-20 00:26:34 +01:00
add option to build the arm64 architecture image
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
.vagrant/
|
.vagrant/
|
||||||
|
tmp/
|
||||||
secrets*
|
secrets*
|
||||||
*.iso
|
*.iso
|
||||||
|
|||||||
62
README.md
62
README.md
@@ -12,6 +12,10 @@ Run `vagrant up efi` to boot the generated ISO in [EFI](https://en.wikipedia.org
|
|||||||
|
|
||||||
To build a netboot image, set the `LB_BUILD_TYPE` environment variable to `netboot` before launching vagrant, e.g. `LB_BUILD_TYPE=netboot vagrant up builder`. This will build the netboot image and copy it to the current directory as `live-image-amd64.netboot.tar`.
|
To build a netboot image, set the `LB_BUILD_TYPE` environment variable to `netboot` before launching vagrant, e.g. `LB_BUILD_TYPE=netboot vagrant up builder`. This will build the netboot image and copy it to the current directory as `live-image-amd64.netboot.tar`.
|
||||||
|
|
||||||
|
To build the arm64 architecture image, set the `LB_BUILD_ARCH` environment variable to `arm64` before launching vagrant, e.g. `LB_BUILD_ARCH=arm64 vagrant up builder`. To execute this image in an emulated virtual machine see the [qemu arm64 emulation](#qemu-arm64-emulation) section.
|
||||||
|
|
||||||
|
**NB** Building the arm64 image takes longer than the native amd64. In my machine it takes about 40m (vs 10m for amd64).
|
||||||
|
|
||||||
|
|
||||||
# Burning the ISO file to a USB pen/disk drive
|
# Burning the ISO file to a USB pen/disk drive
|
||||||
|
|
||||||
@@ -32,6 +36,63 @@ eject /dev/sdd
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# qemu arm64 emulation
|
||||||
|
|
||||||
|
The arm64 architecture image can be executed in an emulated virtual machine as:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# NB in my humble machine (i3-3245) emulating arm64 is very slow and it takes
|
||||||
|
# several minutes until you can login.
|
||||||
|
# NB in the qemu window use the "View" menu to switch between the
|
||||||
|
# virtio-gpu-pci and serial0 console.
|
||||||
|
mkdir tmp
|
||||||
|
cd tmp
|
||||||
|
sudo apt-get install -y qemu-efi-aarch64 cloud-image-utils
|
||||||
|
cat >cloud-init-user-data.yml <<EOF
|
||||||
|
#cloud-config
|
||||||
|
hostname: arm64
|
||||||
|
timezone: Europe/Lisbon
|
||||||
|
ssh_pwauth: true
|
||||||
|
# NB the runcmd output is written to journald and /var/log/cloud-init-output.log.
|
||||||
|
runcmd:
|
||||||
|
- echo '************** DONE RUNNING CLOUD-INIT **************'
|
||||||
|
EOF
|
||||||
|
cloud-localds cloud-init-data.iso cloud-init-user-data.yml
|
||||||
|
cp /usr/share/AAVMF/AAVMF_CODE.fd firmware-code-arm64.fd
|
||||||
|
cp /usr/share/AAVMF/AAVMF_VARS.fd firmware-vars-arm64.fd
|
||||||
|
qemu-img create -f qcow2 hd0.img 20G
|
||||||
|
qemu-img info hd0.img
|
||||||
|
qemu-system-aarch64 \
|
||||||
|
-name arm64 \
|
||||||
|
-machine virt \
|
||||||
|
--accel tcg,thread=multi \
|
||||||
|
-cpu cortex-a57 \
|
||||||
|
-smp cores=4 \
|
||||||
|
-m 2g \
|
||||||
|
-k pt \
|
||||||
|
-device virtio-gpu-pci \
|
||||||
|
-device nec-usb-xhci,id=usb0 \
|
||||||
|
-device usb-kbd,bus=usb0.0 \
|
||||||
|
-device usb-tablet,bus=usb0.0 \
|
||||||
|
-device virtio-scsi-pci,id=scsi0 \
|
||||||
|
-drive if=pflash,file=firmware-code-arm64.fd,format=raw,readonly \
|
||||||
|
-drive if=pflash,file=firmware-vars-arm64.fd,format=raw \
|
||||||
|
-drive if=none,file=hd0.img,discard=unmap,cache=unsafe,id=hd0 \
|
||||||
|
-drive if=none,file=$PWD/../live-image-arm64.hybrid.iso,media=cdrom,cache=unsafe,readonly,id=cd0 \
|
||||||
|
-drive if=none,file=cloud-init-data.iso,media=cdrom,cache=unsafe,readonly,id=cd1 \
|
||||||
|
-device scsi-hd,drive=hd0,bus=scsi0.0,bootindex=1 \
|
||||||
|
-device scsi-cd,drive=cd0,bus=scsi0.0,bootindex=2 \
|
||||||
|
-device scsi-cd,drive=cd1,bus=scsi0.0 \
|
||||||
|
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
|
||||||
|
-device virtio-net-pci,netdev=net0 \
|
||||||
|
-device virtio-rng-pci,rng=rng0 \
|
||||||
|
-object rng-random,filename=/dev/urandom,id=rng0 \
|
||||||
|
-qmp unix:arm64.socket,server,nowait
|
||||||
|
echo info qtree | qmp-shell -H arm64.socket
|
||||||
|
ssh vagrant@localhost -p 2222
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
# Reference
|
# Reference
|
||||||
|
|
||||||
* [Live Systems Manual](https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.html)
|
* [Live Systems Manual](https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.html)
|
||||||
@@ -40,3 +101,4 @@ eject /dev/sdd
|
|||||||
* [lb_config(1)](https://manpages.debian.org/bullseye/live-build/lb_config.1.en.html)
|
* [lb_config(1)](https://manpages.debian.org/bullseye/live-build/lb_config.1.en.html)
|
||||||
* [Debian Live Team Repositories](https://salsa.debian.org/live-team)
|
* [Debian Live Team Repositories](https://salsa.debian.org/live-team)
|
||||||
* [Debian Live Wiki](http://wiki.debian.org/DebianLive): Information about the Debian Live team and its contacts.
|
* [Debian Live Wiki](http://wiki.debian.org/DebianLive): Information about the Debian Live team and its contacts.
|
||||||
|
* [run emulated arm under qemu](https://gist.github.com/rgl/b02c24f9eb1b4bdb4ac6f970d4bfc885)
|
||||||
|
|||||||
9
Vagrantfile
vendored
9
Vagrantfile
vendored
@@ -5,7 +5,7 @@ ENV['VAGRANT_NO_PARALLEL'] = 'yes'
|
|||||||
Vagrant.configure('2') do |config|
|
Vagrant.configure('2') do |config|
|
||||||
config.vm.provider :libvirt do |lv, config|
|
config.vm.provider :libvirt do |lv, config|
|
||||||
lv.memory = 2048
|
lv.memory = 2048
|
||||||
lv.cpus = 2
|
lv.cpus = 4
|
||||||
lv.cpu_mode = 'host-passthrough'
|
lv.cpu_mode = 'host-passthrough'
|
||||||
# lv.nested = true # nested virtualization.
|
# lv.nested = true # nested virtualization.
|
||||||
lv.keymap = 'pt'
|
lv.keymap = 'pt'
|
||||||
@@ -21,7 +21,7 @@ Vagrant.configure('2') do |config|
|
|||||||
config.vm.provider :hyperv do |hv, config|
|
config.vm.provider :hyperv do |hv, config|
|
||||||
hv.linked_clone = true
|
hv.linked_clone = true
|
||||||
hv.memory = 2048
|
hv.memory = 2048
|
||||||
hv.cpus = 2
|
hv.cpus = 4
|
||||||
# hv.enable_virtualization_extensions = true # nested virtualization.
|
# hv.enable_virtualization_extensions = true # nested virtualization.
|
||||||
hv.vlan_id = ENV['HYPERV_VLAN_ID']
|
hv.vlan_id = ENV['HYPERV_VLAN_ID']
|
||||||
# see https://github.com/hashicorp/vagrant/issues/7915
|
# see https://github.com/hashicorp/vagrant/issues/7915
|
||||||
@@ -36,7 +36,10 @@ Vagrant.configure('2') do |config|
|
|||||||
config.vm.define :builder do |config|
|
config.vm.define :builder do |config|
|
||||||
config.vm.box = 'debian-11-amd64'
|
config.vm.box = 'debian-11-amd64'
|
||||||
config.vm.hostname = 'builder'
|
config.vm.hostname = 'builder'
|
||||||
config.vm.provision :shell, path: 'builder.sh', env: {'LB_BUILD_TYPE' => ENV['LB_BUILD_TYPE'] || 'iso'}
|
config.vm.provision :shell, path: 'builder.sh', env: {
|
||||||
|
'LB_BUILD_TYPE' => ENV['LB_BUILD_TYPE'] || 'iso',
|
||||||
|
'LB_BUILD_ARCH' => ENV['LB_BUILD_ARCH'] || 'amd64',
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
['bios', 'efi'].each do |firmware|
|
['bios', 'efi'].each do |firmware|
|
||||||
|
|||||||
33
builder.sh
33
builder.sh
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eux
|
set -euxo pipefail
|
||||||
|
|
||||||
|
|
||||||
# the build artifact type can be one of:
|
# the build artifact type can be one of:
|
||||||
@@ -7,6 +7,11 @@ set -eux
|
|||||||
# netboot
|
# netboot
|
||||||
LB_BUILD_TYPE="${LB_BUILD_TYPE:=iso}"
|
LB_BUILD_TYPE="${LB_BUILD_TYPE:=iso}"
|
||||||
|
|
||||||
|
# the build architecture can be one of:
|
||||||
|
# amd64 (default)
|
||||||
|
# arm64
|
||||||
|
LB_BUILD_ARCH="${LB_BUILD_ARCH:=amd64}"
|
||||||
|
|
||||||
|
|
||||||
echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >/etc/sudoers.d/env_keep_apt
|
echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >/etc/sudoers.d/env_keep_apt
|
||||||
chmod 440 /etc/sudoers.d/env_keep_apt
|
chmod 440 /etc/sudoers.d/env_keep_apt
|
||||||
@@ -75,6 +80,7 @@ EOF
|
|||||||
# install dependencies.
|
# install dependencies.
|
||||||
|
|
||||||
apt-get install -y libcdio-utils librsvg2-bin pngquant
|
apt-get install -y libcdio-utils librsvg2-bin pngquant
|
||||||
|
apt-get install -y qemu-user-static
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -106,7 +112,7 @@ fi
|
|||||||
#
|
#
|
||||||
# build a custom live image.
|
# build a custom live image.
|
||||||
|
|
||||||
mkdir custom-image && pushd custom-image
|
mkdir custom-image-$LB_BUILD_ARCH && pushd custom-image-$LB_BUILD_ARCH
|
||||||
|
|
||||||
# configure it.
|
# configure it.
|
||||||
# see https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.html
|
# see https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.html
|
||||||
@@ -129,6 +135,13 @@ lb_config='\
|
|||||||
--bootloader syslinux \
|
--bootloader syslinux \
|
||||||
'
|
'
|
||||||
fi
|
fi
|
||||||
|
if [ "$LB_BUILD_ARCH" == 'arm64' ]; then
|
||||||
|
lb_config="$lb_config \\
|
||||||
|
--bootloader grub-efi \\
|
||||||
|
--bootstrap-qemu-arch arm64 \\
|
||||||
|
--bootstrap-qemu-static /usr/bin/qemu-arm-static \\
|
||||||
|
"
|
||||||
|
fi
|
||||||
cat >auto/config <<EOF
|
cat >auto/config <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eux
|
set -eux
|
||||||
@@ -136,7 +149,7 @@ lb config noauto \\
|
|||||||
$lb_config \\
|
$lb_config \\
|
||||||
--mode debian \\
|
--mode debian \\
|
||||||
--distribution bullseye \\
|
--distribution bullseye \\
|
||||||
--architectures amd64 \\
|
--architectures $LB_BUILD_ARCH \\
|
||||||
--bootappend-live 'boot=live components username=vagrant' \\
|
--bootappend-live 'boot=live components username=vagrant' \\
|
||||||
--mirror-bootstrap http://ftp.pt.debian.org/debian/ \\
|
--mirror-bootstrap http://ftp.pt.debian.org/debian/ \\
|
||||||
--mirror-binary http://ftp.pt.debian.org/debian/ \\
|
--mirror-binary http://ftp.pt.debian.org/debian/ \\
|
||||||
@@ -308,6 +321,7 @@ echo nls_ascii >>etc/initramfs-tools/modules # for booting from FAT32.
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ "$LB_BUILD_TYPE" == 'iso' ]; then
|
if [ "$LB_BUILD_TYPE" == 'iso' ]; then
|
||||||
|
if [ "$LB_BUILD_ARCH" == 'amd64' ]; then
|
||||||
cat >config/hooks/normal/9990-bootloader-splash.hook.binary <<'EOF'
|
cat >config/hooks/normal/9990-bootloader-splash.hook.binary <<'EOF'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eux
|
set -eux
|
||||||
@@ -334,6 +348,7 @@ menu clear
|
|||||||
EOM
|
EOM
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
chmod +x config/hooks/normal/*.hook.*
|
chmod +x config/hooks/normal/*.hook.*
|
||||||
|
|
||||||
@@ -342,15 +357,15 @@ lb build
|
|||||||
|
|
||||||
if [ "$LB_BUILD_TYPE" == 'iso' ]; then
|
if [ "$LB_BUILD_TYPE" == 'iso' ]; then
|
||||||
# show some information about the generated iso file.
|
# show some information about the generated iso file.
|
||||||
fdisk -l live-image-amd64.hybrid.iso
|
fdisk -l live-image-$LB_BUILD_ARCH.hybrid.iso
|
||||||
iso-info live-image-amd64.hybrid.iso --no-header
|
iso-info live-image-$LB_BUILD_ARCH.hybrid.iso --no-header
|
||||||
#iso-info live-image-amd64.hybrid.iso --no-header -f | sed '0,/ISO-9660 Information/d' | sort -k 2
|
#iso-info live-image-$LB_BUILD_ARCH..hybrid.iso --no-header -f | sed '0,/ISO-9660 Information/d' | sort -k 2
|
||||||
|
|
||||||
# copy it on the host fs (it will be used by the target VM).
|
# copy it on the host fs (it will be used by the target VM).
|
||||||
cp -f live-image-amd64.hybrid.iso /vagrant
|
cp -f live-image-$LB_BUILD_ARCH.hybrid.iso /vagrant
|
||||||
else
|
else
|
||||||
tar tf live-image-amd64.netboot.tar
|
tar tf live-image-$LB_BUILD_ARCH.netboot.tar
|
||||||
cp live-image-amd64.netboot.tar /vagrant
|
cp live-image-$LB_BUILD_ARCH.netboot.tar /vagrant
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# clean it.
|
# clean it.
|
||||||
|
|||||||
Reference in New Issue
Block a user