forked from virt-do/cloudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vmm): implemented automatic generation of rootfs with initramfs
- Loading branch information
1 parent
2338841
commit 5520619
Showing
4 changed files
with
49 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
#!/usr/bin/bash | ||
|
||
LINUX_REPO=linux-cloud-hypervisor | ||
cd ./tools/kernel/ | ||
|
||
if [ ! -d $LINUX_REPO ] | ||
then | ||
git clone --depth 1 "https://github.com/cloud-hypervisor/linux.git" -b "ch-6.2" $LINUX_REPO | ||
fi | ||
|
||
pushd $LINUX_REPO | ||
cd $LINUX_REPO | ||
cp ../linux-config-x86_64 .config | ||
KCFLAGS="-Wa,-mx86-used-note=no" make bzImage -j `nproc` | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,14 @@ | ||
#!/usr/bin/bash | ||
|
||
if [ ! -d alpine-minirootfs ] | ||
# test if its already in src folder => fs-gen available | ||
# launch from src folder at the same level as tools | ||
if [ -d src ] | ||
then | ||
curl -O https://dl-cdn.alpinelinux.org/alpine/v3.14/releases/x86_64/alpine-minirootfs-3.14.2-x86_64.tar.gz | ||
|
||
mkdir alpine-minirootfs | ||
tar xf alpine-minirootfs-3.14.2-x86_64.tar.gz -C alpine-minirootfs | ||
cd src | ||
fi | ||
|
||
pushd alpine-minirootfs | ||
cat > init <<EOF | ||
#! /bin/sh | ||
# | ||
# /init executable file in the initramfs | ||
# | ||
mount -t devtmpfs dev /dev | ||
mount -t proc proc /proc | ||
mount -t sysfs sysfs /sys | ||
ip link set up dev lo | ||
slattach -L /dev/ttyS1& | ||
while ! ifconfig sl0 &> /dev/null; do | ||
sleep 1 | ||
done | ||
ifconfig sl0 172.30.0.11 netmask 255.255.0.0 up | ||
exec /sbin/getty -n -l /bin/sh 115200 /dev/console | ||
poweroff -f | ||
EOF | ||
|
||
chmod +x init | ||
|
||
find . -print0 | | ||
cpio --null --create --verbose --owner root:root --format=newc | | ||
xz -9 --format=lzma > ../initramfs.img | ||
|
||
popd | ||
if [ -d fs-gen ] | ||
then | ||
cargo run --bin fs-gen -- alpine:latest ./fs-gen/test -o ../tools/rootfs/initramfs.img | ||
else | ||
echo "Module fs-gen not found" | ||
fi |