Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for root in btrfs subvolume #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ _action_kernels() {
_found_root() {
local _root
_root="$(findmnt -r -n -o SOURCE /)"
_subvol="${_root#*\[}"
_subvol="${_subvol%\]*}"
if [[ "$_root" != "$_subvol" ]]; then
_subvol="${_subvol#\/}"
export SUBVOL="rootflags=subvol=$_subvol"
_root="${_root%\[*}"
else
export SUBVOL=""
fi
if [ "$?" != 0 ] || [ -z "$_root" ]; then
echo "Something went wrong while searching for root" >&2
return 3
Expand Down Expand Up @@ -212,14 +221,14 @@ __get_cmdline() {
if [ "$USE_DEF" == 1 ]; then
if [ "$SUB_ROOT" == 1 ]; then
_found_root
echo "$CMDLINE_DEFAULT root=PARTUUID=$ROOT_DEVICE $_second"
echo "$CMDLINE_DEFAULT root=PARTUUID=$ROOT_DEVICE $SUBVOL $_second"
else
echo "$CMDLINE_DEFAULT $_second"
fi
else
if [ "$SUB_ROOT" == 1 ]; then
_found_root
eval 'echo "root=PARTUUID='$ROOT_DEVICE' ${_second/@def@/'$CMDLINE_DEFAULT'}"'
eval 'echo "root=PARTUUID='$ROOT_DEVICE' $SUBVOL ${_second/@def@/'$CMDLINE_DEFAULT'}"'
else
eval 'echo "${_second/@def@/'$CMDLINE_DEFAULT'}"'
fi
Expand Down