Ubuntu에서 스토리지가 꽉찬 경우
apt update와 apt upgrade를 실행하는 중에 에러가 발생했다.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up linux-firmware (1.173.21) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-120-generic
cryptsetup: WARNING: failed to detect canonical device of /dev/sda4
cryptsetup: WARNING: could not determine root device from /etc/fstab
cryptsetup: WARNING: failed to detect canonical device of /dev/sda5
I: The initramfs will attempt to resume from /dev/sda3
I: (UUID=3b0c78f2-13f9-11e9-945f-00215e70a674)
I: Set the RESUME variable to override this.
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-5.4.0-120-generic with 1.
dpkg: error processing package linux-firmware (--configure):
installed linux-firmware package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
linux-firmware
E: Sub-process /usr/bin/dpkg returned an error code (1)
핵심은 아래의 라인이다.
gzip: stdout: No space left on device
나의 경우에는 원인은 커널 업데이트로 인한 찌꺼기들이 남아있었고, 해당 파티션이 너무 작게 설정된 경우이다.
먼저 파티션의 상태를 알아보려면 아래의 명령어를 입력한다.
df -h // 스토리지 (하드디스크, SSD)
fdisk -l // 파티션
blkid // 파티션 식별번호 (UUID)
cat /etc/fstab // 파티션
udev 3.9G 0 3.9G 0% /dev
...
/dev/sda4 3.9G 3.5G 359M 89% /
/dev/sda2 477M 424M 24M 95% /boot
...
따로 파티션이 할당된 경우라면 사용하지 않는 파티션을 정리하고, 확장시켜서 해결할 수 있다. 하지만 별도 파티션을 할당하지 않았거나, 확장할 수 없는 경우에는 쓸모 없는 파일을 정리해야 한다.
처음에는 루트 디렉토리의 공간이 부족한 줄로 알고, 다른 파일을 지워 800Mb 이상의 빈공간을 마련했지만 소용없었다. 커널 관련 패키지들은 /boot 디렉토리에 설치된다.
그래서
- /boot 디렉토리에 위치한 파일들을 이동시켜 봤다. (System.map-_, config-_, vmlinuz-* 등) => 실패
- 이동 시킨 후 심볼릭 링크로 처리해봤다. => 실패
또 다른 오류들을 확인할 수 있다.
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written beca use the error message indicates its a followup error from a previous failure.
No apport report written because MaxReports is reached alr eady
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.15.0-187-generic
cryptsetup: WARNING: failed to detect canonical device of /dev/sda4
cryptsetup: WARNING: could not determine root device from /etc/fstab
cryptsetup: WARNING: failed to detect canonical device of /dev/sda5
I: The initramfs will attempt to resume from /dev/sda3
I: (UUID=3b0c78f2-13f9-11e9-945f-00215e70a674)
I: Set the RESUME variable to override this.
gzip: stdout: No space left on device
E: mkinitramfs failure find 141 cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.15.0-187-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-4.15.0-187-generic (--configure):
installed linux-image-4.15.0-187-generic package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
Processing triggers for linux-image-5.4.0-120-generic (5.4.0-120.136~18.0 4.1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.4.0-120-generic
cryptsetup: WARNING: failed to detect canonical device of /dev/sda4
cryptsetup: WARNING: could not determine root device from /etc/fstab
cryptsetup: WARNING: failed to detect canonical device of /dev/sda5
I: The initramfs will attempt to resume from /dev/sda3
I: (UUID=3b0c78f2-13f9-11e9-945f-00215e70a674)
I: Set the RESUME variable to override this.
gzip: stdout: No space left on device
E: mkinitramfs failure find 141 cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-5.4.0-120-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-5.4.0-120-generic (--configure):
installed linux-image-5.4.0-120-generic package post-installation script subprocess returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
linux-firmware
linux-image-generic
linux-generic
linux-signed-generic
linux-image-4.15.0-187-generic
linux-image-5.4.0-120-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
이유는 다음과 같다. /boot/initrd.img-5.4.0-89-generic 같은 파일을 지움 => initramfs-tools 디렉토리 (var/lib/initramfs-tools)에는 “d69e1bac37b3737a93da6515d7b80225b2361031 /boot/initrd.img-5.4.0-89-generic” 해시값이 저장되어 있음 => 커널 업데이트 후 linux-firmware에서 post-install 프로세스에서 initramfs-tools을 호출했는데, 해시값이 다르니 스크립트 실행에 실패함
쓸모없는 커널을 지우기 위해서는 initramfs-tools라는 녀석을 써야한다. 참고로 위치는 “/var/lib/initramfs-tools”이다.
man initramfs-tools // 메뉴얼 확인
initramfs-tools --help // 사용법 확인
initramfs-tools를 찾을 수 없다면, 먼저 설치하자.
커널의 삭제는 다음과 같이 할 수 있다. (/boot에서 설치된 커널의 목록을 확인하며 오래된 버전 부터 정리하자)
update-initramfs -d -v -k 5.4.0-89-generic
update-initramfs -d -v -k 5.4.0-90-generic
이제 용량이 넉넉하게 확보된 것을 확인할 수 있다.
apt update && apt upgrade를 실행하면 오류가 났었기 때문에 패키지가 깨졌을 수 있으니 제대로 설치를 진행하자
apt upgrade
apt --fix-broken install
dpkg --configure -a
구글링 했던 자료들
https://askubuntu.com/questions/759802/where-does-update-initramfs-look-for-kernel-versions/761305#761305?newreg=11a4f143a33f4315b14983fa2466182b https://askubuntu.com/questions/827114/what-to-do-about-update-initramfs-errors-during-kernel-upgrade https://ko.wikipedia.org/wiki/Initramfs https://wiki.gentoo.org/wiki/Initramfs/Guide/ko https://bkjeon1614.tistory.com/190 http://blog.engintruder.com/222