nix-community/nixos-anywhere

no-os install requires root login

Closed this issue · 3 comments

I am installing NixOS with a booted installer CD this document mentions it can be done as nixos user that is present on the installer cd.

password in order to access it. To set a password for the `nixos` user, run the

but I received these errors:

+ wipefs --all -f /dev/xvda1
wipefs: error: /dev/xvda1: probing initialization failed: Permission denied
+ wipefs --all -f /dev/xvda2
wipefs: error: /dev/xvda2: probing initialization failed: Permission denied
+ wipefs --all -f /dev/xvda3
wipefs: error: /dev/xvda3: probing initialization failed: Permission denied
++ zdb -l /dev/xvda
++ sed -nr 's/ +name: '\''(.*)'\''/\1/p'
+ zpool=
+ [[ -n '' ]]
+ unset zpool
++ lsblk /dev/xvda -l -p -o type,name
++ awk 'match($1,"raid.*") {print $2}'
+ md_dev=
+ [[ -n '' ]]
+ wipefs --all -f /dev/xvda
wipefs: error: /dev/xvda: probing initialization failed: Permission denied
+ dd if=/dev/zero of=/dev/xvda bs=440 count=1
dd: failed to open '/dev/xvda': Permission denied
++ mktemp -d
+ disko_devices_dir=/tmp/tmp.FR9K6lAylU
+ trap 'rm -rf "$disko_devices_dir"' EXIT
+ mkdir -p /tmp/tmp.FR9K6lAylU
+ device=/dev/xvda
+ imageSize=2G
+ name=disk1
+ type=disk
+ device=/dev/xvda
+ efiGptPartitionFirst=1
+ type=gpt
+ sgdisk --align-end --new=1:0:+1M --change-name=1:disk-disk1-space --typecode=1:EF02 /dev/xvda
Problem opening /dev/xvda for reading! Error is 13.
You must run this program as root or use sudo!

I'd be happy to update the no-os doc to reflect that root is required. Or if you'd like to double check that sudo is being called in the appropriate places in the code.

Let me know

I found this to be the case too. Works fine as long as root login on SSH is allowed including password auth is allowed or an entry in the authorized_users for the installing machine exists on the target host. All of that is not available on a Ubuntu Life-CD for example. With Nixos installer it's a peace of cake though.

I wonder if this

ssh_ "$disko_script"

needs to be:

ssh_ "${maybe_sudo}" "$disko_script"

@sedlund not exactly. It should be something like this because the sudo must happen after sshing in the box.

ssh_ sh <<SSH
set -efu ${enable_debug}
$maybe_sudo rm -rf /root/kexec
$maybe_sudo mkdir -p /root/kexec
SSH

EDIT: Actually I was wrong, well, the snippet I showed works but in my case I had encryption enabled with a passphrase but the script failed when asking for the passphrase. With your version it works.

EDIT2: The linked PR fixes this issues, for me at least 🎉