The flexibility is great wiakwiak wrote:You could also make 01firstrib_rootfs an empty directory, and use actual firstrib_rootfs renamed to upper_changes, but after some time rename upper_changes to say 50upper_changes (so it automatically gets used on next boot as one of the middle layers) and then the new auto-generated upper_changes will be small each time you want to keep it as a backup (or use later as say 51upper_changes and so on, though can always later merge them all together again).
I've been messing around modifying the init script to instead use chroot of the main system, as that way I can exit-chroot back out of that (back into initrd). Also set it so it runs totally in ram, with the initram sfs inside initrd.
Pauses at a initrd shell at bootup (prior to the chroot), so you can tweak the 'save' area as desired. And later you can exit-chroot (I've compiled that myself) to copy/store the save area as desired for later reboots.
That's one hell of a void modules list, impressed how you managed to figure that all out!
void seem to change many things often, so installing one day, adding things another does involve syncing prior to adding (xbps-install -S) i.e. potentially a new kernel and other majors so the less in the base system the better IMO. Would be nice to have a stable/unchanging version as from personal experiences sooner or later a current 'snapshot' will fail or have issues that cause downtime. One of the risks of a continually and active rolling release. Could I guess create my own local repo snapshot (static void ), perhaps even locally compiled, and refresh that periodically (perhaps 6 monthly).
Code: Select all
#!/bin/sh
###############################################
# /init (inside initrd)
# Based on original initramfs/init(04) by wiak 26 July 2019
# Simple chroot_root init with overlay filesystem set up.
# Copyright ; Licence MIT (aka X11 license)
# Rufwoof 2 Aug 2019
###############################################
_dmesg_quiet() {
dmesg -n 1 # Show only emergency (panic) messages
}
_mount_proc_sys_dev() {
# mount kernel required virtual filesystems and populate /dev
mount -t proc -o nodev,noexec,nosuid proc /proc
mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
mount -t devtmpfs -o mode=0755 none /dev
}
_load_modules_for_void_linux() {
# Modules need loaded by initramfs when using kernel from Void Linux
for m in mbcache aufs exportfs ext4 fat vfat fuse isofs nls_cp437 \
nls_iso8859-1 nls_utf8 reiserfs squashfs xfs libata ahci \
libahci sata_sil24 pdc_adma sata_qstor sata_sx4 ata_piix \
sata_mv sata_nv sata_promise sata_sil sata_sis sata_svw \
sata_uli sata_via sata_vsc pata_ali pata_amd pata_artop \
pata_atiixp pata_atp867x pata_cmd64x pata_cs5520 pata_cs5530 \
pata_cs5535 pata_cs5536 pata_efar pata_hpt366 pata_hpt37x \
pata_it8213 pata_it821x pata_jmicron pata_marvell pata_netcell \
pata_ns87415 pata_oldpiix pata_pdc2027x pata_pdc202xx_old pata_rdc \
pata_sc1200 pata_sch pata_serverworks pata_sil680 pata_sis \
pata_triflex pata_via pata_isapnp pata_mpiix pata_ns87410 pata_opti \
pata_rz1000 ata_generic loop cdrom hid hid_generic usbhid mptscsih \
mptspi mptsas tifm_core cb710 mmc_block mmc_core sdhci sdhci-pci \
wbsd tifm_sd cb710-mmc via-sdmmc vub300 sdhci-pltfm scsi_mod \
scsi_transport_spi scsi_transport_sas sd_mod sr_mod usb-common \
usbcore ehci-hcd ehci-pci ohci-hcd uhci-hcd xhci-hcd usb-storage xts
do
modprobe $m 2>/dev/null
done
}
_usbwait() {
# usbwait for slow devices
echo "usbwait for slow devices. Please wait patiently..." >/dev/console
usbwait=`egrep -o "usbwait=[^ ]+" /proc/cmdline | cut -d= -f2`
[ "$usbwait" ] && sleep $usbwait
}
_setup_chroot_folders() {
mkdir /CHR
cd /CHR
mkdir merged upper_changes work lower
}
_mount_sfs() {
mount /01firstrib_rootfs.sfs /CHR/lower
}
_load_modules_for_overlay() {
# Load module to allow overlay filesystem functionality
modprobe overlay && umount /usr/lib/modules 2>/dev/null
sync
}
_mount_overlay() {
# Combine the overlays with result in /CHR/merged
mount -t overlay -o lowerdir=/CHR/lower,upperdir=/CHR/upper_changes,workdir=/CHR/work overlay /CHR/merged
}
_move_mounts() {
mount -o move /sys /CHR/merged/sys
mount -o move /dev /CHR/merged/dev
mount -o move /proc /CHR/merged/proc
}
_cleanup_modules() {
# Remove unused modules to save memory
modprobe -r `lsmod | cut -d' ' -f1` 2>/dev/null
}
_sub_void() {
echo "You are now in init ramdisk - sub void level"
echo "when done making tweaks exit this shell to continue booting void"
setsid cttyhack /bin/sh
}
_chroot() {
exec chroot /CHR/merged /sbin/init
}
###############################################
_dmesg_quiet
_mount_proc_sys_dev
_load_modules_for_void_linux
_usbwait
_setup_chroot_folders
_mount_sfs
_load_modules_for_overlay
_mount_overlay
_move_mounts
_cleanup_modules
_sub_void
_chroot