Re: switch_root

From: Laurent Bercot <>
Date: Wed, 16 Oct 2013 21:09:49 +0100

> Advice taken. So far, I have rebuilt everything around s6* statically (against
> musl), with s6-linux-utils-1.0.2 having been the only PITA because of s6-devd,
> which doesn't compile and have temporarily substituted with a stub (I don't
> need s6-devd... yet, at the least) till I manage to figure out how to do it.

  Look a bit earlier in the archives: install the Sabotage Linux kernel headers
if you don't have other kernel headers already. It works fine with musl.

> (The static s6-mount is 52K in size, while the dynamic, stock -- slackware
> current -- mount alone is 92K, by the way; isn't it humorous?)

  It's util-linux. This mount has a lot of misc functionality, such as
calling specialized helpers for certain filesystems. It's not so bad. You
could probably statically link util-linux against musl (with some kernel
headers) and get almost reasonable binaries.

> #!/bin/mksh
> s6-mount -t proc proc /proc
> s6-mount -t sysfs sysfs /sys
> s6-mount -t devtmpfs devtmpfs /dev
> s6-mount -t tmpfs tmpfs /run
> s6-mount -t ext4 -o ro /dev/sda2 /newroot
> exec /sbin/switch_root /newroot /etc/s6-init/init

  At this point I am feeling compelled to ask you *why* you are using an
initramfs. You could directly boot on /dev/sda2 and mount /proc, /sys and
/run during stage 1 init, and have your devtmpfs automatically mounted by
the kernel.

  I understand writing a switch_root script can be fun, but if you are looking
to build a small, efficient system, then just cut the initramfs crap, spare
yourself a lot of work and just boot on your rootfs, using your stage 1 script
to do whatever you need to do very early.
  Really, initramfs is powerful and fun, but ultimately useless.

Received on Wed Oct 16 2013 - 20:09:49 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC