1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

NixOS で /boot/efi がいっぱいになったとき

Posted at

いっぱいになると nixos-rebuild switch すらできない。

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       197M   197M    0 100% /boot/efi

$ sudo nixos-rebuild switch  
building Nix...
building the system configuration...
updating systemd-boot from 250.4 to 250.9
Failed to copy data from "/nix/store/a55d0mc43m0ibl328yxd5dggrr7r4f1h-systemd-250.9/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/efi/EFI/systemd/.#systemd-bootx64.efic86e6ccb08db22c7": No space left on device
Failed to copy data from "/nix/store/a55d0mc43m0ibl328yxd5dggrr7r4f1h-systemd-250.9/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/efi/EFI/BOOT/.#BOOTX64.EFIf823f30d08cc220e": No space left on device
Traceback (most recent call last):
  File "/nix/store/c30xfwqyfbhwq9kxirdis4aqq8vcs2yi-systemd-boot", line 317, in <module>
    main()
  File "/nix/store/c30xfwqyfbhwq9kxirdis4aqq8vcs2yi-systemd-boot", line 266, in main
    subprocess.check_call(["/nix/store/a55d0mc43m0ibl328yxd5dggrr7r4f1h-systemd-250.9/bin/bootctl", "--path=/boot/efi", "update"])
  File "/nix/store/3yn3fb99d9d5br9ghrviwzcvkdxpkmvx-python3-3.9.16/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/nix/store/a55d0mc43m0ibl328yxd5dggrr7r4f1h-systemd-250.9/bin/bootctl', '--path=/boot/efi', 'update']' returned non-zero exit status 1.
warning: error(s) occurred while switching to the new configuration

以下で記述する解決方法はかなりパワープレイでの解決をしています。
これにより発生したいかなる損害について責任を負えません。
後述しますが、実際筆者は少しだけ事故りました。

作業中コマンドの出力等は消し飛ばしたので、全体的に雑な再現です

TL;DR

※筆者はこのコマンドを使っていないので更に注意

find /boot/efi -not -name "*$(uname -r)*" -exec sudo rm -i {} +

原因の特定

$ du -h /boot/efi | sort -rh 
150M	/boot/efi/EFI/nixos

/boot/efi/EFI/nixos というディレクトリが容量を食っているのがわかる。

中身を見るとカーネルのブート関連のなにかっぽいものが入っている。

$ ls -al /boot/efi/EFI/nixos
total 23529
drwxr-xr-x 3 root root     3072  8月 28 21:53 .
drwxr-xr-x 7 root root      512  6月 30  2022 ..
-rwxr-xr-x 1 root root 16011084  8月 28 21:53 b7vi1pd46lmq1gmr0v7v8wj0wgxw5shd-initrd-linux-5.15.85-initrd.efi
drwxr-xr-x 2 root root      512  8月 28 21:53 .extra-files
-rwxr-xr-x 1 root root  8077920  8月 28 21:53 g42zfki362myf6jkdyn060f74r0gcf7z-linux-5.15.85-bzImage.efi
f6jkdyn060f74r0gcf7z-linux-5.15.85-bzImage.efi

# 多分もっとたくさん

こいつらを消せば解消しそう。

解決

/boot/efi/EFI/nixos/*.efi なファイルを消す。
ただし、どう見てもカーネルに関連するため、今使っていそうなものは除外する。

繰り返しになりますが、とても危険な操作をしています。
各コマンドの意味を理解できない場合は実行しないことをおすすめします。

# 今動いているカーネルのバージョンを確認する
$ uname -r
5.15.85

# 動いているもの以外を全部消す
find /boot/efi -not -name "*$(uname -r)*" -exec sudo rm -i {} +

各ファイルを削除するかのプロンプトが出るので、注意深くファイル名を見てから y を打つ。

そして reboot

問題発生

再起動後、なぜかもともとつかっていた X11 ではなく Wayland で起動した。
conifguration.nix に以下を書き加えて switch、再起動したらなおった。

services.xserver.displayManager.gdm.wayland = false;

OS のバージョンが上がったりしたのだろうか。わからんけど治ったからヨシ

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?