在 AWS (ec2) 上使用 Ubuntu 20.04,我想將我的核心從 AWS 更改為通用核心。當我嘗試按照建議的方式更改 Grub 配置時,它會停止機器。
這是因為 Jibri(Jitsi Video Recorder)需要使用 ALSA 並 modprobe snd-aloop ,但任何需要低延遲或不同內核的東西都會有相同的需求。
我嘗試過的:
抓取影像:
sudo apt install linux-image-extra-virtual
您會在安裝套件中看到它引用類似 Linux 5.4.0-84-generic 的內容,稍後會有所幫助。現在,列出該新通用核心的引導條目
grep -A200 submenu /boot/grub/grub.cfg |grep -P '^(?=.*menuentry)(?=.*generic)'
我懂了:
menuentry 'Ubuntu,使用 Linux 5.4.0-84-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-84-generic-advanced-e8070c31-bfee -4314-a151-d1332dc23486' { menuentry 'Ubuntu,使用Linux 5.4.0-84-generic(恢復模式)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_optiongnulin gnu-linux --class gnu --class os $menuentry_id_optiongnulin .0-84-通用-恢復-e8070c31-bfee-4314-a151-d1332dc23486'{
在可能是最上面的一行中,而不是提到恢復模式的行中,將其選單項目複製到該行的開頭。我的看起來像 Ubuntu,有 Linux 5.4.0-84-generic ,但每個人都會有所不同。
現在,我將編輯/etc/預設/grub,
註解掉 GRUB_DEFAULT=0(載入 grub 引導清單中的第一個項目),並將其變更為我們之前找到的字串。對我來說,文件的這一部分現在看起來像:
#GRUB_DEFAULT=0
GRUB_DEFAULT="Ubuntu, with Linux 5.4.0-84-generic"
這還不是一個正確的設定 - 我們用它來讓 grub 檢查並告訴我們最好的方法。
此時,我們可以 sudo update-grub,這會給我一個像這樣的友好警告(這很好!)
Warning: Please don't use old title `Ubuntu, with Linux 5.4.0-84-generic' for GRUB_DEFAULT, use `Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-84-generic' (for versions before 2.00) or `gnulinux-advanced-e8070c31-bfee-4314-a151-d1332dc23486>gnulinux-5.4.0-84-generic-advanced-e8070c31-bfee-4314-a151-d1332dc23486' (for 2.00 or later)
再說一次,這很好!我們知道我們已經指定了它可以識別的東西。現在每個人都運行高於 2.00 的 grub,因此我們現在再次編輯 /etc/default/grub 並將其更改為最終值:
(我的價值觀與你的不同)
#GRUB_DEFAULT=0
#GRUB_DEFAULT="Ubuntu, with Linux 5.4.0-84-generic"
GRUB_DEFAULT="gnulinux-advanced-e8070c31-bfee-4314-a151-d1332dc23486>gnulinux-5.4.0-84-generic-advanced-e8070c31-bfee-4314-a151-d1332dc23486"
sudo update-grub ,我看到警告現在消失了。
現在我做一個sudo reboot now
此時,grub 已經給了我一個配置,該配置應該嘗試引導通用內核,然後恢復到正常內核。
相反,它陷入了啟動循環。
在串行控制台中,我在啟動循環期間反覆看到這一點。
[ 0.000000] Linux version 5.4.0-84-generic (buildd@lgw01-amd64-050) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021
(Ubuntu 5.4.0-84.94-generic 5.4.133)
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-84-generic root=PARTUUID=5198cbc0-01 ro console=tty1 console=ttyS0 nvme_core.io_timeout=4294967295 panic=-
1
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Hygon HygonGenuine
[ 0.000000] Centaur CentaurHauls
[ 0.000000] zhaoxin Shanghai
... lots of cpu init that's hard to copy ..
[ 10.366218] rtc_cmos 00:00: setting system clock to 2021-09-21T11:25:30 UTC (1632223530)
[ 10.373185] md: Waiting for all devices to be available before autodetect
[ 10.460173] md: If you don't use raid, use raid=noautodetect
[ 10.464642] md: Autodetecting RAID arrays.
[ 10.468024] md: autorun ...
[ 10.470867] md: ... autorun DONE.
[ 10.473906] VFS: Cannot open root device "PARTUUID=5198cbc0-01" or unknown-block(0,0): error -6
[ 10.562806] Please append a correct "root=" boot option; here are the available partitions:
[ 10.569825] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 10.674637] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.4.0-84-generic #94-Ubuntu
[ 10.682527] Hardware name: Amazon EC2 t3.small/, BIOS 1.0 10/16/2017
[ 10.686735] Call Trace:
[ 10.691100] dump_stack+0x6d/0x8b
[ 10.759061] panic+0x101/0x2e3
[ 10.761974] mount_block_root+0x23f/0x2e8
[ 10.765568] mount_root+0x38/0x3a
[ 10.768584] prepare_namespace+0x13f/0x194
[ 10.771873] kernel_init_freeable+0x23f/0x263
[ 10.775368] ? rest_init+0xb0/0xb0
[ 10.859141] kernel_init+0xe/0x110
[ 10.862101] ret_from_fork+0x35/0x40
[ 10.865843] Kernel Offset: 0x36a00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
它告訴我它無法根據它找到啟動設備或partuuid。此時,我幾乎必須終止實例並重試,因為我無法輕鬆恢復它。
有沒有更好的方法將我的核心更改為通用核心?如果它啟動的話,我很樂意在此時以任何可能的方式使用通用圖像。