debootstrap、squashfs、および grub を含むライブ Debian USB スティック

debootstrap、squashfs、および grub を含むライブ Debian USB スティック

私はchroot(debootstrap)環境で独自のDebian Liveブートスティックを作成したいと思います。

ルートファイルシステムはsquashfsとしてマウントする必要があり、grubは単一のEFIパーティションからシステムを起動できる必要があります。

これまで、USBスティックにchroot環境であるvmlinuzとinitrd.imgのsquashfsイメージがあります。しかし、ローカルシステムを起動せずに(grub-install ...を試してください)、代わりにUSBスティックのsquashfsを起動するようにgrubを設定する方法がわかりません。

ベストアンサー1

問題を解決しました!

まず、chroot環境にはshquashfsイメージをロードするために必要なinitframeが必要です。これを行うには、chrootにライブブートパッケージをインストールし、initframeを更新しました。正しく機能するには、chrootで/proc、/dev/pts、/dev、/sysを使用できる必要があります。

# @ root on localhost
mount -o bind /proc /debootstrap/proc
mount -o bind /dev /debootstrap/dev
mount -o bind /dev/pts /debootstrap/dev/pts
mount -o bind /sys /debootstrap/sys
# @ root in chroot
apt install live-boot live-boot-initramfs-tools
update-initramfs -u

完了したら、これらのディレクトリをアンマウントする必要があり、shquashfsを/target/live/filesystem.squashfsに作成できます。

# @ root on localhost
umount /debootstrap/proc
umount /debootstrap/dev
umount /debootstrap/dev/pts
umount /debootstrap/sys
# @ root on localhost
mksquashfs -comp xz /debootstrap /target/live/filesystem.squashfs

USBドライブをfat32でフォーマットし、/targetにマウントしました。これでGrubをインストールする準備が整いました。

# @ root on localhost
grub-install --target=x86_64-efi --root-directory=/target

完了したら、vmlinuzとinitrd.imgを/target/bootにコピーし、/target/boot/grub/grub.cfgに次の内容でgrub.cfgを作成します。

insmod all_video

set default=0
set timeout=0

menuentry "debian live" {
    linux /boot/vmlinuz boot=live toram=filesystem.squashfs quiet
    initrd /boot/initrd.img
}

これで、コンピュータがこのスティックをEFI起動できるようになります。

おすすめ記事