Re: -o remount,ro /

From: Eric Vidal <eric_at_obarun.org>
Date: Fri, 13 May 2016 15:36:59 +0400

> Make sure your live directory is on a mounted writable filesystem,
> typically a tmpfs.

This is the case, the live directory is on run with tmpfs type and this option : mode=0755,nosuid,nodev
 
> You probably mean stage 2, not pid 2. (pid 2 has no special meaning; and
> on Linux, it's often kthreadd.)

Yes, sorry for my bad language :)


> You can use lsof to identify what process is keeping a rw fd on your
> root filesystem, and configure it not to do that. If you find that the
> culprit is indeed s6-rc, then you are not hosting the live directory on a
> tmpfs and that's what you should fix.
 
So, i do a simple test : i boot with this init file :

# Export good path
/usr/local/bin/export PATH "/usr/local/bin:/usr/bin"

cd /

# parse s6.conf before loading environment
#foreground {
# redirfd -r 0 /etc/s6/s6.conf
# pipeline { s6-grep -vF -- "#" }
# forstdin -nCd"\n" -- conf
# import -ui conf
# multidefine -d"=" $conf { var value }
# foreground {
# if { mkdir -p /run/s6-conf/ }
# redirfd -w 1 /run/s6-conf/$var
# s6-echo -- $value
# }
#}
# Clean environment
emptyenv -p
s6-envdir -if /etc/s6/env


# Be clean and safe
s6-setsid -qb --
umask 022

if {
        s6-echo -- "********** Booting Obarun under S6\n Under development\n please give a feedback http://obarun.org/forum/ ******************\n"
}

# Copy service for pid1 in the right place
import -i stage1serv
foreground {
        cp -a ${stage1serv} /run/s6
}

# Create symlink to /run/s6-run
if {
  forbacktickx -p -0 i { s6-ls -0 /run/s6 }
  import -u i
  foreground
  {
        if { s6-mkdir -p -m 0755 /run/s6-run/ }
        s6-ln -s -- /run/s6/${i} /run/s6-run/
  }
}

redirfd -r 0 /dev/null
redirfd -wnb 1 /run/s6-run/service/s6-svscan-log/fifo

# Now we are good for stage2, start it
background {
  s6-setsid --
  fdmove -c 2 1
  /etc/stage2
}

unexport !
fdmove -c 2 1
s6-envdir -I /run/s6-run/service/.s6-svscan/
s6-svscan -st0 /run/s6-run/service

and on stage 2 i just have a bundle with 2 oneshot service on it. one named fsro for remount / with ro options like this :
#!/usr/local/bin/execlineb -P
fdmove -c 2 1
mount -o remount,ro /

and the other named fsrw for remount / with rw options. A dependencies is made under it calling fsro
and nothing more. tty1 is started on early boot time.

So this is the output of the command : lsof | awk '$4 ~ /[0-9].*w/' (note: if i do : lsof / | awk '$4 ~ /[0-9].*w/', nothing appear)

s6-svscan 1 root 1w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-svscan 1 root 2w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-svscan 1 root 5w FIFO 0,18 0t0 10321 /run/s6/service/.s6-svscan/control
s6-superv 131 root 1w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-superv 131 root 2w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-superv 131 root 5w FIFO 0,18 0t0 10324 /run/s6/service/early-tty1/supervise/control
s6-superv 132 root 1w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-superv 132 root 2w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-superv 132 root 5w FIFO 0,18 0t0 1313 /run/s6/service/s6-svscan-log/supervise/control
s6-log 134 s6log 1w CHR 5,1 0t0 1036 /dev/console
s6-log 134 s6log 2w CHR 5,1 0t0 1036 /dev/console
s6-log 134 s6log 3wW REG 0,18 0 9355 /run/s6/uncaught-logs/lock
s6-log 134 s6log 4w REG 0,18 175 9357 /run/s6/uncaught-logs/current
s6-superv 139 root 1w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-superv 139 root 2w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-superv 139 root 5w FIFO 0,18 0t0 8405 /run/s6-rc:initial/servicedirs/s6rc-fdholder/supervise/control
s6-superv 140 root 1w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-superv 140 root 2w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
s6-superv 140 root 5w FIFO 0,18 0t0 9404 /run/s6-rc:initial/servicedirs/s6rc-oneshot-runner/supervise/control
s6-ipcser 146 root 2w FIFO 0,18 0t0 9348 /run/s6/service/s6-svscan-log/fifo
lsof 162 root 1w FIFO 0,10 0t0 9427 pipe
lsof 162 root 5w FIFO 0,10 0t0 9436 pipe
zsh 163 root 1w REG 8,20 0 3332 /root/lsof
lsof 164 root 7w FIFO 0,10 0t0 9437 pipe

Surely i do something wrong, but honestly, i don't see where

> Note that booting with / rw, then remounting it ro for a fsck, then
> remounting it rw again, is useless and wasteful. You should boot with / ro
> directly, and only remount it rw when you really need it rw.

Yeah, you are absolutly right, but if a good exercice for me to understand how doing stuff :).

I have a another weird behaviour with s6rc-fdholder. It never bring up at boot, i need to start it manualy. This is the expected behaviour?

Hoping that i'm not annoying with my newbies question/posts.

Regards

-- 
Eric Vidal <eric_at_obarun.org>
Received on Fri May 13 2016 - 11:36:59 UTC

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