mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-07 03:45:23 +01:00
- We do not use latest 4.9.x because it relies on a new version of binutils, while older versions do not. (Note: we should be able to go a bit newer but I didn't bother testing >50 versions to figure this out). - We do not use newer kernel versions because they require one or more of (new perl, new binutils, new make, new gcc, new bison, new tar). - sysb and sysc are updated to use the SATA (libata) subsystem (aka sda) instead of IDE-emulating SATA subsystem (aka hda) which is now available to us. - While theoretically according to docs 4.9 should work OOTB with our version of binutils this is not the case, so we have to do a bit of (interesting) patching. But this does not break anything. - Thankfully serial support in 4.9 is not screwed over like it is in 2.6 so we can revert to that. - 4.9 has the linux-libre project at our disposal, instead of gNewSense. So we use this. Unfortunatley that takes forever because we have to use sed because our version of gawk is too old/buggy. :( I plan to introduce very shortly 1. parallelism 2. 'sysc snapshot' which will start from sysc to avoid this. I do not want to use linux-libre tarballs because they make modificiations directly from this script (aka not easily verifiable, use the source!) and this script allows for much greater flexibility. - We compile the initramfs ahead-of-build using the in-tree cpio generator instead of also building cpio to use less packages. We do NOT build the initramfs into the kernel like 2.6 (unsupported). - Oh and fix a kexec-tools checksum.
65 lines
1.8 KiB
Bash
Executable file
65 lines
1.8 KiB
Bash
Executable file
#!/usr/bin/bash
|
|
|
|
# SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
set -e
|
|
|
|
. bootstrap.cfg
|
|
|
|
export PATH=/usr/bin:/usr/sbin
|
|
|
|
# Unload the current kernel before things go weird
|
|
kexec -u
|
|
|
|
populate_device_nodes() {
|
|
# http://www.linuxfromscratch.org/lfs/view/6.1/chapter06/devices.html
|
|
test -c /dev/null || mknod -m 666 /dev/null c 1 3
|
|
test -c /dev/zero || mknod -m 666 /dev/zero c 1 5
|
|
test -c /dev/ptmx || mknod -m 666 /dev/ptmx c 5 2
|
|
test -c /dev/tty || mknod -m 666 /dev/tty c 5 0
|
|
test -c /dev/random || mknod -m 444 /dev/random c 1 8
|
|
test -c /dev/urandom || mknod -m 444 /dev/urandom c 1 9
|
|
}
|
|
|
|
create_hdx() {
|
|
# Create all of the sd{a,b,c..}
|
|
minor=0
|
|
alpha="a b c d e f g h i j k l m n o p" # 16 disks -- more than enough
|
|
# For each disk...
|
|
for a in ${alpha}; do
|
|
mknod -m 600 "/dev/sd${a}" b 8 "$((minor++))"
|
|
# For each partition...
|
|
for p in $(seq 15); do
|
|
mknod -m 600 "/dev/sd${a}${p}" b 8 "$((minor++))"
|
|
done
|
|
done
|
|
}
|
|
|
|
# If there is no disk specified error out
|
|
if [ -z "${DISK}" ]; then
|
|
echo "You must specify a disk where sysb will be located!"
|
|
exit 1
|
|
fi
|
|
|
|
# Otherwise, add stuff from sysa to sysb
|
|
echo "Mounting sysc"
|
|
mkdir /sysc
|
|
# All the various structures that don't exist but needed to mount
|
|
mkdir -p /etc /dev
|
|
populate_device_nodes
|
|
create_hdx
|
|
mount -t ext4 "/dev/${DISK}" /sysc
|
|
|
|
# Copy over appropriate data
|
|
echo "Copying data into sysc"
|
|
cp -r /dev /sysc/
|
|
# Don't include /usr/src
|
|
find /usr -mindepth 1 -maxdepth 1 -type d -not -name src -exec cp -r {} /sysc/{} \;
|
|
sync
|
|
|
|
# switch_root into sysc 1. for simplicity 2. to avoid kexecing again
|
|
# spouts a few errors because we don't have /proc /sys or /dev mounted
|
|
echo "Switching into sysc"
|
|
exec switch_root /sysc /init
|