I'm running a VM on a virtual cluster. The (experimental) cluster provisioning system puts an unformatted block device in /dev/sdb
. Upon cluster initialization, I want to format this device and mount.
In the initialization workflow, my VM contacts the cluster manager to learn how configure the VM--network interfaces, and devices. I'm feeding this info to a nix expression which my /etc/nixos/configuration.nix
inherits. I can make the filesystem mount a partitioned disk:
fileSystems."/log" = { device = "${logDevice}1";
fsType = "bind"; };
However, I don't know how to format the device as a part of configuration. If this was a nix derivation, I would put make some sort of buildHook, e.g.
formatLogDisk = ''
parted -s ${logDevice} mklabel gpt
parted -s ${logDevice} unit % mkpart extended ext4 0 100
mkfs.ext4 -q ${logDevice}1
'';
So I'm wondering if there is some sort of preMount
module hook that might run this. Otherwise, I can run the utilities directly during the phase that collects the system information, but I was hoping thered be a nixOs based answer.