Skip to content
This repository was archived by the owner on Aug 27, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion doc/manual/installation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,33 @@ $ lvcreate --size 1G --name smalldisk MyVolGroup</screen>
<listitem><para>For creating software RAID devices, use
<command>mdadm</command>.</para></listitem>

<listitem><para>For creating ZFS pools, the zfs commands, e.g.,

<screen>
$ zpool create zroot /dev/sda2 ....
$ zfs create zroot/root </screen>

</para></listitem>

</itemizedlist>

</para></listitem>

<listitem><para>Mount the target file system on which NixOS should
be installed on <filename>/mnt</filename>.</para></listitem>
be installed on <filename>/mnt</filename>.</para>

<itemizedlist>
<listitem><para> If you're using a ZFS root, then you'll need to mark it as a legacy mount for the NixOS initrd to properly mount it.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be wrapped down to 72 columns.

ZFS root also requires requires a separate <filename>/boot</filename> partition.
<screen>
$ zfs set mountpoint=legacy zroot/root
$ mount -t zfs zroot/root /mnt
$ mkfs.ext3 -L boot /dev/sda1
$ mkdir /mnt/boot
$ mount LABEL=boot /mnt/boot </screen>
</para></listitem>
</itemizedlist>
</listitem>

<listitem>

Expand Down
2 changes: 1 addition & 1 deletion lib/test-driver/Machine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sub new {
if (!$startCommand) {
# !!! merge with qemu-vm.nix.
$startCommand =
"qemu-kvm -m 384 " .
"qemu-kvm -m 768 " .
"-net nic,model=virtio \$QEMU_OPTS ";
my $iface = $args->{hdaInterface} || "virtio";
$startCommand .= "-drive file=" . Cwd::abs_path($args->{hda}) . ",if=$iface,boot=on,werror=report "
Expand Down
2 changes: 1 addition & 1 deletion modules/profiles/base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
];

# Include support for various filesystems.
boot.supportedFilesystems = [ "btrfs" "reiserfs" "vfat" ];
boot.supportedFilesystems = [ "btrfs" "reiserfs" "vfat" "zfs" ];

}
24 changes: 14 additions & 10 deletions modules/tasks/filesystems/zfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,40 +50,44 @@ in

boot.initrd = mkIf inInitrd {
kernelModules = [ "spl" "zfs" ] ;
# zfs uses libs from: zfs, glibc, utillinux, zlib, gcc and glibc.
# stage-1.nix provides: glibc utlilinux gcc and glibc
extraUtilsCommands =
''
cp -v ${kernel.zfs}/sbin/zfs $out/sbin
cp -v ${kernel.zfs}/sbin/zdb $out/sbin
cp -v ${kernel.zfs}/sbin/zpool $out/sbin
cp -v ${kernel.zfs}/sbin/zfs $out/bin
cp -v ${kernel.zfs}/sbin/zdb $out/bin
cp -v ${kernel.zfs}/sbin/zpool $out/bin
cp -pdv ${kernel.zfs}/lib/lib*.so.* $out/lib
cp -pdv ${pkgs.zlib}/lib/lib*.so.* $out/lib
'';
postDeviceCommands =
''
zpool import -f -a -d /dev
zfs mount -a
'';
};

systemd.services."zpool-import" = {
systemd.services."zpool-import" = mkIf inSystem {
description = "Import zpools";
after = [ "systemd-udev-settle.service" ];
wantedBy = [ "local-fs.target" ];
restartIfChanged = false;
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
restartIfChanged = false;
ExecStart = "${kernel.zfs}/sbin/zpool import -f -a -d /dev";
ExecStart = "-${kernel.zfs}/sbin/zpool import -d /dev -f -a"; # XXX: allow failure?
};
};

systemd.services."zfs-mount" = {
description = "Mount zfs volumes";
after = [ "zpool-import.service" ];
wantedBy = [ "local-fs.target" ];
restartIfChanged = false;
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
restartIfChanged = false;
ExecStart = "${kernel.zfs}/sbin/zfs mount -a";
ExecStop = "${kernel.zfs}/sbin/zfs umount -a";
ExecStart = "-${kernel.zfs}/sbin/zfs mount -a"; # XXX: allow failure?
ExecStop = "-${kernel.zfs}/sbin/zfs umount -a"; # XXX: allow failure?
};
};

Expand Down
4 changes: 2 additions & 2 deletions modules/virtualisation/qemu-vm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ let
-virtfs local,path=$TMPDIR/xchg,security_model=none,mount_tag=xchg \
-virtfs local,path=''${SHARED_DIR:-$TMPDIR/xchg},security_model=none,mount_tag=shared \
${if cfg.useBootLoader then ''
-drive index=0,id=drive1,file=$NIX_DISK_IMAGE,if=virtio,cache=writeback,werror=report \
-drive index=0,id=drive1,file=$NIX_DISK_IMAGE,if=virtio,cache=writethrough,werror=report \
-drive index=1,id=drive2,file=${bootDisk}/disk.img,if=virtio,readonly \
-boot menu=on
'' else ''
-drive file=$NIX_DISK_IMAGE,if=virtio,cache=writeback,werror=report \
-drive file=$NIX_DISK_IMAGE,if=virtio,cache=writethrough,werror=report \
-kernel ${config.system.build.toplevel}/kernel \
-initrd ${config.system.build.toplevel}/initrd \
-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo} ${kernelConsole} $QEMU_KERNEL_PARAMS" \
Expand Down
1 change: 1 addition & 0 deletions release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ in {
installer.rebuildCD = runTest (t: t.installer.rebuildCD.test);
installer.separateBoot = runTest (t: t.installer.separateBoot.test);
installer.simple = runTest (t: t.installer.simple.test);
installer.zroot = runTest (t: t.installer.zroot.test);
#installer.swraid = runTest (t: t.installer.swraid.test);
ipv6 = runTest (t: t.ipv6.test);
kde4 = runTest (t: t.kde4.test);
Expand Down
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ with import ../lib/testing.nix { inherit system minimal; };
tomcat = makeTest (import ./tomcat.nix);
trac = makeTest (import ./trac.nix);
xfce = makeTest (import ./xfce.nix);
ztest = makeTest (import ./ztest.nix);
}
36 changes: 36 additions & 0 deletions tests/installer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ let
}
'';

zRootFS =
''
boot.initrd.supportedFilesystems = [ "ext3" "zfs" ];
fileSystems."/".device = "zroot/root";
fileSystems."/".fsType = "zfs";
'';

rootFS =
''
fileSystems."/".device = "/dev/disk/by-label/nixos";
Expand Down Expand Up @@ -301,6 +308,35 @@ in {
fileSystems = rootFS + bootFS;
};

# separate boot/zfs root partition
zroot = makeTest
{ createPartitions =
''
$machine->succeed(
"parted /dev/vda mklabel msdos",
"parted /dev/vda -- mkpart primary 1M 50MB", # /boot
"parted /dev/vda -- mkpart primary 50MB 2048M",
"udevadm settle",
"zpool create zroot /dev/vda2", # start a pool
"zfs create zroot/root", # create root
"zfs set mountpoint=legacy zroot/root", # mount this fs with 'mount' instead of 'zfs mount'
"zfs set compression=lz4 zroot/root", # compress things a bit, so we don't run out of space.
"mount -t zfs zroot/root /mnt",
"zfs create -V 1G -b 4K zroot/swap", # create a swap zvol
"zfs set compression=off zroot/swap", # don't compress swap
"zfs set primarycache=metadata zroot/swap", # only cache metadata
"zfs set sync=always zroot/swap",
"mkswap -L swap /dev/zvol/zroot/swap",
"swapon -L swap",
"mkfs.ext3 -L boot /dev/vda1", # separate boot partition
"mkdir /mnt/boot",
"mount LABEL=boot /mnt/boot",
"udevadm settle",
);
'';
fileSystems = zRootFS + bootFS;
};

# Test a basic install using GRUB 1.
grub1 = makeTest
{ createPartitions =
Expand Down
33 changes: 33 additions & 0 deletions tests/ztest.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ pkgs, ... }:

{
nodes = {
machine =
{ pkgs, config, ... }:

{
virtualisation.emptyDiskImages = [ 4096 ];
boot.supportedFilesystems = [ "zfs" "ext4" ] ;
};
};

testScript = ''
startAll;

$machine->waitForUnit("default.target");

# this is a work in progress, it currently fails with:
# pack/bigT mismatch in 0x7f5ff010cf60/0x7f5ff068fea8
# probably some disk io synchronization problems.

# we don't directly create a zfs filesystem here we create a ext3
# filesystem and the the zfs unit tests use it..

$machine->succeed("mkfs.ext3 -L ztest /dev/vdb");
$machine->succeed("mkdir /ztest");
$machine->succeed("mount LABEL=ztest /ztest");
$machine->succeed("echo Running ZFS unit tests, this may take a while...");
$machine->succeed("ztest -f /ztest -t1 -VVV"); # single threaded
$machine->shutdown;
'';
}