-
Notifications
You must be signed in to change notification settings - Fork 0
/
qemu-hd.sh
31 lines (24 loc) · 910 Bytes
/
qemu-hd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# QEMU HD creation
## Image format raw, size 10G
qemu-img create qemu-hd.img 10g
## Format the disk with ext4 filesystem
mkfs.ext4 qemu-hd.img
## Mount the disk
mkdir qemu-mount
sudo mount -o loop qemu-hd.img qemu-mount
## Install debootstrap with stable release
sudo debootstrap --arch amd64 stable qemu-mount
## Create a /var/modules directory
## to add kernel modules (nic) that can be
## insmod after the emulator boots with test kernel
sudo mkdir qemu-mount/var/modules
## Unmount the disk
sudo umount qemu-mount
## First boot to set up root passwd
## Requires a Linux kernel x86 boot executable
## Assign init to be /bin/bash shell
# make -j$(nproc) bzImage
sudo qemu-system-x86_64 -kernel ../linux/arch/x86/boot/bzImage -drive file=qemu-hd.img,index=0,media=disk,format=raw -append "root=/dev/sda rw init=/bin/bash"
# Use passwd to set the root password
# and shutdown the emulator