cleanup modules after loading, makes it possible to boot the normal ISO with 700M

This commit is contained in:
Tobias Powalowski 2023-05-07 09:38:50 +02:00
parent 0f009ee8e4
commit 25daeabb92
2 changed files with 28 additions and 18 deletions

View file

@ -36,7 +36,7 @@ modprobe -q zram
modprobe -q zstd
echo 1 > /proc/sys/kernel/sysrq
echo -e "\e[1mInitializing\e[m \e[36mArchboot\e[m \e[1m- Arch Linux Environment:\e[m"
echo -e "\e[1mStep 1/5:\e[m Searching for archboot rootfs on usb/hd/cdrom device..."
echo -e "\e[1mStep 1/6:\e[m Searching for archboot rootfs on usb/hd/cdrom device..."
echo -e " Trying for 10 seconds /dev/sr0 and UUID=1234-ABCD..."
_COUNT=0
while true; do
@ -57,7 +57,8 @@ if ! [[ -f "/mnt/boot/initramfs-$(uname -m).img" ]] ; then
fi
cd /
# move in modules from main initramfs
echo -e "\e[1mStep 2/5:\e[m Copying and loading modules from main initramfs..."
echo -e "\e[1mStep 2/6:\e[m Copying and loading modules from initramfs-$(uname -m).img..."
echo -e " This may need some time..."
bsdcpio -u -i "*/lib/modules/" "*/lib/firmware/" <"/mnt/boot/initramfs-$(uname -m).img" &>/dev/null || _emergency_shell
# reinitialize available modules
udevadm control -R
@ -65,6 +66,11 @@ _udev_trigger
# shutdown udevd
udevadm control --exit
udevadm info --cleanup-db
echo -e "\e[1mStep 3/6:\e[m Removing firmware and modules..."
# cleanup firmware and modules
rm -rf /lib/firmware
rm -rf /lib/modules/*/kernel/drivers/{acpi,ata,gpu,bcma,block,bluetooth,hid,input,platform,net,scsi,soc,spi,usb,video}
rm -rf /lib/modules/*/extramodules
# it needs one echo before, in order to reset the consolefont!
FB_SIZE="$(cut -d 'x' -f 1 "$(find /sys -wholename '*fb0/modes')" | sed -e 's#.*:##g')"
if [[ "${FB_SIZE}" -gt '1900' ]]; then
@ -73,17 +79,17 @@ else
SIZE="16"
fi
setfont consolefont-${SIZE}.psf.gz -C /dev/console
echo -e "\e[1mStep 3/5:\e[m Creating /dev/zram0 with zstd compression..."
echo -e "\e[1mStep 4/6:\e[m Creating /dev/zram0 with zstd compression..."
echo "zstd" >/sys/block/zram0/comp_algorithm
echo "4G" >/sys/block/zram0/disksize
echo -e "\e[1mStep 4/5:\e[m Creating btrfs on /dev/zram0..."
echo -e "\e[1mStep 5/6:\e[m Creating btrfs on /dev/zram0..."
mkfs.btrfs /dev/zram0 &>/dev/null
# use discard to get free RAM on delete!
mount -o discard /dev/zram0 /sysroot &>/dev/null
echo -e "\e[1mStep 5/5:\e[m Copying archboot rootfs files to /sysroot..."
echo -e "\e[1mStep 6/6:\e[m Copying rootfs files to /sysroot..."
echo -e " This may need some time..."
mkdir -p /sysroot/usr/lib
mv /lib/{modules,firmware} /sysroot/usr/lib
mv /lib/modules /sysroot/usr/lib
cd /sysroot || _emergency_shell
bsdcpio -u -f "*/lib/modules/" -f "*/lib/firmware/" -i <"/mnt/boot/initramfs-$(uname -m).img" &>/dev/null || _emergency_shell
echo 0 > /proc/sys/kernel/sysrq

View file

@ -172,7 +172,7 @@
</head>
<body>
<h1>Archboot Homepage</h1>
<p>Last update 06.05.2023 12:22<br>&copy; Tobias Powalowski | Arch Linux Developer </span><a href="https://archlinux.org/people/developers/#tpowa"><strong>tpowa</strong></a> since 2004<span dir=""></p>
<p>Last update 07.05.2023 07:16<br>&copy; Tobias Powalowski | Arch Linux Developer </span><a href="https://archlinux.org/people/developers/#tpowa"><strong>tpowa</strong></a> since 2004<span dir=""></p>
<p><span dir=""><img src="https://pkgbuild.com/~tpowa/archboot/web/logo.png" alt="Logo"></span></p>
<p><span dir=""><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=Z7GXKW4MKHK7C"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="Donate" /></a> You like the project? I like coffee :-)</span></p>
<nav id="TOC" role="doc-toc">
@ -332,9 +332,9 @@
<td>&#10004;</td>
<td>&#10004;</td>
<td>&#10006;</td>
<td>336MB</td>
<td>457MB</td>
<td>459MB</td>
<td>312MB</td>
<td>417MB</td>
<td>417MB</td>
</tr>
<tr class="even">
<td><strong><em>date</em>-latest</strong></td>
@ -342,9 +342,9 @@
<td>&#10006;</td>
<td>DHCP<br>server needed</td>
<td>&#10004;</td>
<td>152MB</td>
<td>128MB</td>
<td></td>
<td>223MB</td>
<td>182MB</td>
</tr>
<tr class="odd">
<td><strong><em>date</em>-local</strong></td>
@ -352,9 +352,9 @@
<td>&#10004;</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td>556MB</td>
<td>532MB</td>
<td></td>
<td>793MB</td>
<td>753MB</td>
</tr>
</tbody>
</table>
@ -1004,22 +1004,26 @@ Its an initramdisk which includes everything. The calculated size to boot the
</tr>
<tr class="odd">
<td>Bootup speed systemd-analyze**</td>
<td>15 seconds</td>
<td>17 seconds</td>
<td>75 seconds</td>
</tr>
<tr class="odd">
<td>Minimum RAM to boot in MiB**</td>
<td>700</td>
<td>850</td>
</tr>
<td>Free RAM on system in MiB**</td>
<td>3136</td>
<td>3400</td>
<td>2853</td>
</tr>
<tr class="odd">
<td>Imagesize in MiB</td>
<td>223 - 793</td>
<td>182 - 753</td>
<td>853 </td>
</tr>
<tr class="even">
<td>ROOTFS size in MiB**</td>
<td>633</td>
<td>378</td>
<td>1700</td>
</tr>
<tr class="odd">