Subject: [alpine-devel] Some questions about initramfs-init.

From: Magicloud Magiclouds <[email-masked]>
Date: Sat, 30 Mar 2019 02:17:09 +0800

Hi,

I'd like to propose a rewrite of the initrd `init` script. Because I
think it is quite mixed up of booting logic, and missing some
customization possibilities.

But before that, I need to get some questions clear. In following
discussion, "stage 1" means the initrd system (before switch_root),
"stage 2" means the actual system end user uses (after switch_root).

1. Why there is a keymap setup? I cannot see the necessity of it
except for fallback/single shell.
2. Why networking is after nlplug-findfs? Can I bring up network (if
needed) before nlplug-findfs?
3. Since nlplug-findfs already output a repofile, why there is a
find_boot_repositories soon after to overwrite repofile?
4. Since apk works without /etc/apk/arch, why overwrite it with `apk
--print-arch`, instead of just removing it?
5. The script contains two ways of using repofile. One is using it
directly as "--repositories-file", the other is joining its content
with "--repository". What is the difference?

Thanks.

-- 
竹密岂妨流水过
山高哪阻野云飞

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Natanael Copa <[email-masked]>
Date: Fri, 29 Mar 2019 19:34:53 +0100

On Sat, 30 Mar 2019 02:17:09 +0800

> except for fallback/single shell.

We have support for encrypted apkovls, for "disk less" installs. You
may need to type the password to decrypt the configuration.

> needed) before nlplug-findfs?

nlplug-findfs also serves as coldplug, and enumerates all the current
devices so all kernel modules gets loaded. Without this there is no
guarantee that the network driver is automatically detected and loaded.

> find_boot_repositories soon after to overwrite repofile?

I will have to consult the source code and git log. I don't remember.

> --print-arch`, instead of just removing it?

Because it was an upgrade path from 32bit x86 to 64 bit diskless
installs. You can simply copy an apkovl from 32 bit install to a 64 bit
boot USB and the entire install is 64 bit after that. Without the
--print-arch logic it would error because it wouldnt find the packages.

> with "--repository". What is the difference?

IIRC, --repositories-file will replace the
default /etc/apk/repositories, while --repository will append the
specified repo to whatever is listed in /etc/apk/repositories

---

---

From: Magicloud Magiclouds <[email-masked]>
Date: Sat, 30 Mar 2019 02:45:27 +0800

Thanks. I still do not get the arch part. Detail is after the question.

> may need to type the password to decrypt the configuration.
Ah, I forgot that requirement.
> guarantee that the network driver is automatically detected and loaded.
I see.
> I will have to consult the source code and git log. I don't remember.
Just FYI, from line 520, if there is no network requirement,
nlplug-findfs (in line 528) gets the option "-b $repofile". Then in
line 667, $repofile is overwrite by find_boot_repositories.
> --print-arch logic it would error because it wouldnt find the packages.
I do not think I followed.

I can see the following case. Say my apkovl is 32bit, so
$sysroot/etc/apk/arch is x86 (I guess, I do not have a 32bit env to
check). So current logic overwrites it with x86_64, so following apk
bootstrap uses 64bit packages.

But if just removing the 32bit arch file, would not apk in new boot
USB (which contains 64 bit system) using 64bit packages by default?
> specified repo to whatever is listed in /etc/apk/repositories
I see.

-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.

---

---

From: Magicloud Magiclouds <[email-masked]>
Date: Sun, 31 Mar 2019 18:16:03 +0800

I think I get why overwriting $repofile, it is because of the
relocate_mount. But if that, "nlplug_findfs -b" call seems non-sense.

Also, where is $ovl_unmount defined?

-- 
竹密岂妨流水过
山高哪阻野云飞

---

---

From: Magicloud Magiclouds <[email-masked]>
Date: Sun, 31 Mar 2019 18:44:38 +0800

And thinking about it, I am confused on why relocate_mount so many times.

There are three calls. 1. if apkovl contains fstab; 2. else if stage1
contains fstab; 3. else if packages install a fstab. But consider that
there is no umount call, and move mount only occurs before
switch_root. I cannot see the point of relocating them during stage1.

-- 
竹密岂妨流水过
山高哪阻野云飞

---

---

From: Tuan Hoang <[email-masked]>
Date: Tue, 9 Apr 2019 15:16:00 +0200

>> guarantee that the network driver is automatically detected and loaded.

There are cases where I have nasty hack that I put 'nlplug-findfs -p
/sbin/mdev' (no root dir) before configure_ip and it kind of works. I
couldn't speak for normal/mainstream installation though because it
might break people's stuffs.

I think Alpine scripts in general is very friendly and flexible to hack
to match your needs. If it turns out that people x and/or group y also
need your hack, then a PR is very welcomed and necessary.

Cheers,

---

---

From: Magicloud Magiclouds <[email-masked]>
Date: Wed, 10 Apr 2019 11:42:04 +0800

Thanks for the info.

My intention is to save the hacking work. I like things to be
configurable or appendable. Also, some code seems out of maintain. For
example, ALPINE_MNT, I could not find its definition or where
assigned.

PS: For PR, I am not sure if github works. I had one to fix VIM syntax
highlight issue (very small), but no response for quite a while.

-- 
竹密岂妨流水过
山高哪阻野云飞

---

---

From: Milan P. Stanić <[email-masked]>
Date: Wed, 10 Apr 2019 15:18:50 +0200

> Thanks for the info.
[...]
> highlight issue (very small), but no response for quite a while.

Could you post URL of the PR, I'm working on fixes for VIM these days
and  it would nice to see your work.

[...]

-- 
regards

---

---

From: Magicloud Magiclouds <[email-masked]>
Date: Wed, 17 Apr 2019 17:22:50 +0800

Sorry, just saw this now. It is just a minor change for VIM  syntax highlight.

https://github.com/alpinelinux/mkinitfs/pull/50

-- 
竹密岂妨流水过
山高哪阻野云飞

---

---

From: Milan P. Stanić <[email-masked]>
Date: Wed, 17 Apr 2019 12:15:56 +0200

[ Don't CC me, I'm subscribed to list ]

> Sorry, just saw this now. It is just a minor change for VIM  syntax highlight.

No problem.
 
> https://github.com/alpinelinux/mkinitfs/pull/50

I'm not familiar with github PRs, but to me this fix looks it is for
mkinitfs and not for vim. Or I'm  wrong?

---

---

From: Magicloud Magiclouds <[email-masked]>
Date: Wed, 17 Apr 2019 22:27:19 +0800

The problem is on VIM parsing the code. So either fixing VIM to allow
this usage, or fixing the code to make VIM work.

I have no idea how VIM works. So I made change on this side.

-- 
竹密岂妨流水过
山高哪阻野云飞

---

---

From: Milan P. Stanić <[email-masked]>
Date: Wed, 17 Apr 2019 17:21:07 +0200

> this usage, or fixing the code to make VIM work.

Just opened src/mkinitfs-3.2.0/initramfs-init.in with vim in stable
release and it looks ok, after and before mentioned line.

---

---

From: Magicloud Magiclouds <[email-masked]>
Date: Thu, 18 Apr 2019 23:07:46 +0800

Hum.... I am using 8.1 in Archlinux that has this problem. And I tried
to run vim with sudo to rule out .vimrc, it still broke. Could you
give your vim information so maybe I could get help from VIM side?

$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 29 2019 20:08:59)
Included patches: 1-1073
Compiled by Arch Linux
Huge version without GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            -farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    +tcl/dyn
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +textprop
+byte_offset       -hangul_input      +num64             +timers
+channel           +iconv             +packages          +title
+cindent           +insert_expand     +path_extra        -toolbar
-clientserver      +job               +perl/dyn          +user_commands
-clipboard         +jumplist          +persistent_undo   +vartabs
+cmdline_compl     +keymap            +postscript        +vertsplit
+cmdline_hist      +lambda            +printer           +virtualedit
+cmdline_info      +langmap           +profile           +visual
+comments          +libcall           +python/dyn        +visualextra
+conceal           +linebreak         +python3/dyn       +viminfo
+cryptv            +lispindent        +quickfix          +vreplace
+cscope            +listcmds          +reltime           +wildignore
+cursorbind        +localmap          +rightleft         +wildmenu
+cursorshape       +lua/dyn           +ruby/dyn          +windows
+dialog_con        +menu              +scrollbind        +writebackup
+diff              +mksession         +signs             -X11
+digraphs          +modify_fname      +smartindent       -xfontset
-dnd               +mouse             +startuptime       -xim
-ebcdic            -mouseshape        +statusline        -xpm
+emacs_tags        +mouse_dec         -sun_workshop      -xsmp
+eval              +mouse_gpm         +syntax            -xterm_clipboard
+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2
-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
-fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
-fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.28/core_perl/CORE
-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib
-Wl,--as-needed -o vim        -lm -ltinfo -lelf -lnsl    -lacl -lattr
-lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.28/core_perl/CORE
-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
-fstack-protector-strong -L/usr/local/lib
-L/usr/lib/perl5/5.28/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt
-lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm

-- 
竹密岂妨流水过
山高哪阻野云飞

---

---

From: Milan P. Stanić <[email-masked]>
Date: Thu, 18 Apr 2019 18:31:14 +0200

> VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 29 2019 20:08:59)

This is on Arch Linux.

Try to use Alpine stable and edge, vim works fine looking into
src/mkinitfs-3.2.0/initramfs-init.in

[...]

-- 
regards

---

---

From: Magicloud Magiclouds <[email-masked]>
Date: Fri, 19 Apr 2019 18:07:46 +0800

OK. Confirmed. And it is not something different on sh.vim. Got to dig more.

Thanks.

-- 
竹密岂妨流水过
山高哪阻野云飞

---

---

From: Magicloud Magiclouds <[email-masked]>
Date: Fri, 19 Apr 2019 23:36:12 +0800

Just noticed, that actually Alpinelinux VIM cannot parse this line
correctly as well. But in a different way, and cannot be fixed by an
escaping.

-- 
竹密岂妨流水过
山高哪阻野云飞

---