Fix: Vtoyboot installation in Arch Linux with systemd-based initramfs - #125
Open
ntt998244353 wants to merge 1 commit into
Open
Fix: Vtoyboot installation in Arch Linux with systemd-based initramfs#125ntt998244353 wants to merge 1 commit into
ntt998244353 wants to merge 1 commit into
Conversation
# Ventoy Install Hook Fix
## Solution
### 1. Modified `vtoy.sh` (lines 22-67)
Added copying of systemd-related files during vtoyboot installation:
```bash
print_kernel_param_warning() {
echo ""
echo -e "\033[33m[WARNING] ################################################################## \033[0m"
for i in 0 1 2 3 4 5 6 7 8 9; do
echo -e "\033[33m[WARNING] !!!! Do NOT use root=PARTUUID/PARTLABEL/gpt-auto/dissect !!!! \033[0m"
done
echo -e "\033[33m[WARNING] ################################################################## \033[0m"
echo ""
echo -e "\033[33mVentoy device mapper does NOT expose GPT partition type metadata.\033[0m"
echo -e "\033[33mThe following kernel parameters will FAIL to boot:\033[0m"
echo -e "\033[33m - root=PARTUUID=xxx\033[0m"
echo -e "\033[33m - root=PARTLABEL=xxx\033[0m"
echo -e "\033[33m - root=gpt-auto\033[0m"
echo -e "\033[33m - root=dissect\033[0m"
echo ""
echo -e "\033[32mUse these instead (they work correctly):\033[0m"
echo -e "\033[32m - root=LABEL=xxx (recommended)\033[0m"
echo -e "\033[32m - root=UUID=xxx (recommended)\033[0m"
echo -e "\033[32m - root=/dev/mapper/ventoyN\033[0m"
echo ""
echo -e "\033[33mCheck your bootloader config (systemd-boot, GRUB, etc.) and update\033[0m"
echo -e "\033[33mthe kernel command line accordingly.\033[0m"
echo ""
sleep 5
}
vtoy_clean_env() {
rm -f /sbin/vtoydump /sbin/vtoypartx /sbin/vtoytool /sbin/vtoydrivers
rm -f /usr/lib/initcpio/hooks/ventoy
rm -f /usr/lib/initcpio/install/ventoy
rm -f /usr/lib/initcpio/ventoy-device-mapper
rm -f /usr/lib/systemd/system/ventoy-device-mapper.service
}
vtoy_clean_env
cp -a $vtdumpcmd /sbin/vtoydump
cp -a $partxcmd /sbin/vtoypartx
cp -a $vtoytool /sbin/vtoytool
cp -a ./tools/vtoydrivers /sbin/vtoydrivers
cp -a ./distros/$initrdtool/ventoy-install.sh /usr/lib/initcpio/install/ventoy
cp -a ./distros/$initrdtool/ventoy-hook.sh /usr/lib/initcpio/hooks/ventoy
# Copy systemd-related files if they exist
if [ -f ./distros/$initrdtool/ventoy-device-mapper ]; then
install -Dm755 ./distros/$initrdtool/ventoy-device-mapper /usr/lib/initcpio/ventoy-device-mapper
fi
if [ -f ./distros/$initrdtool/ventoy-device-mapper.service ]; then
install -Dm644 ./distros/$initrdtool/ventoy-device-mapper.service /usr/lib/systemd/system/ventoy-device-mapper.service
fi
# Print warning about kernel parameters
print_kernel_param_warning
echo "updating the initramfs, please wait ..."
```
### 2. Modified `ventoy-install.sh`
Simplified the systemd section since files are now pre-installed by `vtoy.sh`:
```bash
if [ $use_systemd -eq 1 ]; then
# Using systemd - install service unit and executable script
# Add the service unit to initramfs (file should already be in /usr/lib/systemd/system/)
add_systemd_unit "ventoy-device-mapper.service"
# Add the device mapper script with explicit 755 mode to ensure it's executable
add_file "/usr/lib/initcpio/ventoy-device-mapper" "/usr/lib/initcpio/ventoy-device-mapper" "755"
# Enable the service by creating symlink
add_symlink "/usr/lib/systemd/system/initrd.target.wants/ventoy-device-mapper.service" \
"../ventoy-device-mapper.service"
else
# Using traditional busybox/udev initramfs - use runtime hook
add_runscript
fi
```
## File Flow
```
vtoyboot installation (vtoy.sh):
├─ Copy to /sbin/: vtoydump, vtoypartx, vtoytool, vtoydrivers
├─ Copy to /usr/lib/initcpio/install/: ventoy-install.sh
├─ Copy to /usr/lib/initcpio/hooks/: ventoy-hook.sh
├─ Copy to /usr/lib/initcpio/: ventoy-device-mapper (NEW)
└─ Copy to /usr/lib/systemd/system/: ventoy-device-mapper.service (NEW)
mkinitcpio build (ventoy-install.sh):
├─ Detect systemd hook
├─ Call add_systemd_unit "ventoy-device-mapper.service"
│ └─ Reads from /usr/lib/systemd/system/ (already there!)
├─ Call add_file for ventoy-device-mapper
└─ Create symlink for initrd.target.wants
```
## Key Changes Summary
### vtoy.sh
1. ✅ Added cleanup for new systemd files
2. ✅ Added `install -Dm755` for `ventoy-device-mapper` → `/usr/lib/initcpio/`
3. ✅ Added `install -Dm644` for `ventoy-device-mapper.service` → `/usr/lib/systemd/system/`
4. ✅ Added safety check with `if [ -f ... ]`
5. ✅ **Added kernel parameter warning** - alerts users that PARTUUID/PARTLABEL/gpt-auto/dissect will not work
### ventoy-install.sh
1. ✅ Fixed `/sbin/vtoydrivers` error handling with `2>/dev/null`
2. ✅ Simplified systemd section (no need to copy files during build)
3. ✅ Added clear comment explaining files are pre-installed
## Important Limitation
⚠️ **Ventoy device mapper does NOT expose GPT partition type metadata**
This means the following kernel parameters **will FAIL**:
- ❌ `root=PARTUUID=xxx`
- ❌ `root=PARTLABEL=xxx`
- ❌ `root=gpt-auto`
- ❌ `root=dissect`
**Use these instead:**
- ✅ `root=LABEL=xxx` (recommended)
- ✅ `root=UUID=xxx` (recommended)
- ✅ `root=/dev/mapper/ventoyN`
The installation script will display a prominent warning about this limitation.
## Testing
To test the fix in the VM:
1. Transfer the modified vtoyboot directory to VM
2. Run vtoyboot installation:
```bash
cd vtoyboot/vtoyboot/vtoyboot-1.0.36
sudo bash vtoyboot.sh /dev/ventoy2
```
3. Verify files were copied during installation:
```bash
ls -l /usr/lib/initcpio/ventoy-device-mapper
ls -l /usr/lib/systemd/system/ventoy-device-mapper.service
```
4. Check that initramfs was rebuilt and verify contents:
```bash
lsinitcpio /boot/initramfs-linux.img | grep ventoy
```
Expected output:
```
usr/lib/systemd/system/ventoy-device-mapper.service
usr/lib/initcpio/ventoy-device-mapper
usr/lib/systemd/system/initrd.target.wants/ventoy-device-mapper.service
usr/lib/initcpio/hooks/ventoy
```
5. Reboot and test with Ventoy boot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #120, #121, ventoy/Ventoy#3271, ventoy/Ventoy#3503, etc.
This enables Ventoy to boot Arch Linux virtual disks when using
systemd-based initramfs, which is becoming increasingly common.
The fix is fully backward compatible and auto-detects the
initramfs type.
Tested in the minimal Arch Linux install by
archinstall(with systemd-boot), with UEFI boot mode.