NixOS ISO: Don't use a unionfs for /

We don't need a unionfs on /, we only need a tmpfs.
This commit is contained in:
Eelco Dolstra 2014-05-21 14:06:31 +02:00
parent 48601269a9
commit 5e364503d5
2 changed files with 32 additions and 27 deletions

View File

@ -67,7 +67,7 @@ let
${config.boot.kernelPackages.kernel}/bzImage ::boot/bzImage ${config.boot.kernelPackages.kernel}/bzImage ::boot/bzImage
mcopy -v -i "$out" \ mcopy -v -i "$out" \
${config.system.build.initialRamdisk}/initrd ::boot/initrd ${config.system.build.initialRamdisk}/initrd ::boot/initrd
''; ''; # */
targetArch = if pkgs.stdenv.isi686 then targetArch = if pkgs.stdenv.isi686 then
"ia32" "ia32"
@ -177,39 +177,45 @@ in
# recognise that. # recognise that.
boot.kernelParams = [ "root=LABEL=${config.isoImage.volumeID}" ]; boot.kernelParams = [ "root=LABEL=${config.isoImage.volumeID}" ];
# Note that /dev/root is a symlink to the actual root device fileSystems."/" =
# specified on the kernel command line, created in the stage 1 init { fsType = "tmpfs";
# script. device = "none";
fileSystems."/".device = "/dev/root"; 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"; { fsType = "squashfs";
device = "/nix-store.squashfs"; device = "/iso/nix-store.squashfs";
options = "loop"; options = "loop";
neededForBoot = true;
};
fileSystems."/nix/.rw-store" =
{ fsType = "tmpfs";
device = "none";
options = "mode=0755";
neededForBoot = true;
}; };
boot.initrd.availableKernelModules = [ "squashfs" "iso9660" ]; boot.initrd.availableKernelModules = [ "squashfs" "iso9660" ];
boot.initrd.kernelModules = [ "loop" ]; boot.initrd.kernelModules = [ "loop" ];
# In stage 1, mount a tmpfs on top of / (the ISO image) and # In stage 1, mount a tmpfs on top of /nix/store (the squashfs
# /nix/store (the squashfs image) to make this a live CD. # image) to make this a live CD.
boot.initrd.postMountCommands = boot.initrd.postMountCommands =
'' ''
mkdir -p /unionfs-chroot/ro-root mkdir -p $targetRoot/nix/store
mount --rbind $targetRoot /unionfs-chroot/ro-root unionfs -o allow_other,cow,nonempty,chroot=$targetRoot,max_files=32768 /nix/.rw-store=RW:/nix/.ro-store=RO $targetRoot/nix/store
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
''; '';
# Closures to be copied to the Nix store on the CD, namely the init # Closures to be copied to the Nix store on the CD, namely the init
@ -253,10 +259,6 @@ in
{ source = config.system.build.squashfsStore; { source = config.system.build.squashfsStore;
target = "/nix-store.squashfs"; 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 [ ] ++ optionals config.isoImage.makeEfiBootable [
{ source = efiImg; { source = efiImg;
target = "/boot/efi.img"; target = "/boot/efi.img";

View File

@ -344,5 +344,8 @@ in
(isYes "BLK_DEV_INITRD") (isYes "BLK_DEV_INITRD")
]; ];
# Prevent systemd from waiting for the /dev/root symlink.
systemd.units."dev-root.device".text = "";
}; };
} }