[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26815: [PATCH 1/3] vm: Add support for arbitrary partition flags.
From: |
Marius Bakke |
Subject: |
bug#26815: [PATCH 1/3] vm: Add support for arbitrary partition flags. |
Date: |
Sun, 7 May 2017 16:36:45 +0200 |
* gnu/build/vm.scm (<partition>): Change BOOTABLE? to FLAGS.
(initialize-partition-table): Pass each flag to parted.
(initialize-hard-disk): Search for root partition by "boot" flag.
* gnu/system/vm.scm (qemu-image): Adjust partitions accordingly.
---
gnu/build/vm.scm | 18 +++++++++++++-----
gnu/system/vm.scm | 2 +-
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 440596a40..3286ffb02 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2016 Christopher Allan Webber <address@hidden>
;;; Copyright © 2016 Leo Famulari <address@hidden>
;;; Copyright © 2017 Mathieu Othacehe <address@hidden>
+;;; Copyright © 2017 Marius Bakke <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -41,7 +42,7 @@
partition-size
partition-file-system
partition-label
- partition-bootable?
+ partition-flags
partition-initializer
root-partition-initializer
@@ -141,7 +142,7 @@ the #:references-graphs parameter of 'derivation'."
(size partition-size)
(file-system partition-file-system (default "ext4"))
(label partition-label (default #f))
- (bootable? partition-bootable? (default #f))
+ (flags partition-flags (default '()))
(initializer partition-initializer (default (const #t))))
(define (fold2 proc seed1 seed2 lst) ;TODO: factorize
@@ -168,9 +169,11 @@ actual /dev name based on DEVICE."
(cons* "mkpart" "primary" "ext2"
(format #f "~aB" offset)
(format #f "~aB" (+ offset (partition-size part)))
- (if (partition-bootable? part)
- `("set" ,(number->string index) "boot" "on")
- '())))
+ (apply append (map (lambda (flag)
+ (cons* "set" (number->string index)
+ (symbol->string flag)
+ "on" '()))
+ (partition-flags part)))))
(define (options partitions offset)
(let loop ((partitions partitions)
@@ -303,6 +306,11 @@ in PARTITIONS, and using BOOTCFG as its bootloader
configuration file.
Each partition is initialized by calling its 'initializer' procedure,
passing it a directory name where it is mounted."
+
+ (define (partition-bootable? partitions)
+ "Return the first partition found with the boot flag set."
+ (member 'boot (partition-flags partitions)))
+
(let* ((partitions (initialize-partition-table device partitions))
(root (find partition-bootable? partitions))
(target "/fs"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index cc13abe2a..42c7690b1 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -230,7 +230,7 @@ the image."
(* 10 (expt 2 20))))
(label #$file-system-label)
(file-system #$file-system-type)
- (bootable? #t)
+ (flags '(boot))
(initializer initialize)))))
(initialize-hard-disk "/dev/vda"
#:partitions partitions
--
2.12.2
- bug#26815: [PATCH 0/3] Hybrid UEFI disk image, Marius Bakke, 2017/05/07
- bug#26815: [PATCH 1/3] vm: Add support for arbitrary partition flags.,
Marius Bakke <=
- bug#26815: [PATCH 3/3] vm: Support EFI boot in base image., Marius Bakke, 2017/05/07
- bug#26815: [PATCH 3/3] vm: Support EFI boot in base image., Danny Milosavljevic, 2017/05/07
- bug#26815: [PATCH 3/3] vm: Support EFI boot in base image., Marius Bakke, 2017/05/07
- bug#26815: [PATCH 3/3] vm: Support EFI boot in base image., Marius Bakke, 2017/05/07
- bug#26815: [PATCH 3/3] vm: Support EFI boot in base image., Marius Bakke, 2017/05/08
- bug#26815: [PATCH 3/3] vm: Support EFI boot in base image., Ludovic Courtès, 2017/05/08
- bug#26815: [PATCH 1/3] vm: Support arbitrary partition flags., Marius Bakke, 2017/05/10
- bug#26815: [PATCH 2/3] vm: Support creating FAT partitions., Marius Bakke, 2017/05/10
- bug#26815: [PATCH 3/3] vm: Add UEFI loader to disk images., Marius Bakke, 2017/05/10
- bug#26815: [PATCH 3/3] vm: Add UEFI loader to disk images., Ludovic Courtès, 2017/05/10