From 5e364503d5b219e81c54e3616e3bf8e61a2cf1c7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 21 May 2014 14:06:31 +0200 Subject: [PATCH] NixOS ISO: Don't use a unionfs for / We don't need a unionfs on /, we only need a tmpfs. --- nixos/modules/installer/cd-dvd/iso-image.nix | 56 ++++++++++---------- nixos/modules/system/boot/stage-1.nix | 3 ++ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index 00f5fae84342..28c42d64f6fb 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -67,7 +67,7 @@ let ${config.boot.kernelPackages.kernel}/bzImage ::boot/bzImage mcopy -v -i "$out" \ ${config.system.build.initialRamdisk}/initrd ::boot/initrd - ''; + ''; # */ targetArch = if pkgs.stdenv.isi686 then "ia32" @@ -177,39 +177,45 @@ in # recognise that. boot.kernelParams = [ "root=LABEL=${config.isoImage.volumeID}" ]; - # Note that /dev/root is a symlink to the actual root device - # specified on the kernel command line, created in the stage 1 init - # script. - fileSystems."/".device = "/dev/root"; + fileSystems."/" = + { fsType = "tmpfs"; + device = "none"; + options = "mode=0755"; + }; - fileSystems."/nix/store" = + # Note that /dev/root is a symlink to the actual root device + # specified on the kernel command line, created in the stage 1 + # init script. + fileSystems."/iso" = + { device = "/dev/root"; + neededForBoot = true; + noCheck = true; + }; + + fileSystems."/nix/.ro-store" = { fsType = "squashfs"; - device = "/nix-store.squashfs"; + device = "/iso/nix-store.squashfs"; options = "loop"; + neededForBoot = true; + }; + + fileSystems."/nix/.rw-store" = + { fsType = "tmpfs"; + device = "none"; + options = "mode=0755"; + neededForBoot = true; }; boot.initrd.availableKernelModules = [ "squashfs" "iso9660" ]; boot.initrd.kernelModules = [ "loop" ]; - # In stage 1, mount a tmpfs on top of / (the ISO image) and - # /nix/store (the squashfs image) to make this a live CD. + # In stage 1, mount a tmpfs on top of /nix/store (the squashfs + # image) to make this a live CD. boot.initrd.postMountCommands = '' - mkdir -p /unionfs-chroot/ro-root - mount --rbind $targetRoot /unionfs-chroot/ro-root - - mkdir /unionfs-chroot/rw-root - mount -t tmpfs -o "mode=755" none /unionfs-chroot/rw-root - mkdir /mnt-root-union - unionfs -o allow_other,cow,chroot=/unionfs-chroot,max_files=32768 /rw-root=RW:/ro-root=RO /mnt-root-union - oldTargetRoot=$targetRoot - targetRoot=/mnt-root-union - - mkdir /unionfs-chroot/rw-store - mount -t tmpfs -o "mode=755" none /unionfs-chroot/rw-store - mkdir -p $oldTargetRoot/nix/store - unionfs -o allow_other,cow,nonempty,chroot=/unionfs-chroot,max_files=32768 /rw-store=RW:/ro-root/nix/store=RO /mnt-root-union/nix/store + mkdir -p $targetRoot/nix/store + unionfs -o allow_other,cow,nonempty,chroot=$targetRoot,max_files=32768 /nix/.rw-store=RW:/nix/.ro-store=RO $targetRoot/nix/store ''; # Closures to be copied to the Nix store on the CD, namely the init @@ -253,10 +259,6 @@ in { source = config.system.build.squashfsStore; target = "/nix-store.squashfs"; } - { # Quick hack: need a mount point for the store. - source = pkgs.runCommand "empty" {} "mkdir -p $out"; - target = "/nix/store"; - } ] ++ optionals config.isoImage.makeEfiBootable [ { source = efiImg; target = "/boot/efi.img"; diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index c38d33c45d6e..b6249b6c0915 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -344,5 +344,8 @@ in (isYes "BLK_DEV_INITRD") ]; + # Prevent systemd from waiting for the /dev/root symlink. + systemd.units."dev-root.device".text = ""; + }; }