summaryrefslogtreecommitdiff
path: root/gnu/bootloader/grub.scm
diff options
context:
space:
mode:
authortiantian <typ22@foxmail.com>2022-09-05 01:25:40 +0800
committerJulien Lepiller <julien@lepiller.eu>2022-09-08 22:30:09 +0200
commit1fc20e4c86697e9d112b9fed8079334c818dd78e (patch)
tree5a92d38a2013216a8059f1e97dc141c6e2ea3b0d /gnu/bootloader/grub.scm
parent52d780ea2b0714d035a84e350b516ca2e2c19af1 (diff)
gnu: bootloader: grub: Add support for chain-loader.
* gnu/bootloader/grub.scm (grub-configuration-file): Add support for chain-loader. Signed-off-by: Julien Lepiller <julien@lepiller.eu>
Diffstat (limited to 'gnu/bootloader/grub.scm')
-rw-r--r--gnu/bootloader/grub.scm73
1 files changed, 43 insertions, 30 deletions
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 4f18c9b5183..72832573547 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -374,44 +374,57 @@ when booting a root file system on a Btrfs subvolume."
374 (let ((label (menu-entry-label entry)) 374 (let ((label (menu-entry-label entry))
375 (linux (menu-entry-linux entry)) 375 (linux (menu-entry-linux entry))
376 (device (menu-entry-device entry)) 376 (device (menu-entry-device entry))
377 (device-mount-point (menu-entry-device-mount-point entry))) 377 (device-mount-point (menu-entry-device-mount-point entry))
378 (if linux 378 (multiboot-kernel (menu-entry-multiboot-kernel entry))
379 (let ((arguments (menu-entry-linux-arguments entry)) 379 (chain-loader (menu-entry-chain-loader entry)))
380 (linux (normalize-file linux 380 (cond
381 device-mount-point 381 (linux
382 store-directory-prefix)) 382 (let ((arguments (menu-entry-linux-arguments entry))
383 (initrd (normalize-file (menu-entry-initrd entry) 383 (linux (normalize-file linux
384 device-mount-point 384 device-mount-point
385 store-directory-prefix))) 385 store-directory-prefix))
386 ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point. 386 (initrd (normalize-file (menu-entry-initrd entry)
387 ;; Use the right file names for LINUX and INITRD in case 387 device-mount-point
388 ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a 388 store-directory-prefix)))
389 ;; separate partition. 389 ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point.
390 390 ;; Use the right file names for LINUX and INITRD in case
391 ;; When BTRFS-SUBVOLUME-FILE-NAME is defined, prepend it the linux and 391 ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a
392 ;; initrd paths, to allow booting from a Btrfs subvolume. 392 ;; separate partition.
393 #~(format port "menuentry ~s { 393
394 ;; When BTRFS-SUBVOLUME-FILE-NAME is defined, prepend it the linux and
395 ;; initrd paths, to allow booting from a Btrfs subvolume.
396 #~(format port "menuentry ~s {
394 ~a 397 ~a
395 linux ~a ~a 398 linux ~a ~a
396 initrd ~a 399 initrd ~a
397}~%" 400}~%"
398 #$label 401 #$label
399 #$(grub-root-search device linux) 402 #$(grub-root-search device linux)
400 #$linux (string-join (list #$@arguments)) 403 #$linux (string-join (list #$@arguments))
401 #$initrd)) 404 #$initrd)))
402 (let ((kernel (menu-entry-multiboot-kernel entry)) 405 (multiboot-kernel
403 (arguments (menu-entry-multiboot-arguments entry)) 406 (let ((kernel (menu-entry-multiboot-kernel entry))
404 (modules (menu-entry-multiboot-modules entry)) 407 (arguments (menu-entry-multiboot-arguments entry))
405 (root-index 1)) ; XXX EFI will need root-index 2 408 (modules (menu-entry-multiboot-modules entry))
406 #~(format port " 409 (root-index 1)) ; XXX EFI will need root-index 2
410 #~(format port "
407menuentry ~s { 411menuentry ~s {
408 multiboot ~a root=device:hd0s~a~a~a 412 multiboot ~a root=device:hd0s~a~a~a
409}~%" 413}~%"
414 #$label
415 #$kernel
416 #$root-index (string-join (list #$@arguments) " " 'prefix)
417 (string-join (map string-join '#$modules)
418 "\n module " 'prefix))))
419 (chain-loader
420 #~(format port "
421menuentry ~s {
422 ~a
423 chainloader ~a
424}~%"
410 #$label 425 #$label
411 #$kernel 426 #$(grub-root-search device chain-loader)
412 #$root-index (string-join (list #$@arguments) " " 'prefix) 427 #$chain-loader)))))
413 (string-join (map string-join '#$modules)
414 "\n module " 'prefix))))))
415 428
416 (define (crypto-devices) 429 (define (crypto-devices)
417 (define (crypto-device->cryptomount dev) 430 (define (crypto-device->cryptomount dev)