The demo was performed on a QEMU virtual machine using BIOS+GPT with Ubuntu 22.04 OS installed.
qemu-system-x86_64 -cpu host -enable-kvm \\
-hda ubuntu.qcow2 -hdb erofs.qcow2 \\
-net user,hostfwd=tcp::10022-:22 -net nic \\
-smp 16 -m 8G
Firstly, let’s compile and install our modified GRUB bootloader.
cd ~/grub-latest
# compile GRUB
./bootstrap
./configure --prefix=~/grub-latest/install --target=x86_64
make -j20
make install
# install GRUB
cd install
sudo ./sbin/grub-install --target=i386-pc /dev/sda
sudo ./sbin/grub-mkconfig -o /boot/grub/grub.cfg
Note that the version number has changed to 2.12-rc1.
Prepare virtual disk for EROFS partition
>sudo fdisk /dev/sdb
Command (m for help): g
Created a new GPT disklabel (GUID: 1FB769D1-08CD-8F45-A651-5F3A8CB16729).
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-20971486, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971486, default 20971486):
Created a new partition 1 of type 'Linux filesystem' and of size 10 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Pack vmlinuz
and initrd
into EROFS partition /dev/sdb
mkdir ~/erofs-src
sudo cp /boot/*5.19.0-45* ~/erofs-src/
>ls ~/erofs-src
config-5.19.0-45-generic initrd.img-5.19.0-45-generic System.map-5.19.0-45-generic vmlinuz-5.19.0-45-generic
sudo mkfs.erofs /dev/sdb1 ~/erofs-src/
Make sure we are doing the correct things…
Add a GRUB custom boot entry, modify ~/grub-latest/install/etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Test" {
linux (hd1,1)/vmlinuz-5.19.0-45-generic root=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ro
initrd (hd1,1)/initrd.img-5.19.0-45-generic
}
update /boot/grub/grub.cfg
sudo ./sbin/grub-mkconfig -o /boot/grub/grub.cfg
Selecting the “Test” entry in GRUB, and we successfully enter the Desktop.