Skip to content

Commit 4a15040

Browse files
committed
debootstrap-debian-qemu.sh: make perfect
1 parent 0321da6 commit 4a15040

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

debootstrap-debian-qemu.sh

100644100755
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ if [ ! -d "$debootstrap_dir" ]; then
2222
"$debootstrap_dir" \
2323
http://deb.debian.org/debian/ \
2424
;
25+
sudo rm -f "$root_filesystem"
2526
fi
2627

27-
linux_image="$(printf "${debootstrap_dir}/boot/vmlinuz-"*)"
28-
2928
if [ ! -f "$root_filesystem" ]; then
30-
3129
# Set root password.
3230
echo 'root:root' | sudo chroot "$debootstrap_dir" chpasswd
3331

@@ -65,24 +63,26 @@ EOF
6563
sudo chmod 666 "$root_filesystem"
6664
fi
6765

68-
linux_img="${debootstrap_dir}/boot/vmlinuz-"*
66+
# linux_image="$(printf "${debootstrap_dir}/boot/vmlinuz-"*)"
6967

70-
# Build the Linux kernel.
71-
git clone --depth 1 --branch v4.18 git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
72-
cd linux
73-
wget https://gist.githubusercontent.com/cirosantilli/6e2f4975c1929162a86be09f839874ca/raw/6d151d231a233408a6e1b541bf4a92fd55bf5338/.config
74-
make olddefconfig
75-
make -j`nproc`
76-
cd -
77-
linux_img="linux/arch/x86_64/boot/bzImage"
68+
linux_img=linux/arch/x86_64/boot/bzImage
69+
if [ ! -f "$linux_img" ]; then
70+
# Build the Linux kernel.
71+
git clone --depth 1 --branch v4.18 git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
72+
cd linux
73+
wget https://gist.githubusercontent.com/cirosantilli/6e2f4975c1929162a86be09f839874ca/raw/6d151d231a233408a6e1b541bf4a92fd55bf5338/.config
74+
make olddefconfig
75+
make -j`nproc`
76+
cd -
77+
fi
7878

7979
qemu-system-x86_64 \
8080
-append 'console=ttyS0 root=/dev/sda' \
81-
-drive "file=img.ext2.qcow2,format=qcow2" \
81+
-drive "file=${root_filesystem},format=qcow2" \
8282
-enable-kvm \
8383
-serial mon:stdio \
8484
-m 2G \
85-
-kernel="$linux_img"
85+
-kernel "$linux_img" \
8686
-device rtl8139,netdev=net0 \
8787
-netdev user,id=net0 \
8888
;

debootstrap-ubuntu-qemu.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ Description=DHCP Client
4747
Documentation=man:dhclient(8)
4848
Wants=network.target
4949
Before=network.target
50+
5051
[Service]
5152
Type=forking
5253
PIDFile=/var/run/dhclient.pid
5354
ExecStart=/sbin/dhclient -4 -q
55+
5456
[Install]
5557
WantedBy=multi-user.target
5658
EOF

0 commit comments

Comments
 (0)