Skip to content

Commit

Permalink
Kind of works
Browse files Browse the repository at this point in the history
  • Loading branch information
ironyman committed Jan 11, 2020
0 parents commit 4dbe0a0
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Prerequisites

```
apt install -y e2fsprogs coreutils debootstrap qemu-system-x86
```


# Create vm
```
sudo ./create-vm.sh
```

# Run firefox
Start vm
```
qemu-system-x86_64 \
-drive file=root.img,format=raw \
-kernel /boot/vmlinuz-`uname -r` \
-initrd /boot/initrd.img-`uname -r` \
-append "root=/dev/sda rdinit=/sbin/init console=tty1,115200 console=ttyS0,115200" \
-m $MEMORY \
-smp ${CPU:-1} \
-machine ubuntu,accel=kvm \
-nographic \
-device virtio-net,netdev=vmnic -netdev user,id=vmnic,hostfwd=tcp::5555-:22
```
Run firefox
```
ssh user@localhost -p5555 -Y firefox
```
42 changes: 42 additions & 0 deletions create-vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

DISK=3G
MEMORY=2G
CPU=4

truncate root.img --size ${DISK:-3G}
mkfs.ext4 root.img -L ROOT

export MOUNTPOINT=$(mktemp -d)
mount root.img $MOUNTPOINT
debootstrap --include=firefox,openssh-server,xauth --components=main,universe bionic $MOUNTPOINT
cat <<"EOF" | bash
chroot $MOUNTPOINT
useradd -m user
passwd -d user
echo LABEL=ROOT / ext4 rw 0 1 > /etc/fstab
echo "user ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
cat<<"EOF2" > /etc/systemd/system/dhclient.service
[Unit]
Description=dhclient
#After=network.target
[Service]
Type=simple
ExecStart=/bin/bash -c 'modprobe virtio-net; while [[ ! $( ip l | grep -e "^2:") ]]; do sleep 1; done; /sbin/dhclient -v -w'
StandardOutput=journal
[Install]
WantedBy=multi-user.target
EOF2
systemctl enable dhclient
EOF

# apt doesn't find it for some reason
# sudo apt-get -o Dir=$MOUNTPOINT update
# sudo apt-get -o Dir=$MOUNTPOINT install linux-modules-`uname -r`
mkdir $MOUNTPOINT/lib/modules/
cp /lib/modules/`uname -r` $MOUNTPOINT/lib/modules/ -r
umount $MOUNTPOINT

0 comments on commit 4dbe0a0

Please sign in to comment.