Skip to content

Commit

Permalink
gentoo: 修复 systemd 没有自动创建 machine-id 导致 dhcp 无法获取 ip
Browse files Browse the repository at this point in the history
  • Loading branch information
bin456789 committed Nov 4, 2024
1 parent ed27852 commit 5e9cc84
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ One-Click Script to Reinstall System [中文](README.md)

## Highlights

- Supports one-click installation of Linux: 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 Linux installation: allows install 17 common distributions.
- 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`
- 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
- 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
- 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.

## System Requirements
Expand Down Expand Up @@ -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.
- Supports all languages.

#### 支持的系统
#### Supported Systems

- Windows (Vista ~ 11)
- Windows Server (2008 ~ 2025)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- 专门适配低配小鸡,比官方 netboot 需要更少的内存
- 全程用分区表 ID 识别硬盘,确保不会写错硬盘
- 支持 BIOS、EFI 引导,支持 ARM
- 不含自制包,所有资源均实时从源站点获得
- 不含自制包,所有资源均实时从镜像源获得
- 有很多注释

## 系统要求
Expand Down
11 changes: 6 additions & 5 deletions trans.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,8 @@ EOF
# 此时不能用
# chroot $os_dir timedatectl set-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-resolved
chroot $os_dir systemctl enable sshd
Expand Down Expand Up @@ -2260,9 +2262,8 @@ clear_machine_id() {
os_dir=$1

# https://www.freedesktop.org/software/systemd/man/latest/machine-id.html
if [ -f $os_dir/etc/machine-id ]; then
echo uninitialized >$os_dir/etc/machine-id
fi
# gentoo 不会自动创建该文件
echo uninitialized >$os_dir/etc/machine-id

# 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
Expand Down Expand Up @@ -2540,7 +2541,7 @@ EOF

download_cloud_init_config $os_dir

# clear_machine_id $os_dir
clear_machine_id $os_dir

# el/ol/fedora/国产fork
# 1. 禁用 selinux kdump
Expand Down Expand Up @@ -3307,7 +3308,7 @@ install_qcow_by_copy() {
disable_selinux_kdump /os

# centos7 删除 machine-id 后不会自动重建
# clear_machine_id /os
clear_machine_id /os

# el7 yum 可能会使用 ipv6,即使没有 ipv6 网络
if [ "$releasever" = 7 ]; then
Expand Down

0 comments on commit 5e9cc84

Please sign in to comment.