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
Copy file name to clipboardExpand all lines: README.md
+62-34Lines changed: 62 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -70,7 +70,7 @@ Fun fact, qemu actually bundles/uses `iPXE` internally. But ignore that. We're g
70
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
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
72
73
-
```
73
+
```bash
74
74
#1. iPXE.org docs https://ipxe.org/docs
75
75
76
76
# 2.
@@ -79,56 +79,82 @@ cd ipxe/src
79
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
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
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
82
+
3. For example, given a manual `qemu` boot (which we'll put iPXE
83
+
in-front of momentarily) consider first the following which
84
+
boots linux, and simulates a Network interface card (NIC) on
83
85
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
86
networking (using tun/tap is 'better'/faster):
85
87
88
+
89
+
qemu_args=(
90
+
-enable-kvm # utilize hardware virtualization of processors
91
+
-cpu max # Enables all features supported by the accelerator in the current host
92
+
-smp 4
93
+
-m 4096
94
+
-kernel vmlinuz-lts
95
+
-initrd new-initramfs-lts
96
+
-serial mon:stdio # multiplex the QEMU Monitor with the serial port output
97
+
98
+
# Since we're using -serial, ask linux to direct kernel log to the serial
99
+
# so we can see it, without this -append, we won't see the kernel boot log
100
+
# As there is no default graphical device we disable the display
101
+
# as we can work entirely in the terminal.
102
+
-display none
103
+
-device virtio-net-pci,netdev=mynet0
104
+
-netdev user,id=mynet0,dns=1.1.1.1
105
+
)
106
+
# Start qemu with the above args
107
+
qemu-system-x86_64 "${qemu_args[@]}"
86
108
```
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
-
```
109
+
106
110
The above would start your linux instance, you'd then *manually* configure addressing on the virtual network card with the following:
111
+
112
+
```shell
107
113
ip link set dev eth0 up
108
114
ip addr add 10.0.2.10/24 dev eth0
109
-
ip route get 1.1.1.1 # no root to host
115
+
ip route get 1.1.1.1 # no root to host, oh no, read on!
116
+
```
117
+
118
+
Now perform
119
+
120
+
```bash
110
121
ip route add default via 10.0.2.2
111
122
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?
# I've read that page for years and it's still only just clicking.. they're not magic numbers they are defaults :)
123
+
```
124
+
125
+
Where did 10.0.2.2 come from? It's the gateway default when using qemu SLIRP network, see the image on that page https://wiki.qemu.org/Documentation/Networking#:~:text=Network%20backend%20types it's trying
126
+
to tell you the default addressing scheme.
127
+
Did you notice valid host addresses start from address .9?
-https://unix.stackexchange.com/a/489843 `/sbin/init not found in new root. Launching emergency recovery shell
178
+
` / `init not found in new root`
152
179
> "Stuff like this is slowly becoming a lost art" [src](https://www.linuxquestions.org/questions/linux-general-1/bin-bash-as-primary-init-4175543547/#post5367386) ooopse.
153
180
154
181
@@ -159,3 +186,4 @@ TODO READ: https://bbs.archlinux.org/viewtopic.php?pid=1378903#p1378903
0 commit comments