Re: Another attempt at S6 init

2015-04-21 Thread Avery Payne



On 4/21/2015 7:34 AM, TheOldFellow wrote:


So I should need much less than Laurent has in his example.  (did I mention
the ancient grey cells?)
I'm no expert at execline, so I'm taking wild guesses here based on the 
little bits that I know from reading about it.



#close stdout and stderr
fdclose 1 fdclose 2
...would it hurt anything to move the fdclose 1  2 near the connect 
stdin to /dev/null?  Yes your console will be noisy but you at least 
get to see if anything is hurt or wounded prior to re-plumbing everything.


At Laurent's website, it mentions setting up an early getty so that you 
have access to something during the boot.

   The best suggestion is probably 'use
systemd', but please refrain.

(saying this while I cover my ears) You said the s word.


Re: Another attempt at S6 init

2015-04-21 Thread Laurent Bercot

On 21/04/2015 23:19, TheOldFellow wrote:

I am trying to write the init-stage1 script, so (B).  The initrd has
completed by the time it runs, since root is a lvm2 partition /dev
must be mounted in initrd so that /dev/mapper/'root' can be mounted
on /.  That's the main function of my initrd, incidentally it has to
mount /sys and /proc to do this.

The script is running after /dev is mounted, but before anything has
been set up as hotplug.

What I think I have to do is to prepare the logger and execve into
stage2.


 Right. You only have to do this.
 Do you keep your initrd after pivot_rooting, or do you unmount it ?
 If you keep it, it's a suitable place to put the scandir and the
live service directories. If you don't keep it, you have to create a
tmpfs first.

 Something like this (replace ${TMPFS} with your chosen location) :


if { s6-mount -wt tmpfs -o mode=0755,size=67108864 tmpfs ${TMPFS} }
if { s6-hiercopy /img/tmpfs ${TMPFS} }
redirfd -r 0 /dev/null
redirfd -wnb 1 ${TMPFS}/service/s6-svscan-log/fifo
fdmove -c 2 1
s6-envdir /etc/s6-init/env
background
{
  s6-setsid
  redirfd -w 1 ${TMPFS}/service/s6-svscan-log/fifo
  /etc/s6-init/init-stage2
}
unexport !
s6-svscan -t0 ${TMPFS}/service


 You don't need to close stdin/stdout/stderr, the redirections will
work fine. The advantage of not closing them is that you'll see the
error message if s6-mount or s6-hiercopy fails.
(I should make it clearer that the close the standard descriptors
thing is only useful when you want to change /dev under init's feet,
and you don't need that here.)

 Note that in the script you posted, there was a s6hiercopy
instead of s6-hiercopy. Check that your original script doesn't
include the typo.
 If there's no typo, be aware that this script needs a correct
hierarchy in /img/tmpfs: at least /img/tmpfs/service for the
scandir and the initial services such as s6-svscan-log.



I have a further problem in that the Kernel Panic obliterates the
on-screen track, so there is no information about that cause the
panic.  It would help if there was a 'panic silently' boot switch!


 Try loglevel=0.
 If it doesn't work, try console=null.
 If it doesn't work either, since you have access to your disk at
this point, mount your disk read-write and insert debug instructions
writing to disk and syncing the disk before each line in the script.
 After a crash, reboot with init=/bin/sh and examine the file that
was written to know what the last correctly executed instruction was.
(i.e. printf debugging, boot-style!)

--
 Laurent


Re: Another attempt at S6 init

2015-04-21 Thread Laurent Bercot

On 21/04/2015 16:34, TheOldFellow wrote:

I have built a fresh LFS, it is on a LVM2 partition, so I need an
Initramfs, and this enters the Stage 1 script with a devtmpfs somewhat
populated, and /sys and /proc already mounted.  My thinking is that these
mounts are OK, and I don't see any advantage in umounting them, just to
remake /dev in a tmpfs.


 Indeed, you don't need much, but what you need to do depends on what you
want. Please give us the following details:
 What are you trying to write here:
 A. the /init script of the initramfs ?
 or B. a script that will run after your initramfs has --moved ?

 If A: what do you want it to do ?
 1. keep your initramfs as rootfs ?
 or 2. have it modprobe, mount your LVM2 filesystem, and mount --move
your root filesystem ?

--
 Laurent