You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You then might want to re-run your `qemu` debugging process: See [](https://github.com/KarmaComputing/minimal-linux-boot-coreutils/blob/c64027b54b12d488f83cef75b5fbfee3d444e661/run-qemu.sh#L5)- remembering to change the `-initrd rootfs.cpio.gz` argument.
55
59
56
-
<strike>TODO: add [iproute2](https://github.com/iproute2/iproute2) for minimal routing.</strike>
60
+
## How do I use `ipxe` to provide dynamic kernel parameters at bootime, such as `ip=` kernel options?
57
61
58
-
## Things you need to build
62
+
Booting with `qemu-system-x86_64` and [passing kernel options like `ip=` using the `append=` qemu options](https://github.com/KarmaComputing/minimal-linux-boot-coreutils/blob/7453eea727732761152ec306e822d54a4587934a/run-qemu.sh#L5) is great an all, (see also [debugging-linux-kernel-bootstrap-with-qemu](https://github.com/KarmaComputing/debugging-linux-kernel-bootstrap-with-qemu)), but how can I harness `iPXE` to provide `-append` kernel options dynamically via http✨?
63
+
64
+
Fun fact, qemu actually bundles/uses `iPXE` internally. But ignore that. We're going to build and pass iPXE as an ISO to demonstrate booting from `iPXE` to set dynamic kernel options, opening up the possibility to boot from anywhere. The steps in brief (explained in detail after) are:
65
+
66
+
1. Read the iPXE docs
67
+
2. Clone iPXE
68
+
3. Write your own `script.ipxe`
69
+
4. Build your own `iPXE` ISO which bundles that iPXE script
70
+
5. 'Start' your machine ( `qemu-system-x86_64` , in this instance simulating a bare metal server), passing qemu the `-boot d -cdrom image.iso` options
71
+
6. Observe your virtual bare metal 'machine' do whatever you tell it to do (see step 1, did you see the [section about UEFI](https://ipxe.org/download#:~:text=128kB%20in%20size.-,UEFI,-iPXE%20supports%20both)?).
72
+
73
+
```
74
+
#1. iPXE.org docs https://ipxe.org/docs
75
+
76
+
# 2.
77
+
git clone https://github.com/ipxe/ipxe.git
78
+
cd ipxe/src
79
+
make # yes you have to do this, for all other build targets to be available. You'll probably be missing `build-essential` packages needed to build, so read the output, research and install any missing dependencies.
80
+
# Again, the docs are helpful here https://ipxe.org/download#:~:text=You%20will%20need%20to%20have%20at%20least%20the%20following%20packages%20installed%20in%20order%20to%20build%20iPXE
81
+
82
+
3. For example, given a manual `qemu` boot (which we'll put iPXE infront of momenterily) consider first the following which boots linux, and simulates a Network interface card (NIC) on
83
+
the host using [qemu SLIRP user networking](https://wiki.qemu.org/Documentation/Networking#:~:text=Network%20backend%20types) because its the most compatible friendly *documentation* approach for
84
+
networking (using tun/tap is 'better'/faster):
85
+
86
+
```
87
+
qemu_args=(
88
+
-enable-kvm # utilize hardware virtualization of processors
89
+
-cpu max # Enables all features supported by the accelerator in the current host
90
+
-smp 4
91
+
-m 4096
92
+
-kernel vmlinuz-lts
93
+
-initrd new-initramfs-lts
94
+
-serial mon:stdio # multiplex the QEMU Monitor with the serial port output
95
+
# Since we're using -serial, ask linux to direct kernel log to the serial
96
+
# so we can see it, withou this -append, we won't see the kernel boot log
97
+
# As there is no default graphical device we disable the display
98
+
# as we can work entirely in the terminal.
99
+
-display none
100
+
-device virtio-net-pci,netdev=mynet0
101
+
-netdev user,id=mynet0,dns=1.1.1.1
102
+
)
103
+
# Start qemu with the above args
104
+
qemu-system-x86_64 "${qemu_args[@]}"
105
+
```
106
+
The above would start your linux instance, you'd then *manually* configure addressing on the virtual network card with the following:
107
+
ip link set dev eth0 up
108
+
ip addr add 10.0.2.10/24 dev eth0
109
+
ip route get 1.1.1.1 # no root to host
110
+
ip route add default via 10.0.2.2
111
+
ip route get 1.1.1.1 # Now you have a route to host :)
112
+
# Where did 10.0.2.2 come from? It's the gateway default when using qemu SLIRP network, see the image
113
+
# on that page https://wiki.qemu.org/Documentation/Networking#:~:text=Network%20backend%20types it's trying
114
+
# to tell you the default addressing scheme- did you notice valid host addresses start from address .9?
0 commit comments