update
This commit is contained in:
@@ -72,7 +72,6 @@ cleanup() {
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
# --- Nested Partition Logic ---
|
||||
OUTER_MOUNT_POINT=""
|
||||
handle_nested_partition() {
|
||||
local uuid="$1"
|
||||
@@ -89,14 +88,20 @@ handle_nested_partition() {
|
||||
|
||||
echo "[INFO] Found outer device: $outer_device" >&2
|
||||
|
||||
# Create a temporary mount point for the outer partition
|
||||
OUTER_MOUNT_POINT=$(mktemp -d -t luks_outer_XXXXXX)
|
||||
# Check if already mounted
|
||||
if findmnt -n "$outer_device" >/dev/null; then
|
||||
echo "[INFO] Outer device is already mounted." >&2
|
||||
OUTER_MOUNT_POINT=$(findmnt -n -o TARGET "$outer_device")
|
||||
else
|
||||
# Create a temporary mount point for the outer partition
|
||||
OUTER_MOUNT_POINT=$(mktemp -d -t luks_outer_XXXXXX)
|
||||
|
||||
echo "[INFO] Mounting outer device to $OUTER_MOUNT_POINT..." >&2
|
||||
if ! sudo mount "$outer_device" "$OUTER_MOUNT_POINT"; then
|
||||
echo "[ERROR] Failed to mount outer device." >&2
|
||||
rmdir "$OUTER_MOUNT_POINT"
|
||||
exit 1
|
||||
echo "[INFO] Mounting outer device to $OUTER_MOUNT_POINT..." >&2
|
||||
if ! sudo mount "$outer_device" "$OUTER_MOUNT_POINT"; then
|
||||
echo "[ERROR] Failed to mount outer device." >&2
|
||||
rmdir "$OUTER_MOUNT_POINT"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local luks_image="$OUTER_MOUNT_POINT/$NESTED_path"
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
[[ "$XDG_CURRENT_DESKTOP" != "niri" ]] && exit 1
|
||||
# [[ "$XDG_CURRENT_DESKTOP" != "niri" ]] && exit 1
|
||||
|
||||
# if grep -q 'prefer_order=(nvidia intel)' "$HOME/.local/snippets/set_display"; then
|
||||
if grep -q '[^[:space:]]' "$HOME/.config/niri/config/prime.kdl"; then
|
||||
# sed -i 's/prefer_order=(nvidia intel)/prefer_order=(intel nvidia)/' "$HOME/.local/snippets/set_display"
|
||||
sed -i -E 's/prefer_order=\([^)]*\)/prefer_order=(intel nvidia)/' "$HOME/.local/snippets/set_display"
|
||||
echo "" >"$HOME/.config/niri/config/prime.kdl"
|
||||
echo "Disabled global Nvidia Prime offloading."
|
||||
else
|
||||
# sed -i 's/prefer_order=(intel nvidia)/prefer_order=(nvidia intel)/' "$HOME/.local/snippets/set_display"
|
||||
sed -i -E 's/prefer_order=\([^)]*\)/prefer_order=(nvidia intel)/' "$HOME/.local/snippets/set_display"
|
||||
cat >"$HOME/.config/niri/config/prime.kdl" <<EOF
|
||||
environment {
|
||||
__NV_PRIME_RENDER_OFFLOAD "1"
|
||||
@@ -23,8 +23,10 @@ fi
|
||||
|
||||
# Restart session
|
||||
|
||||
printf "Session restart is required to apply changes.\nDo it now? (Y/n): "
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ || -z "$answer" ]]; then
|
||||
niri msg action quit
|
||||
if [[ $XDG_CURRENT_DESKTOP == niri ]]; then
|
||||
printf "Session restart is required to apply changes.\nDo it now? (Y/n): "
|
||||
read -r answer
|
||||
if [[ $answer =~ ^[Yy]$ || -z $answer ]]; then
|
||||
niri msg action quit
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Description:
|
||||
# Mount a WSL VHDX file to a specified mount point using guestmount.
|
||||
#
|
||||
# Requirements:
|
||||
# - libguestfs-tools
|
||||
# - sudo privileges
|
||||
#
|
||||
# Memo:
|
||||
# - set `LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1` to show details when guestmount fails.
|
||||
# - A common issue is that the VHDX file has logs that needs to be "replayed".
|
||||
# This can be done using `qemu-img check -r all <VHDX_PATH>`
|
||||
|
||||
|
||||
[ "$(id -u)" -eq 0 ] && {
|
||||
echo "Do not run this script in sudo mode."
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -z "$1" ] && echo "Usage: $0 <VHDX_PATH>" && exit 1
|
||||
|
||||
vhdx_path="$1"
|
||||
|
||||
[ -z "$2" ] && mount_point="/mnt/wsl" || mount_point="$2"
|
||||
|
||||
[ -d "$mount_point" ] || sudo mkdir -p "$mount_point"
|
||||
|
||||
username=$(whoami)
|
||||
|
||||
sudo chown "$username:$username" "$mount_point"
|
||||
|
||||
export LIBGUESTFS_BACKEND=direct
|
||||
|
||||
# replay log
|
||||
# qemu-img check -r all "$VHDX_PATH" || {
|
||||
# echo "Failed to check VHDX file."
|
||||
# exit 1
|
||||
# }
|
||||
|
||||
guestmount --add "$vhdx_path" --inspector --ro "$mount_point" || {
|
||||
echo "Failed to mount VHDX file."
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Successfully mounted $vhdx_path to $mount_point"
|
||||
Reference in New Issue
Block a user