You are not logged in.

#1 2024-09-22 14:09:14

Afmer
Member
Registered: 2023-09-21
Posts: 28

[SOLV]Adding a second configuration to grub grub_cmdline_linux_default

Good day to all. I am setting up vfio on my PC so that I can forward a video card. Consequently, after enabling this configuration, my video card does not work. I would like to add a separate configuration at startup in grub, where the vfio driver will be enabled, and where this driver will be disabled. On the Internet, I found that /etc/grub.d/40_custom can be used for these purposes. But the problem is that my root volume is encrypted and I do not know how to correctly specify the configuration, how to use this volume. Please tell me what I should do?

/etc/grub.d/40_custom

menuentry 'Linux-zen without VFIO' {
    cryptdevice=UUID=aa6c90f0-aa6d-40f0-bae5-8d0d3a81eb81:cryptroot:allow-discards
    linux /boot/vmlinuz-linux-zen root=/dev/mapper/cryptroot cryptkey=rootfs:/root/secrets/crypto_keyfile.bin nvidia_drm.modeset=1 quiet
    initrd /boot/initramfs-linux-zen.img
}

/etc/fstab

# /dev/mapper/cryptroot LABEL=cryptroot
UUID=1eea2ab2-4a25-4133-8fae-9c733065fc86 / btrfs rw,noatime,compress=lzo,ssd,space_cache=v2,subvolid=256,subvol=/@ 0 0

# /dev/mapper/cryptroot LABEL=cryptroot
UUID=1eea2ab2-4a25-4133-8fae-9c733065fc86 /home btrfs rw,noatime,compress=lzo,ssd,space_cache=v2,subvol=/@home 0 0

# /dev/mapper/cryptroot LABEL=cryptroot
UUID=1eea2ab2-4a25-4133-8fae-9c733065fc86 /.snapshots btrfs rw,noatime,compress=lzo,ssd,space_cache=v2,subvol=/@snapshots 0 0 

# /dev/mapper/cryptroot LABEL=cryptroot
UUID=1eea2ab2-4a25-4133-8fae-9c733065fc86 /swap btrfs   relatime,discard,autodefrag,compress=zstd:9,subvol=@swap    0 0

# swapfile
/swap/swapfile                              none    swap    sw

# /dev/nvme1n1p3
UUID=16D1-1B6C /boot/efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
/dev/mapper/bitlocker1	/media/mount/bitlocker1	ntfs3	uid=1000,gid=1000,dmask=027,fmask=137,noacl	0 0
/dev/mapper/bitlocker2  /media/mount/bitlocker2 ntfs3   uid=1000,gid=1000,dmask=027,fmask=137,noacl	0 0

/etc/default/grub

# GRUB boot loader configuration

GRUB_DEFAULT=0
GRUB_TIMEOUT=15
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="amd_iommu=on loglevel=3 quiet iommu=pt vfio-pci.ids=10de:1f02,10de:10f9,10de:1ada,10de:1adb"
GRUB_CMDLINE_LINUX="cryptdevice=UUID=aa6c90f0-aa6d-40f0-bae5-8d0d3a81eb81:cryptroot:allow-discards root=/dev/mapper/cryptroot cryptkey=rootfs:/root/secrets/crypto_keyfile.bin nvidia_drm.modeset=1"

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable booting from LUKS encrypted devices
GRUB_ENABLE_CRYPTODISK=y

# Set to 'countdown' or 'hidden' to change timeout behavior,
# press ESC key to display menu.
GRUB_TIMEOUT_STYLE=menu

# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `videoinfo'
GRUB_GFXMODE=auto

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true

# Uncomment and set to the desired menu colors.  Used by normal and wallpaper
# modes only.  Entries specified as foreground/background.
#GRUB_COLOR_NORMAL="light-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/path/to/wallpaper"
#GRUB_THEME="/path/to/gfxtheme"

# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

# Uncomment to make GRUB remember the last selection. This requires
# setting 'GRUB_DEFAULT=saved' above.
#GRUB_SAVEDEFAULT=true

# Uncomment to disable submenus in boot menu
#GRUB_DISABLE_SUBMENU=y

# Probing for other operating systems is disabled for security reasons. Read
# documentation on GRUB_DISABLE_OS_PROBER, if still want to enable this
# functionality install os-prober and uncomment to detect and include other
# operating systems.
GRUB_DISABLE_OS_PROBER=false

Last edited by Afmer (2025-06-30 10:54:39)

Offline

#2 2024-09-22 14:30:47

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLV]Adding a second configuration to grub grub_cmdline_linux_default

Check the auto-generated menuentries to see how the root device is set there but I think that "cryptdevice" line belongs on the "linux" line (in the options) with the first line in the menuentry being used to set the root partition.

I don't use encryption myself so I'm not sure how the menuentries should look (sorry).


Jin, Jîyan, Azadî

Offline

Board footer

Powered by FluxBB