Skip to content

Commit

Permalink
nixos/installer: add sd-image-powerpc64le.nix
Browse files Browse the repository at this point in the history
This builds on top of nixpkgs mainline 00d8347
with the following two PRs cherry-picked:

- #192670
- #192668

using the following command:

```
nix build -f nixos -L \
  -I nixos-config=nixos/modules/installer/sd-card/sd-image-powerpc64le.nix \
  config.system.build.sdImage
```

I was able to successfully boot the image, although it boots to a login prompt
rather than a shell, and won't accept the empty password for `root`.  I guess
I'll have to figure out why that is.

To boot the image: `zstd`-decompress the it, mount it, and use `kexec`:

```
cd boot/nixos
kexec -l \
  *-vmlinux \
  --initrd *-initrd \
  --dt-no-old-root \
  --command-line="$(grep APPEND ../extlinux/extlinux.conf | sed 's_^ *APPEND *__')"
```

The machine I used for testing has only one storage device which is completely
allocated to LVM.  It appears that the NixOS ISO loader doesn't look for
partition tables within LVM volumes.  To work aroundn this, I had to extract the
`ext4` image within the partition table within the `sd-card` image and put that
in its own LVM volume.  This likely won't be an obstacle for users who write the
image to a USB stick or similar.
  • Loading branch information
Adam Joseph authored and wegank committed Feb 23, 2023
1 parent 3ad7b8a commit f99e8ba
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions nixos/modules/installer/sd-card/sd-image-powerpc64le.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# To build, use:
# nix-build nixos -I nixos-config=nixos/modules/installer/sd-card/sd-image-powerpc64le.nix -A config.system.build.sdImage
{ config, lib, pkgs, ... }:

{
imports = [
../../profiles/base.nix
../../profiles/installation-device.nix
./sd-image.nix
];

boot.loader = {
# powerpc64le-linux typically uses petitboot
grub.enable = false;
generic-extlinux-compatible = {
# petitboot is not does not support all of the extlinux extensions to
# syslinux, but its parser is very forgiving; it essentially ignores
# whatever it doesn't understand. See below for a filename adjustment.
enable = true;
};
};

boot.consoleLogLevel = lib.mkDefault 7;
boot.kernelParams = [ "console=hvc0" ];

sdImage = {
populateFirmwareCommands = "";
populateRootCommands = ''
mkdir -p ./files/boot
${config.boot.loader.generic-extlinux-compatible.populateCmd} \
-c ${config.system.build.toplevel} \
-d ./files/boot
''
# https://github.com/open-power/petitboot/blob/master/discover/syslinux-parser.c
# petitboot will look in these paths (plus all-caps versions of them):
# /boot/syslinux/syslinux.cfg
# /syslinux/syslinux.cfg
# /syslinux.cfg
+ ''
mv ./files/boot/extlinux ./files/boot/syslinux
mv ./files/boot/syslinux/extlinux.conf ./files/boot/syslinux/syslinux.cfg
''
# petitboot does not support relative paths for LINUX or INITRD; it prepends
# a `/` when parsing these fields
+ ''
sed -i 's_^\(\W\W*\(INITRD\|initrd\|LINUX\|linux\)\W\)\.\./_\1/boot/_' ./files/boot/syslinux/syslinux.cfg
'';
};
}

0 comments on commit f99e8ba

Please sign in to comment.