forked from GengWei1997/kernel-deb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathghproxy-Update-kernel.sh
More file actions
95 lines (79 loc) · 2.66 KB
/
ghproxy-Update-kernel.sh
File metadata and controls
95 lines (79 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
echo "=== 开始更新内核 ==="
echo "1. 切换到/tmp工作目录"
cd /tmp
if [ $? -ne 0 ]; then
echo "错误:无法进入/tmp目录"
exit 1
fi
echo "2. 下载linux-xiaomi内核包"
wget https://ghfast.top/https://github.com/GengWei1997/kernel-deb/releases/download/v6.18/linux-xiaomi-raphael.deb
if [ $? -ne 0 ]; then
echo "错误:内核包下载失败"
exit 1
fi
echo "3. 显示当前已安装的Linux相关软件包"
dpkg --get-selections | grep linux
echo "4. 查找并卸载所有linux-xiaomi内核包"
echo " 正在查找linux-xiaomi相关包..."
dpkg -l | grep -E "linux-xiaomi" | awk '{print $2}' | xargs dpkg -P
echo "5. 清理/lib/modules目录(删除所有内核模块)"
rm -rf /lib/modules/*
echo "6. 安装新的linux-xiaomi内核包"
if [ -f "linux-xiaomi-raphael.deb" ]; then
dpkg -i linux-xiaomi-raphael.deb
if [ $? -ne 0 ]; then
echo "错误:内核包安装失败"
exit 1
fi
else
echo "错误:找不到linux-xiaomi-raphael.deb文件"
exit 1
fi
echo "7. 显示安装后的Linux相关软件包"
dpkg --get-selections | grep linux
echo "8. 为所有内核生成initramfs镜像"
update-initramfs -c -k all
if [ $? -ne 0 ]; then
echo "警告:initramfs更新可能存在问题"
fi
echo "9. 清理旧的启动文件"
rm -f /boot/initramfs
rm -f /boot/linux.efi
echo "10. 重命名启动文件"
echo " 将最新的initrd.img移动到/boot/initramfs"
latest_initrd=$(ls -t /boot/initrd.img-* 2>/dev/null | head -1)
if [ -n "$latest_initrd" ]; then
mv "$latest_initrd" /boot/initramfs
echo " 已移动: $latest_initrd -> /boot/initramfs"
else
echo " 警告:未找到initrd.img-*文件"
fi
echo " 将最新的vmlinuz移动到/boot/linux.efi"
latest_vmlinuz=$(ls -t /boot/vmlinuz-* 2>/dev/null | head -1)
if [ -n "$latest_vmlinuz" ]; then
mv "$latest_vmlinuz" /boot/linux.efi
echo " 已移动: $latest_vmlinuz -> /boot/linux.efi"
else
echo " 警告:未找到vmlinuz-*文件"
fi
echo "11. 显示/boot目录内容"
ls -la /boot
echo "=== 验证启动文件 ==="
if [ -f "/boot/initramfs" ] && [ -f "/boot/linux.efi" ]; then
echo "✓ 验证成功:"
echo " - /boot/initramfs 文件存在"
echo " - /boot/linux.efi 文件存在"
echo ""
echo "文件详细信息:"
ls -lh /boot/initramfs /boot/linux.efi
else
echo "✗ 验证失败:"
[ -f "/boot/initramfs" ] || echo " - /boot/initramfs 文件缺失"
[ -f "/boot/linux.efi" ] || echo " - /boot/linux.efi 文件缺失"
echo ""
echo "请检查上述步骤是否有错误"
fi
echo "12. 清理下载的内核包"
rm -f linux-xiaomi-raphael.deb
echo "=== 脚本执行完成 ==="