summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2017-04-11 10:47:38 +0200
committerLudovic Courtès <ludo@gnu.org>2017-05-20 10:17:52 +0200
commitfd5a30ab7b999f9b1095426054b5fcdfdacddc6f (patch)
tree578ebc0249d8984cf7d286d7d747cebd69a5ce09
parentc383dc520f4b71bcb99115768bfafa00df85f9d1 (diff)
vm: Support arbitrary partition flags.
* gnu/build/vm.scm (<partition>): Change BOOTABLE? to FLAGS. (initialize-partition-table): Pass each flag to parted. (initialize-hard-disk): Locate boot partition. * gnu/system/vm.scm (qemu-image): Adjust partition flags.
-rw-r--r--gnu/build/vm.scm17
-rw-r--r--gnu/system/vm.scm2
2 files changed, 13 insertions, 6 deletions
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 1eb9a4c45e5..00d625c9469 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -3,6 +3,7 @@
3;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org> 3;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
4;;; Copyright © 2016 Leo Famulari <leo@famulari.name> 4;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
5;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> 5;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
6;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
6;;; 7;;;
7;;; This file is part of GNU Guix. 8;;; This file is part of GNU Guix.
8;;; 9;;;
@@ -41,7 +42,7 @@
41 partition-size 42 partition-size
42 partition-file-system 43 partition-file-system
43 partition-label 44 partition-label
44 partition-bootable? 45 partition-flags
45 partition-initializer 46 partition-initializer
46 47
47 root-partition-initializer 48 root-partition-initializer
@@ -141,7 +142,7 @@ the #:references-graphs parameter of 'derivation'."
141 (size partition-size) 142 (size partition-size)
142 (file-system partition-file-system (default "ext4")) 143 (file-system partition-file-system (default "ext4"))
143 (label partition-label (default #f)) 144 (label partition-label (default #f))
144 (bootable? partition-bootable? (default #f)) 145 (flags partition-flags (default '()))
145 (initializer partition-initializer (default (const #t)))) 146 (initializer partition-initializer (default (const #t))))
146 147
147(define (fold2 proc seed1 seed2 lst) ;TODO: factorize 148(define (fold2 proc seed1 seed2 lst) ;TODO: factorize
@@ -168,9 +169,10 @@ actual /dev name based on DEVICE."
168 (cons* "mkpart" "primary" "ext2" 169 (cons* "mkpart" "primary" "ext2"
169 (format #f "~aB" offset) 170 (format #f "~aB" offset)
170 (format #f "~aB" (+ offset (partition-size part))) 171 (format #f "~aB" (+ offset (partition-size part)))
171 (if (partition-bootable? part) 172 (append-map (lambda (flag)
172 `("set" ,(number->string index) "boot" "on") 173 (list "set" (number->string index)
173 '()))) 174 (symbol->string flag) "on"))
175 (partition-flags part))))
174 176
175 (define (options partitions offset) 177 (define (options partitions offset)
176 (let loop ((partitions partitions) 178 (let loop ((partitions partitions)
@@ -300,6 +302,11 @@ in PARTITIONS, and using BOOTCFG as its bootloader configuration file.
300 302
301Each partition is initialized by calling its 'initializer' procedure, 303Each partition is initialized by calling its 'initializer' procedure,
302passing it a directory name where it is mounted." 304passing it a directory name where it is mounted."
305
306 (define (partition-bootable? partition)
307 "Return the first partition found with the boot flag set."
308 (member 'boot (partition-flags partition)))
309
303 (let* ((partitions (initialize-partition-table device partitions)) 310 (let* ((partitions (initialize-partition-table device partitions))
304 (root (find partition-bootable? partitions)) 311 (root (find partition-bootable? partitions))
305 (target "/fs")) 312 (target "/fs"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 2c8b954c805..71bc55d7d82 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -229,7 +229,7 @@ the image."
229 (* 10 (expt 2 20)))) 229 (* 10 (expt 2 20))))
230 (label #$file-system-label) 230 (label #$file-system-label)
231 (file-system #$file-system-type) 231 (file-system #$file-system-type)
232 (bootable? #t) 232 (flags '(boot))
233 (initializer initialize))))) 233 (initializer initialize)))))
234 (initialize-hard-disk "/dev/vda" 234 (initialize-hard-disk "/dev/vda"
235 #:partitions partitions 235 #:partitions partitions