Alpine Linux Porting (1.9999)

如上篇所说,这篇开始需要开始来理解OpenRC的流程。
然而即便这样,我还是希望用比较just enough的方式来处理,首先看了一下openrc的help string,发现他其实有--verbose的选项可以用,於是我便兴冲冲地在Alpine Init的swtich_root前挡了一到busybox sh、让我先进去/sysroot/etc里面修改inittab当中openrc的启动参数。结果它喷了一串kernel OOM讯息:

[   39.361634] init invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
[   39.362621] CPU: 0 PID: 1 Comm: init Not tainted 5.10.7 #2
[   39.363237] Call Trace:
[   39.363638] [<c040261a>] walk_stackframe+0x0/0xa6
[   39.364069] [<c0abbf50>] show_stack+0x32/0x3e
[   39.364432] [<c0abe718>] dump_stack+0x70/0x8e
[   39.364782] [<c0abd664>] dump_header+0x46/0x23e
[   39.365146] [<c04c5610>] out_of_memory+0x368/0x3b8
[   39.365536] [<c04fc5ee>] __alloc_pages_nodemask+0x4c2/0x8e6
[   39.365963] [<c04ea86a>] handle_mm_fault+0x3fc/0xa66
[   39.366348] [<c0404e2a>] do_page_fault+0xc8/0x256
[   39.366724] [<c040128a>] ret_from_exception+0x0/0xc
[   39.367307] Mem-Info:
[   39.367814] active_anon:384 inactive_anon:23988 isolated_anon:0
[   39.367814]  active_file:0 inactive_file:0 isolated_file:0
[   39.367814]  unevictable:0 dirty:0 writeback:0
[   39.367814]  slab_reclaimable:200 slab_unreclaimable:810
[   39.367814]  mapped:210 shmem:2273 pagetables:27 bounce:0
[   39.367814]  free:259 free_pcp:4 free_cma:0
[   39.370232] Node 0 active_anon:1536kB inactive_anon:95952kB active_file:0kB inactive_file:0kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:840kB dirty:0kB writeback:0kB shmem:9092kB writeback_tmp:0kB kernel_stack:264kB all_unreclaimable? yes
[   39.371978] Normal free:1036kB min:1044kB low:1304kB high:1564kB reserved_highatomic:0KB active_anon:1536kB inactive_anon:95952kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:126976kB managed:104528kB mlocked:0kB pagetables:108kB bounce:0kB free_pcp:16kB local_pcp:16kB free_cma:0kB
[   39.374135] lowmem_reserve[]: 0 0
[   39.374584] Normal: 1*4kB (M) 5*8kB (UM) 4*16kB (UM) 1*32kB (M) 2*64kB (UM) 2*128kB (UM) 0*256kB 1*512kB (U) 0*1024kB 0*2048kB 0*4096kB = 1036kB
[   39.375961] 2273 total pagecache pages
[   39.376424] 0 pages in swap cache
[   39.376854] Swap cache stats: add 0, delete 0, find 0/0
[   39.377385] Free swap  = 0kB
[   39.377721] Total swap = 0kB
[   39.378208] 31744 pages RAM
[   39.378536] 0 pages HighMem/MovableOnly
[   39.378935] 5612 pages reserved
[   39.379447] Tasks state (memory values in pages):
[   39.379917] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[   39.381328] Out of memory and no killable processes...
[   39.382250] Kernel panic - not syncing: System is deadlocked on memory
[   39.383159] CPU: 0 PID: 1 Comm: init Not tainted 5.10.7 #2
[   39.383788] Call Trace:
[   39.384168] [<c040261a>] walk_stackframe+0x0/0xa6
[   39.384751] [<c0abbf50>] show_stack+0x32/0x3e
[   39.385142] [<c0abe718>] dump_stack+0x70/0x8e
[   39.385519] [<c0abc176>] panic+0xfa/0x2a2
[   39.385870] [<c04c563c>] out_of_memory+0x394/0x3b8
[   39.386253] [<c04fc5ee>] __alloc_pages_nodemask+0x4c2/0x8e6
[   39.386686] [<c04ea86a>] handle_mm_fault+0x3fc/0xa66
[   39.387094] [<c0404e2a>] do_page_fault+0xc8/0x256
[   39.387470] [<c040128a>] ret_from_exception+0x0/0xc
[   39.388651] ---[ end Kernel panic - not syncing: System is deadlocked on memory ]---

老实说应该是要进去看怎麽会开个verbose就把busyboxinit给炸了,但是这边想先绕个路去看一下有没有其他的verbose可以开。此时发现OpenRC文件有提及:
可以在/etc/rc.conf中,将rc_verbose=yes,便会启动一定程度的verbose output:

 * Executing: /lib/rc/sh/openrc-run.sh /lib/rc/sh/openrc-run.sh /etc/init.d/dmesg start
 * Executing: /lib/rc/sh/openrc-run.sh /lib/rc/sh/openrc-run.sh /etc/init.d/modloop start
 * Mounting modloop  ... [ !! ]
 * ERROR: modloop failed to start
 * Executing: /lib/rc/sh/openrc-run.sh /lib/rc/sh/openrc-run.sh /etc/init.d/sysfs start

如果想要的话,其实也可以去改那只openrc-run.sh加个set -x来慢慢看。
然而,我倒是被另一件事情吸引了注意力,那就是Alpine Init里面有一个function

setup_inittab_console(){                                                        
    term=vt100                                                                  
    # Inquire the kernel for list of console= devices                                                                                                          
    consoles="$(for c in console $KOPT_consoles; do list_console_devices $c; done)"
    for tty in $consoles; do                                                    
        # do nothing if inittab already have the tty set up                     
        if ! grep -q "^$tty:" $sysroot/etc/inittab; then                        
            echo "# enable login on alternative console" \                      
                >> $sysroot/etc/inittab                                         
            # Baudrate of 0 keeps settings from kernel                          
            echo "$tty::respawn:/sbin/getty -L 0 $tty $term" \                  
                >> $sysroot/etc/inittab                                         
        fi                                                                      
        if [ -e "$sysroot"/etc/securetty ] && ! grep -q -w "$tty" "$sysroot"/etc/securetty; then
            echo "$tty" >> "$sysroot"/etc/securetty                             
        fi                                                                      
    done                                                                        
} 

我原本以为是OpenRC惹祸的部份,看起来是Alpine Init自作主张去把一票getty设进去造成的。
把这边抹掉之後,下一篇进板子再试试看~


<<:  Day 18:AWS是什麽?30天从动漫/影视作品看AWS服务应用 -《新世纪福音战士》

>>:  30天学会 Python: Day 19-考试常用的输入格式

D20 - 用 Swift 和公开资讯,打造投资理财的 Apps { 移动平均线(MA线)实作.3 }

扩充 MAUtility,让原来的 func 能计算 n 条均线 在原来的 func 上加上 ran...

Day 20. Hashicorp Nomad: Docker driver image behavior

Hashicorp Nomad: Docker driver image behavior 在Has...

PHP 检查是否符合程序码风格:CodeSniffer

前言 工作後才知道,有很多开源的工具能自动帮你检查 source code 是否写得符合各语言的程序...

DAY01 - 初次参加铁人赛的中年大叔の简介

前言: 这是大叔的第一次...参加IT铁人赛,不免俗的在参赛的第一篇要交代一下个人背景与参赛动机。 ...

Day23-按钮分身术(上)_纯CSS汉堡图样与改变

今天明天要来写纯CSS可控制的按钮分身术 感谢室友的idea提供~ 之前在重写网站时的首页按钮也是类...