summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-09-04 23:21:37 +0200
committerLudovic Courtès <ludo@gnu.org>2013-09-05 00:46:09 +0200
commit7c1d8146a770d6b37b35cefc0ad8662f4c07df62 (patch)
treef86944c8623f1333c4bf94fd5642fe86411002a6
parente911470857069b20c767d2a581b3ab640ac876db (diff)
downloadguix-7c1d8146a770d6b37b35cefc0ad8662f4c07df62.tar.gz
gnu: vm: 'qemu-image' populates /dev on the target root file system.
* gnu/system/vm.scm (qemu-image): Use (guix build linux-initrd).  Remove
  'mknod' calls; use 'make-essential-device-nodes' to populate /dev on
  the target image.
* gnu/packages/linux-initrd.scm (qemu-initrd): When /root/dev exists,
  don't call 'make-essential-device-nodes'.
-rw-r--r--gnu/packages/linux-initrd.scm5
-rw-r--r--gnu/system/vm.scm15
2 files changed, 11 insertions, 9 deletions
diff --git a/gnu/packages/linux-initrd.scm b/gnu/packages/linux-initrd.scm
index 4a4e437635..ab8787f02c 100644
--- a/gnu/packages/linux-initrd.scm
+++ b/gnu/packages/linux-initrd.scm
@@ -284,8 +284,9 @@ the Linux kernel.")
         (mkdir "/root/xchg")
         (mkdir-p "/root/nix/store")
 
-        (mkdir "/root/dev")
-        (make-essential-device-nodes #:root "/root/dev")
+        (unless (file-exists? "/root/dev")
+          (mkdir "/root/dev")
+          (make-essential-device-nodes #:root "/root"))
 
         ;; Mount the host's store and exchange directory.
         (mount-qemu-smb-share "/store" "/root/nix/store")
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 3bc94f4575..596a697738 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -210,7 +210,8 @@ process."
    `(let ()
       (use-modules (ice-9 rdelim)
                    (srfi srfi-1)
-                   (guix build utils))
+                   (guix build utils)
+                   (guix build linux-initrd))
 
       (let ((parted  (string-append (assoc-ref %build-inputs "parted")
                                     "/sbin/parted"))
@@ -223,9 +224,7 @@ process."
             (initrd  (string-append (assoc-ref %build-inputs "initrd")
                                     "/initrd"))
             (linux   (string-append (assoc-ref %build-inputs "linux")
-                                    "/bzImage"))
-            (makedev (lambda (major minor)
-                       (+ (* major 256) minor))))
+                                    "/bzImage")))
 
         (define (read-reference-graph port)
           ;; Return a list of store paths from the reference graph at PORT.
@@ -265,7 +264,6 @@ process."
                                (assoc-ref %build-inputs "gawk") "/bin"))
 
         (display "creating partition table...\n")
-        (mknod "/dev/vda" 'block-special #o644 (makedev 8 0))
         (and (zero? (system* parted "/dev/vda" "mklabel" "msdos"
                              "mkpart" "primary" "ext2" "1MiB"
                              ,(format #f "~aB"
@@ -273,7 +271,6 @@ process."
                                          (* 5 (expt 2 20))))))
              (begin
                (display "creating ext3 partition...\n")
-               (mknod "/dev/vda1" 'block-special #o644 (makedev 8 1))
                (and (zero? (system* mkfs "-F" "/dev/vda1"))
                     (begin
                       (display "mounting partition...\n")
@@ -291,6 +288,9 @@ process."
                                                                    thing)))
                                 (things-to-copy))
 
+                      ;; Populate /dev.
+                      (make-essential-device-nodes #:root "/fs")
+
                       (call-with-output-file "/fs/boot/grub/grub.cfg"
                         (lambda (p)
                           (format p "
@@ -335,7 +335,8 @@ menuentry \"Boot-to-Guile! (GNU System technology preview)\" {
    #:make-disk-image? #t
    #:disk-image-size disk-image-size
    #:references-graphs (map input->name+derivation inputs-to-copy)
-   #:modules '((guix build utils))))
+   #:modules '((guix build utils)
+               (guix build linux-initrd))))
 
 
 ;;;