-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(virtiofs): virtiofs root filesystem support
Currently dracut can't mount virtiofs as root filesystem. Make possible to boot virtual machines off virtiofs, passing "root=virtiofs:<mtag>", using the mount tag <mtag> as root filesystem. Alternatively this module also supports "rootfstype=virtiofs root=<mtag>" Signed-off-by: German Maglione <[email protected]>
- Loading branch information
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/bash | ||
|
||
# called by dracut | ||
check() { | ||
[[ $hostonly ]] || [[ $mount_needs ]] && { | ||
is_qemu_virtualized && return 0 | ||
|
||
for fs in "${host_fs_types[@]}"; do | ||
[[ $fs == "virtiofs" ]] && return 0 | ||
done | ||
return 255 | ||
} | ||
|
||
return 0 | ||
} | ||
|
||
# called by dracut | ||
depends() { | ||
return 0 | ||
} | ||
|
||
# called by dracut | ||
installkernel() { | ||
instmods virtiofs | ||
} | ||
|
||
# called by dracut | ||
install() { | ||
inst_hook cmdline 95 "$moddir/parse-virtiofs.sh" | ||
inst_hook pre-mount 99 "$moddir/mount-virtiofs.sh" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/sh | ||
|
||
if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then | ||
if ! { modprobe virtiofs || strstr "$(cat /proc/filesystems)" virtiofs; }; then | ||
die "virtiofs is required but not available." | ||
fi | ||
|
||
mount -t virtiofs -o "$rflags" "${root#virtiofs:}" "$NEWROOT" 2>&1 | vinfo | ||
if ! ismounted "$NEWROOT"; then | ||
die "virtiofs: failed to mount root fs" | ||
exit 1 | ||
fi | ||
|
||
info "virtiofs: root fs mounted (options: '${rflags}')" | ||
|
||
[ -f "$NEWROOT"/forcefsck ] && rm -f -- "$NEWROOT"/forcefsck 2> /dev/null | ||
[ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2> /dev/null | ||
fi | ||
: |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/sh | ||
# Accepted formats: | ||
# rootfstype=virtiofs root=<tag> | ||
# root=virtiofs:<tag> | ||
|
||
if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then | ||
# shellcheck disable=SC2034 | ||
rootok=1 | ||
fi |
This file contains 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