Create an init process in Rust that can mount the initial file systems appropriately.
This commit is contained in:
@@ -20,5 +20,5 @@ RUN dnf install -y \
|
||||
RUN mkdir -p /build/ramfs
|
||||
RUN curl https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-${KERNEL_VERSION}.tar.xz | tar xJC /build
|
||||
RUN mv /build/linux* /build/kernel
|
||||
COPY buildramfs.sh /build/ramfs/buildramfs.sh
|
||||
COPY lam.config /build/kernel/.config
|
||||
COPY buildramfs.sh /build/ramfs/buildramfs.sh
|
||||
|
||||
12
docker/Dockerfile.rust
Normal file
12
docker/Dockerfile.rust
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM fedora:latest
|
||||
ENV USER=lam
|
||||
ENV PASS=lampass
|
||||
|
||||
RUN useradd -m -G wheel -p ${PASS} ${USER}
|
||||
RUN dnf install -y \
|
||||
clang \
|
||||
gcc
|
||||
USER ${USER}
|
||||
WORKDIR /home/${USER}
|
||||
RUN mkdir -p /home/${USER}/lam
|
||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -t x86_64-unknown-linux-musl -y
|
||||
@@ -1,40 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
ARCH="x86_64"
|
||||
BB_VER="1.31.0"
|
||||
|
||||
# Dirs
|
||||
mkdir -p root
|
||||
cd root
|
||||
mkdir -p bin dev etc lib mnt proc sbin sys tmp var
|
||||
mkdir -p image/{bin,dev,etc,lib,mnt,proc,sbin,sys,tmp,var}
|
||||
cd image
|
||||
mkdir -p
|
||||
cd -
|
||||
|
||||
# Utils
|
||||
if [ ! -f "root/bin/busybox" ]; then
|
||||
curl -L "https://www.busybox.net/downloads/binaries/${BB_VER}-defconfig-multiarch-musl/busybox-${ARCH}" >root/bin/busybox
|
||||
fi
|
||||
cd root/bin
|
||||
chmod +x busybox
|
||||
ln -s busybox mount
|
||||
ln -s busybox sh
|
||||
cd -
|
||||
|
||||
# Init process
|
||||
|
||||
cat >>root/init << EOF
|
||||
#!/bin/busybox sh
|
||||
/bin/busybox --install -s /bin
|
||||
mount -t devtmpfs devtmpfs /dev
|
||||
mount -t proc proc /proc
|
||||
mount -t sysfs sysfs /sys
|
||||
mount -t tmpfs tmpfs /tmp
|
||||
setsid cttyhack sh
|
||||
exec /bin/sh
|
||||
EOF
|
||||
chmod +x root/init
|
||||
|
||||
# initramfs creation
|
||||
|
||||
cd root
|
||||
cd image
|
||||
find . | cpio -ov --format=newc | gzip -9 >../initramfs
|
||||
cd -
|
||||
|
||||
Reference in New Issue
Block a user