我正在尝试在 Ubuntu Server 上安装新内核,但由于“gzip: stdout: no space left on device”错误而无法完成它。运行后产生完整错误sudo make modules_install install
:
INSTALL /lib/firmware/cpia2/stv0672_vp4.bin
INSTALL /lib/firmware/yam/1200.bin
INSTALL /lib/firmware/yam/9600.bin
DEPMOD 3.16.0
sh ./arch/x86/boot/install.sh 3.16.0 arch/x86/boot/bzImage \
System.map "/boot"
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.16.0 /boot/vmlinuz-3.16.0
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.16.0 /boot/vmlinuz-3.16.0
update-initramfs: Generating /boot/initrd.img-3.16.0
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.16.0 with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
make[1]: *** [install] Error 1
make: *** [install] Error 2
我使用 df -h 检查了磁盘空间,这是输出:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/server--vg-root 103G 33G 66G 34% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 63G 4.0K 63G 1% /dev
tmpfs 13G 1.8M 13G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 63G 148K 63G 1% /run/shm
none 100M 24K 100M 1% /run/user
/dev/sda1 236M 62M 162M 28% /boot
/home/stan/.Private 103G 33G 66G 34% /home/stan
我不明白为什么在给定空间量的情况下会产生此错误。我已经在 Debian 和 OpenSUSE 上成功地使用了完全相同的过程。
答案1
“make module_install install”尝试在 /boot 分区上构建 initrd 映像,该分区有 162 MB 可用空间,这根本不够。
如果你想在Ubuntu上自己编译内核,你需要在/boot分区上准备至少1GB的可用空间。
答案2
/boot
当分区上没有太多剩余空间时会发生这种情况。解决方案是卸载旧内核并释放空间。
您可以获得当前安装的内核的列表
[I] ~ ❯❯❯ dpkg -l | grep linux-image
rc linux-image-4.19.0-6-amd64 4.19.67-2+deb10u1 amd64 Linux 4.19 for 64-bit PCs (signed)
rc linux-image-5.10.0-2-amd64 5.10.9-1 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-image-5.10.0-5-amd64 5.10.24-1 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-image-5.10.0-6-amd64 5.10.28-1 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-image-5.14.0-1-amd64 5.14.6-3 amd64 Linux 5.14 for 64-bit PCs (signed)
rc linux-image-5.14.0-2-amd64 5.14.9-2 amd64 Linux 5.14 for 64-bit PCs (signed)
rc linux-image-5.14.0-3-amd64 5.14.12-1 amd64 Linux 5.14 for 64-bit PCs (signed)
rc linux-image-5.14.0-4-amd64 5.14.16-1 amd64 Linux 5.14 for 64-bit PCs (signed)
ic linux-image-5.15.0-2-amd64 5.15.5-2 amd64 Linux 5.15 for 64-bit PCs (signed)
rc linux-image-5.15.0-3-amd64 5.15.15-2 amd64 Linux 5.15 for 64-bit PCs (signed)
rc linux-image-5.16.0-3-amd64 5.16.11-1 amd64 Linux 5.16 for 64-bit PCs (signed)
rc linux-image-5.17.0-1-amd64 5.17.3-1 amd64 Linux 5.17 for 64-bit PCs (signed)
ii linux-image-5.18.0-4-amd64 5.18.16-1 amd64 Linux 5.18 for 64-bit PCs (signed)
ii linux-image-5.19.0-2-amd64 5.19.11-1 amd64 Linux 5.19 for 64-bit PCs (signed)
rc linux-image-5.2.0-3-amd64 5.2.17-1 amd64 Linux 5.2 for 64-bit PCs (signed)
rc linux-image-5.3.0-2-amd64 5.3.9-3 amd64 Linux 5.3 for 64-bit PCs (signed)
rc linux-image-5.3.0-3-amd64 5.3.15-1 amd64 Linux 5.3 for 64-bit PCs (signed)
rc linux-image-5.4.0-1-amd64 5.4.6-1 amd64 Linux 5.4 for 64-bit PCs (signed)
rc linux-image-5.4.0-2-amd64 5.4.8-1 amd64 Linux 5.4 for 64-bit PCs (signed)
rc linux-image-5.4.0-3-amd64 5.4.13-1 amd64 Linux 5.4 for 64-bit PCs (signed)
rc linux-image-5.4.0-4-amd64 5.4.19-1 amd64 Linux 5.4 for 64-bit PCs (signed)
rc linux-image-5.5.0-2-amd64 5.5.17-1 amd64 Linux 5.5 for 64-bit PCs (signed)
rc linux-image-5.6.0-1-amd64 5.6.7-1 amd64 Linux 5.6 for 64-bit PCs (signed)
rc linux-image-5.6.0-2-amd64 5.6.14-2 amd64 Linux 5.6 for 64-bit PCs (signed)
rc linux-image-5.8.0-1-amd64 5.8.7-1 amd64 Linux 5.8 for 64-bit PCs (signed)
rc linux-image-5.8.0-2-amd64 5.8.10-1 amd64 Linux 5.8 for 64-bit PCs (signed)
rc linux-image-5.8.0-3-amd64 5.8.14-1 amd64 Linux 5.8 for 64-bit PCs (signed)
rc linux-image-5.9.0-1-amd64 5.9.1-1 amd64 Linux 5.9 for 64-bit PCs (signed)
rc linux-image-5.9.0-2-amd64 5.9.6-1 amd64 Linux 5.9 for 64-bit PCs (signed)
rc linux-image-5.9.0-4-amd64 5.9.11-1 amd64 Linux 5.9 for 64-bit PCs (signed)
ii linux-image-amd64 5.19.11-1 amd64 Linux for 64-bit PCs (meta-package)
然后获取当前内核版本的版本
[I] ~ ❯❯❯ uname -r
5.19.0-2-amd64
现在您需要通过简单地使用 清除软件包名称来安装旧内核sudo apt purge <package-name>
。如果有很多软件包需要卸载,您可以使用一些 bash 魔法。
sudo apt purge linux-image-5.{2,3,4,5,6,8,9,18}*
请注意,该模式不应与您正在运行的当前内核版本匹配。
删除旧内核后,您将能够释放大量空间/boot
。
一旦有足够的可用空间,您现在可以继续安装更新的内核