关于 select
, poll
和 epoll
系统调用
OS
Linux 启动流程 (BIOS)
启动流程 #
开机自检(POST) -> 主板固件(BIOS) -> Boot Loader 引导(grub2) vmlinuz运行 -> 内核挂载文件系统 -> 初始化(systemd)
开机自检 (POST) #
当计算机开机时,BIOS(Basic Input Output System) 首先进行自检 POST(Power-On Self Test),检查硬件组件(如内存、硬盘、显卡等)是否正常工作
加载引导程序 #
TODO
其他 #
使用 initial RAM disk (initrd) #
initrd
提供了通过 boot loader
程序加载 RAM 磁盘的能力,然后这个 RAM 磁盘可以被挂载为根文件系统,并可以从中运行程序。之后,可以从不同的设备挂载新的文件系统,然后将前一个根目录(来自initrd)移动到一个目录,然后可以卸载。
initrd
主要设计为允许系统启动分为两个阶段进行,其中内核携带最少的编译进去的驱动程序集,从 initrd
加载其他模块。
当时用 initrd
,系统通常按照下面顺序启动:
boot loader
(一般是grub
) 加载内核vmlinuz
和 initial RAM diskinitrd.img
, 具体的文件名要看/boot/grub/grub.cfg
中的 menu 设置。
TODO
...Multi-Bootable USB
从一个USB设备(U盘)启动多个操作系统, 并且U盘还能继续存储其他普通文件
下载并解压ventoy
#
wget https://github.com/ventoy/Ventoy/releases/download/v1.0.97/ventoy-1.0.97-linux.tar.gz
tar -xvzf ventoy-1.0.97-linux.tar.gz
cd ventoy-1.0.97/
Ventoy2Disk.sh
用来安装ventor
到U盘
./Ventoy2Disk.sh -h
**********************************************
Ventoy: 1.0.97 x86_64
longpanda admin@ventoy.net
https://www.ventoy.net
**********************************************
Usage: Ventoy2Disk.sh CMD [ OPTION ] /dev/sdX
CMD:
-i install Ventoy to sdX (fails if disk already installed with Ventoy)
-I force install Ventoy to sdX (no matter if installed or not)
-u update Ventoy in sdX
-l list Ventoy information in sdX
OPTION: (optional)
-r SIZE_MB preserve some space at the bottom of the disk (only for install)
-s/-S enable/disable secure boot support (default is enabled)
-g use GPT partition style, default is MBR (only for install)
-L Label of the 1st exfat partition (default is Ventoy)
-n try non-destructive installation (only for install)
安装ventoy #
# ./Ventoy2Disk.sh -I /dev/sdb
**********************************************
Ventoy: 1.0.97 x86_64
longpanda admin@ventoy.net
https://www.ventoy.net
**********************************************
Disk : /dev/sdb
Model: Kingston DataTraveler 3.0 (scsi)
Size : 115 GB
Style: MBR
Attention:
You will install Ventoy to /dev/sdb.
All the data on the disk /dev/sdb will be lost!!!
Continue? (y/n) y
All the data on the disk /dev/sdb will be lost!!!
Double-check. Continue? (y/n) y
Create partitions on /dev/sdb by parted in MBR style ...
Done
Wait for partitions ...
partition exist OK
create efi fat fs /dev/sdb2 ...
mkfs.fat 4.2 (2021-01-31)
success
Wait for partitions ...
/dev/sdb1 exist OK
/dev/sdb2 exist OK
partition exist OK
Format partition 1 /dev/sdb1 ...
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.
mkexfatfs success
writing data to disk ...
sync data ...
esp partition processing ...
Install Ventoy to /dev/sdb successfully finished.
查看最终的U盘分区, sdb1
分区是存放iso
镜像的