github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/docs/compilers/firecracker/make_artifacts.md (about) 1 # How to create the root fs this copiler uses 2 3 ## Create an image file 4 ``` 5 dd if=/dev/zero of=rootfs bs=1M count=50 6 mkfs.ext4 rootfs 7 ``` 8 9 ## Mount it 10 ``` 11 mkdir tmp 12 sudo mount rootfs tmp -o loop 13 ``` 14 15 ## Setup a base: 16 ``` 17 wget http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86_64/alpine-minirootfs-3.8.1-x86_64.tar.gz 18 cd tmp 19 sudo tar xzf ../alpine-minirootfs-3.8.1-x86_64.tar.gz 20 cd .. 21 ``` 22 23 ## Setup various settings 24 This will setup dns for netowrk, and an inittab that will start start-script. 25 26 ``` 27 echo nameserver 1.1.1.1 | sudo tee ./tmp/etc/resolv.conf 28 cat interfaces | sudo tee ./tmp/etc/network/interfaces 29 cat inittab | sudo tee ./tmp/etc/inittab 30 cat start-script | sudo tee ./tmp/start.sh 31 ``` 32 33 34 ## Update the image from the inside 35 36 Install openrc, set root password (makes debugging easier). 37 ``` 38 sudo chroot tmp/ /bin/sh 39 passwd root -d root 40 apk update 41 apk add openrc 42 exit 43 ``` 44 45 ## Cleanup 46 ``` 47 sudo umount tmp 48 rmdir tmp 49 ``` 50 51 # Get a kernel from linuxkit: 52 ``` 53 VERSION=4.19.4 54 CID=$(docker create linuxkit/kernel:$VERSION dummycommand) 55 docker cp $CID:/kernel ./kernel-$VERSION 56 docker rm $CID 57 wget https://raw.githubusercontent.com/torvalds/linux/master/scripts/extract-vmlinux 58 bash extract-vmlinux kernel-$VERSION > kernel-$VERSION-elf 59 ```