7 linux boot arch-linux keyboard grub2
前几天,当它的键盘开始起作用时,我正在使用笔记本电脑作为一般台式机使用。键盘右侧的大多数键完全停止工作,Ctrlu出现不应该出现的组合字符,例如组合字符。退格键表现出最奇怪的行为;它以某种方式能够导致 shell 提示中的删除字符。
我无法干净地重新启动计算机,因此我进行了硬关机。当我再次打开电脑时,我收到了 Grub 发来的这条消息:
GRUB loading.
Welcome to GRUB!
incompatible license
Aborted. Press any key to exit.
Run Code Online (Sandbox Code Playgroud)
我按下了任意键,Grub 回复了
Operating System Not Found.
Run Code Online (Sandbox Code Playgroud)
按另一个键会使第一条消息再次出现。之后再按另一个键会导致出现第二条消息……依此类推。
如果我将笔记本电脑打开几分钟,它的风扇会显着加速,就像笔记本电脑正在运行 CPU 密集型程序一样。
我从笔记本电脑中取出硬盘,将其安装在服务器上,然后环顾四周。我在/boot.
笔记本电脑正在运行 Arch Linux。该驱动器使用 GPT 进行分区。笔记本电脑与另一台机器的硬盘驱动器一起工作正常。而其他机器不支持笔记本电脑的硬盘。
我不确定键盘问题是否与 Grub 问题直接相关。
什么可能导致我遇到的问题?或者,我应该怎么做才能找出或缩小潜在原因的范围?
万一这是相关的,这里(删除)是一个压缩包/boot,并/etc/grub.d在这里是我的GRUB的配置:
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
load_env
fi
set default="0"
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi
export menuentry_id_option
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi
function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}
if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
insmod part_gpt
insmod ext2
set root='hd0,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 d44f2a2f-c369-456b-81f1-efa13f9caae2
else
search --no-floppy --fs-uuid --set=root d44f2a2f-c369-456b-81f1-efa13f9caae2
fi
font="/usr/share/grub/unicode.pf2"
fi
if loadfont $font ; then
set gfxmode=auto
load_video
insmod gfxterm
set locale_dir=$prefix/locale
set lang=en_US
insmod gettext
fi
terminal_input console
terminal_output gfxterm
set timeout=5
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch GNU/Linux, with Linux PARA kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-PARA kernel-true-d44f2a2f-c369-456b-81f1-efa13f9caae2' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd1,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt1 --hint-efi=hd1,gpt1 --hint-baremetal=ahci1,gpt1 b4fbf4f8-303c-49bd-a52f-6049e1623a26
else
search --no-floppy --fs-uuid --set=root b4fbf4f8-303c-49bd-a52f-6049e1623a26
fi
echo 'Loading Linux PARA kernel ...'
linux /boot/vmlinuz-linux-PARA root=UUID=d44f2a2f-c369-456b-81f1-efa13f9caae2 ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-linux-PARA.img
}
menuentry 'Arch GNU/Linux, with Linux core repo kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-true-d44f2a2f-c369-456b-81f1-efa13f9caae2' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd1,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt1 --hint-efi=hd1,gpt1 --hint-baremetal=ahci1,gpt1 b4fbf4f8-303c-49bd-a52f-6049e1623a26
else
search --no-floppy --fs-uuid --set=root b4fbf4f8-303c-49bd-a52f-6049e1623a26
fi
echo 'Loading Linux core repo kernel ...'
linux /boot/vmlinuz-linux root=UUID=d44f2a2f-c369-456b-81f1-efa13f9caae2 ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-linux.img
}
menuentry 'Arch GNU/Linux, with Linux core repo kernel (Fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-core repo kernel-fallback-d44f2a2f-c369-456b-81f1-efa13f9caae2' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set root='hd1,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt1 --hint-efi=hd1,gpt1 --hint-baremetal=ahci1,gpt1 b4fbf4f8-303c-49bd-a52f-6049e1623a26
else
search --no-floppy --fs-uuid --set=root b4fbf4f8-303c-49bd-a52f-6049e1623a26
fi
echo 'Loading Linux core repo kernel ...'
linux /boot/vmlinuz-linux root=UUID=d44f2a2f-c369-456b-81f1-efa13f9caae2 ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initramfs-linux-fallback.img
}
### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" --class memtest86 --class gnu --class tool {
insmod part_gpt
insmod ext2
set root='hd1,gpt1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt1 --hint-efi=hd1,gpt1 --hint-baremetal=ahci1,gpt1 b4fbf4f8-303c-49bd-a52f-6049e1623a26
else
search --no-floppy --fs-uuid --set=root b4fbf4f8-303c-49bd-a52f-6049e1623a26
fi
linux16 ($root)/boot/memtest86+/memtest.bin
}
### END /etc/grub.d/20_memtest86+ ###
### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
Run Code Online (Sandbox Code Playgroud)
更新
昨晚安装 LILO 后,计算机至少启动了一次。当我今天早上启动计算机时,我遇到了内核恐慌:
Initramfs unpacking failed: junk in compressed archive
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,1)
Pid: 1, comm: swapper/0 Not tainted 3.8.7-1-ARCH #1
Call Trace:
...
Run Code Online (Sandbox Code Playgroud)
这是内核恐慌的图片。
更新 2
我重新安装了 LILO 并且在启动时不再收到内核恐慌。
更新2:
忘了你贴了焦油球。太糟糕了。无论如何,.mod使用以下代码对您的文件进行了测试:
./grum_lic_test32 evan_teitelman/boot/grub/i386-pc/*.mod
Run Code Online (Sandbox Code Playgroud)
这产生了以下错误:
...
bufio.mod License: LICENSE=GPLv3+ OK
cacheinfo.mod License: LICENSE=NONE_FOUND ERR
cat.mod License: LICENSE=GPLv3+ OK
chain.mod License: LICENSE=GPLv3+ OK
...
Run Code Online (Sandbox Code Playgroud)
但该文件与 Archlinux 下载的文件相同,因此应该不是问题。换句话说,不是原因。
另外,首先,请注意您已经安装了 LILO,并且猜测此案例已关闭。如果不是,总是有关于 GPT 和 BIOS + 其他问题的问题。你是第一次安装吗?可能是第一次安装时涉及一些调整,重新安装 GRUB 没有修复。
更新1:好的。固定的。应该适用于 32 和 64 位ELF的。
当GRUB到达加载模块的阶段时,它会检查ELF每个模块的文件中嵌入的许可证。如果发现无效,则忽略该模块 - 并打印该特定错误。可能是一个或多个模块损坏。
如果它是一个必不可少的模块,一切都会变糟。说例如part_gpt.mod
或part_msdos.mod。
接受的许可证是GPLv2+、GPLv3和GPLv3+。
当然也可能是其他原因;但其中之一可能是损坏的模块文件。
看起来这些模块是有效的ELF文件,因为它们在许可证测试之前已经过验证。如:如果ELF测试失败,则不执行许可证测试。
模块存在另一个问题,我需要检查各种模块,提取了部分代码并将其制成快速许可证测试器。您可以测试每个*.mod文件/boot/grub/*以查看哪些文件已损坏。
此代码不验证ELF或其他任何内容。只尝试找到许可证字符串并检查它。此外,它仅在 i386/32 位下测试。提取它的原始代码也适用于 x86-64 - 但这里有很多被剥离和黑客攻击,所以我不确定结果。如果它在 64 位下不起作用,它很可能只打印License: LICENSE=NONE_FOUND.
(正如上面的编辑所指出的,我现在已经测试了 32 位和 64 位,英特尔。)
作为单独的测试,然后将执行以下操作:
xxd file.mod | grep -C1 LIC
Run Code Online (Sandbox Code Playgroud)
不是最漂亮的代码——而是快速而肮脏的检查。
(如;你可以试试。)
编译指令例如:
gcc -o grub_lic_test32 source.c # 32-bit variant
gcc -o grub_lic_test64 source.c -DELF64 # 64-bit variant
Run Code Online (Sandbox Code Playgroud)
跑:
./grub_lic_test32 /path/to/mods/*.mod
Run Code Online (Sandbox Code Playgroud)
打印每个文件和许可证,例如:
./grub_lic_test32 tar.mod gettext.mod pxe.mod
tar.mod License: LICENSE=GPLv1+ BAD
gettext.mod License: LICENSE=GPLv3+ OK
pxe.mod License: LICENSE=GPLv3+ OK
Run Code Online (Sandbox Code Playgroud)
代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#ifdef ELF64
struct ELF_hdr
{
unsigned char dummy0[16];
uint32_t dummy1[6];
uint64_t sh_off;
uint16_t dummy2[5];
uint16_t sh_entsize;
uint16_t sh_num;
uint16_t sh_strndx;
};
struct ELF_sect_hdr
{
uint32_t sh_name;
uint32_t dummy0[5];
uint64_t sh_offset;
};
#else
struct ELF_hdr
{
unsigned char dummy0[16];
uint32_t dummy1[4];
uint32_t sh_off;
uint16_t dummy2[5];
uint16_t sh_entsize;
uint16_t sh_num;
uint16_t sh_strndx;
};
struct ELF_sect_hdr
{
uint32_t sh_name;
uint32_t dummy[3];
uint32_t sh_offset;
};
#endif
enum {
ERR_FILE_OPEN = 1,
ERR_FILE_READ,
ERR_MEM,
ERR_BAD_LICENSE,
ERR_ELF_SECT_CORE_BREACH
};
int file_size(FILE *fh, size_t *fs)
{
size_t cp;
cp = ftell(fh);
fseek(fh, 0, SEEK_END);
*fs = ftell(fh);
fseek(fh, cp, SEEK_SET);
return 0;
}
static const char *valid_licenses[] = {
"LICENSE=GPLv2+",
"LICENSE=GPLv3",
"LICENSE=GPLv3+",
NULL
};
int grub_check_license(struct ELF_hdr *e)
{
struct ELF_sect_hdr *s;
const char *txt;
const char *lic;
unsigned i, j = 0;
s = (struct ELF_sect_hdr *)
((char *) e + e->sh_off + e->sh_strndx * e->sh_entsize);
txt = (char *) e + s->sh_offset;
s = (struct ELF_sect_hdr *) ((char *) e + e->sh_off);
for (i = 0; i < e->sh_num; ++i) {
if (strcmp (txt + s->sh_name, ".module_license") == 0) {
lic = (char*) e + s->sh_offset;
if (j)
fprintf(stdout, "%25s", "");
fprintf(stdout, "License: %-25s ", lic);
for (j = 0; valid_licenses[j]; ++j) {
if (!strcmp (lic, valid_licenses[j])) {
fprintf(stdout, "OK\n");
return 0;
}
}
fprintf(stdout, "BAD\n");
}
s = (struct ELF_sect_hdr *) ((char *) s + e->sh_entsize);
}
if (!j)
fprintf(stdout, "License: %-25s ERR\n", "LICENSE=NONE_FOUND");
return ERR_BAD_LICENSE;
}
int grub_check_module(void *buf, size_t size, int verbose)
{
struct ELF_hdr *e = buf;
/* Make sure that every section is within the core. */
if (e->sh_off + e->sh_entsize * e->sh_num > size) {
fprintf(stderr, "ERR: Sections outside core\n");
if (verbose)
fprintf(stderr,
" %*s: %u bytes\n"
#ifdef ELF64
" %*s %u < %llu\n"
" %*s: %llu\n"
#else
" %*s %u < %u\n"
" %*s: %u\n"
#endif
" %*s: %u\n"
" %*s: %u\n"
,
-25, "file-size", size,
-25, "",
size, e->sh_off + e->sh_entsize * e->sh_num,
-25, "sector header offset", e->sh_off,
-25, "sector header entry size", e->sh_entsize,
-25, "sector header num", e->sh_num
);
return ERR_ELF_SECT_CORE_BREACH;
}
return grub_check_license(e);
}
int grub_check_module_file(const char *fn, int verbose)
{
FILE *fh;
void *buf;
size_t fs;
int eno;
char *base_fn;
if (!(base_fn = strrchr(fn, '/')))
base_fn = (char*)fn;
else
++base_fn;
fprintf(stderr, "%-25s ", base_fn);
if (!(fh = fopen(fn, "rb"))) {
fprintf(stderr, "ERR: Unable to open `%s'\n", fn);
perror("fopen");
return ERR_FILE_OPEN;
}
file_size(fh, &fs);
if (!(buf = malloc(fs))) {
fprintf(stderr, "ERR: Memory.\n");
fclose(fh);
return ERR_MEM;
}
if (fread(buf, 1, fs, fh) != fs) {
fprintf(stderr, "ERR: Reading `%s'\n", fn);
perror("fread");
free(buf);
fclose(fh);
return ERR_FILE_READ;
}
fclose(fh);
eno = grub_check_module(buf, fs, verbose);
free(buf);
return eno;
}
int main(int argc, char *argv[])
{
int i = 1;
int eno = 0;
int verbose = 0;
if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'v') {
verbose = 1;
++i;
}
if (argc - i < 1) {
fprintf(stderr, "Usage: %s [-v] <FILE>[, FILE[, ...]]\n", argv[0]);
return 1;
}
for (; i < argc; ++i) {
eno |= grub_check_module_file(argv[i], verbose);
if (eno == ERR_MEM)
return eno;
}
return eno;
}
Run Code Online (Sandbox Code Playgroud)