gentoo: 修复 systemd 没有自动创建 machine-id 导致 dhcp 无法获取 ip

This commit is contained in:
bin456789 2024-11-05 00:33:58 +08:00
parent ed278526ff
commit 5e9cc84a9e
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
3 changed files with 11 additions and 10 deletions

View File

@ -14,14 +14,14 @@ One-Click Script to Reinstall System [中文](README.md)
## Highlights ## Highlights
- Supports one-click installation of Linux: allows install 17 common distributions. - One-click Linux installation: allows install 17 common distributions.
- Supports one-click Windows installation: Uses the official ISO for installation instead of custom images. The script automatically retrieves the ISO link and installs `Virtio` and other drivers. - One-click Windows installation: Uses the official ISO for installation instead of custom images. The script automatically retrieves the ISO link and installs `Virtio` and other drivers.
- Supports installation in any direction, i.e., `Linux to Linux`, `Linux to Windows`, `Windows to Windows`, `Windows to Linux` - Supports installation in any direction, i.e., `Linux to Linux`, `Linux to Windows`, `Windows to Windows`, `Windows to Linux`
- No need to input IP parameters; automatically recognizes dynamic and static IPs, supports `/32`, `/128`, `gateway outside subnet`, `IPv6 only`, `dual NIC` and other special network configurations - No need to input IP parameters; automatically recognizes dynamic and static IPs, supports `/32`, `/128`, `gateway outside subnet`, `IPv6 only`, `dual NIC` and other special network configurations
- Specially optimized for low-spec servers, requires less memory than the official netboot - Specially optimized for low-spec servers, requires less memory than the official netboot
- Uses partition table ID to identify hard drives throughout the process, ensuring no wrong disk is written - Uses partition table ID to identify hard drives throughout the process, ensuring no wrong disk is written
- Supports BIOS and EFI boot, and ARM architecture - Supports BIOS and EFI boot, and ARM architecture
- No homemades image included, all resources are obtained in real-time from source sites - No homemades image included, all resources are obtained in real-time from mirror sites
- Includes many comments. - Includes many comments.
## System Requirements ## System Requirements
@ -254,7 +254,7 @@ bash reinstall.sh netboot.xyz
- The machine with a static IP will automatically configure the IP. It may take a few minutes to take effect on the first boot. - The machine with a static IP will automatically configure the IP. It may take a few minutes to take effect on the first boot.
- Supports all languages. - Supports all languages.
#### 支持的系统 #### Supported Systems
- Windows (Vista ~ 11) - Windows (Vista ~ 11)
- Windows Server (2008 ~ 2025) - Windows Server (2008 ~ 2025)

View File

@ -21,7 +21,7 @@
- 专门适配低配小鸡,比官方 netboot 需要更少的内存 - 专门适配低配小鸡,比官方 netboot 需要更少的内存
- 全程用分区表 ID 识别硬盘,确保不会写错硬盘 - 全程用分区表 ID 识别硬盘,确保不会写错硬盘
- 支持 BIOS、EFI 引导,支持 ARM - 支持 BIOS、EFI 引导,支持 ARM
- 不含自制包,所有资源均实时从源站点获得 - 不含自制包,所有资源均实时从镜像源获得
- 有很多注释 - 有很多注释
## 系统要求 ## 系统要求

View File

@ -1747,6 +1747,8 @@ EOF
# 此时不能用 # 此时不能用
# chroot $os_dir timedatectl set-timezone Asia/Shanghai # chroot $os_dir timedatectl set-timezone Asia/Shanghai
chroot $os_dir systemd-firstboot --force --timezone=Asia/Shanghai chroot $os_dir systemd-firstboot --force --timezone=Asia/Shanghai
# gentoo 不会自动创建 machine-id
clear_machine_id $os_dir
chroot $os_dir systemctl enable systemd-networkd chroot $os_dir systemctl enable systemd-networkd
chroot $os_dir systemctl enable systemd-resolved chroot $os_dir systemctl enable systemd-resolved
chroot $os_dir systemctl enable sshd chroot $os_dir systemctl enable sshd
@ -2260,9 +2262,8 @@ clear_machine_id() {
os_dir=$1 os_dir=$1
# https://www.freedesktop.org/software/systemd/man/latest/machine-id.html # https://www.freedesktop.org/software/systemd/man/latest/machine-id.html
if [ -f $os_dir/etc/machine-id ]; then # gentoo 不会自动创建该文件
echo uninitialized >$os_dir/etc/machine-id echo uninitialized >$os_dir/etc/machine-id
fi
# https://build.opensuse.org/projects/Virtualization:Appliances:Images:openSUSE-Leap-15.5/packages/kiwi-templates-Minimal/files/config.sh?expand=1 # https://build.opensuse.org/projects/Virtualization:Appliances:Images:openSUSE-Leap-15.5/packages/kiwi-templates-Minimal/files/config.sh?expand=1
rm -f $os_dir/var/lib/systemd/random-seed rm -f $os_dir/var/lib/systemd/random-seed
@ -2540,7 +2541,7 @@ EOF
download_cloud_init_config $os_dir download_cloud_init_config $os_dir
# clear_machine_id $os_dir clear_machine_id $os_dir
# el/ol/fedora/国产fork # el/ol/fedora/国产fork
# 1. 禁用 selinux kdump # 1. 禁用 selinux kdump
@ -3307,7 +3308,7 @@ install_qcow_by_copy() {
disable_selinux_kdump /os disable_selinux_kdump /os
# centos7 删除 machine-id 后不会自动重建 # centos7 删除 machine-id 后不会自动重建
# clear_machine_id /os clear_machine_id /os
# el7 yum 可能会使用 ipv6即使没有 ipv6 网络 # el7 yum 可能会使用 ipv6即使没有 ipv6 网络
if [ "$releasever" = 7 ]; then if [ "$releasever" = 7 ]; then