sh Lazy Init System(获得快速用户模式Linux shell)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Lazy Init System(获得快速用户模式Linux shell)相关的知识,希望对你有一定的参考价值。

#!/bin/sh

# The Lazy Init System for Lazy People
# ------------------------------------
#  by: Ethan McTague <ethan@tague.me>
#     Copyright 2018 Ethan McTague
# ------------------------------------
#
# This is an init system that sets up
# critical things, opens a login
# screen, and then shuts down when you
# log out.
#
# To use, put it wherver your kernel
# is set to init from (usually /init
# or /sbin/init) and make it
# executable.
#
# Only tested in user-mode linux.
# Might work elsewhere.
# You have been warned.
#
# ------------------------------------
# 
# Benefits:
# - Fast boot is convenient for UML.
# - Predictable - literally only bash
#   will be running on your system
#   once it's booted.
# - It isn't systemd.
# 
# Drawbacks:
# - No daemon initialization.
# - Hard-coded mounting behavior.
# - Doesn't use /etc/initctl.
# - Generally a bad idea.
# - Obnoxiously large header comment.
# - It isn't systemd.
#
# ------------------------------------

# Mount Filesystems
mount -t proc     proc   /proc    -o nosuid,noexec,nodev
mount -t sysfs    sys    /sys     -o nosuid,noexec,nodev
mount -t tmpfs    run    /run     -o mode=0755,nosuid,nodev
mount -t devtmpfs dev    /dev     -o mode=0755,nosuid
mount -t devpts   devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
mount -t tmpfs    shm    /dev/shm -o mode=1777,nosuid,nodev

# Set Hostname
cat /etc/hostname > /proc/sys/kernel/hostname

# Start Shell (Yes, it must run nested like this.)
/bin/bash -c 'agetty tty0'

# Shut Down
echo e > /proc/sysrq-trigger # SIGTERM to all processes except this one
echo s > /proc/sysrq-trigger # Sync Filesystems
echo u > /proc/sysrq-trigger # Unmount Filysystems
echo o > /proc/sysrq-trigger # Power off

# Wait for Shutdown to Finish
sleep infinity

以上是关于sh Lazy Init System(获得快速用户模式Linux shell)的主要内容,如果未能解决你的问题,请参考以下文章

spring 之 lazy-init Autowired depends-on

Spring IOC源码剖析:lazy-init 延迟加载机制和循环依赖问题

使用 hibernate.enable_lazy_load_no_trans 解决 Hibernate Lazy-Init 问题

尝试激活服务时无法解析类型“System.Lazy`1[System.Net.Http.IHttpClientFactory]”的服务

Spring IOC高级特性:lazy-Init 延迟加载FactoryBean 和 BeanFactory后置处理器

System.Lazy<T> 如何访问 T 的私有构造函数?