.. | ||
configuration.nix | ||
infect.sh | ||
README.md |
NixOS on Media Temple
On Media Temple we can install NixOS on Ubuntu servers by using a custom infect script.
Add a new server
- Click on
Add New Service
and selectSelf Managed VPS
. - Select appropriate server resources (e.g. 2 CPU, 4GB RAM and 100GB storage) and tick
No control panel
. - After order has been processed you will need to finish the installation (selecting Ubuntu version, setting username and password)
Infect Ubuntu 20.04
After executing the infect script (bash infect.sh
) you will need to modify the
hardware-configuration.nix
file. The script will stop and you will need to do it
manually. You will need to remove all squashfs
and vfat
(efi boot) entries.
The automatically generated config will look something like this:
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ata_piix" "virtio_pci" "virtio_scsi" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/e46da1b8-55a0-4df9-842e-8d80c3a22ffc";
fsType = "ext4";
};
fileSystems."/snap/snapd/12883" =
{ device = "/var/lib/snapd/snaps/snapd_12883.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/core20/1081" =
{ device = "/var/lib/snapd/snaps/core20_1081.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/boot/efi" =
{ device = "/dev/disk/by-uuid/7341-10DC";
fsType = "vfat";
};
fileSystems."/snap/lxd/21545" =
{ device = "/var/lib/snapd/snaps/lxd_21545.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/snapd/14549" =
{ device = "/var/lib/snapd/snaps/snapd_14549.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/core20/1270" =
{ device = "/var/lib/snapd/snaps/core20_1270.snap";
fsType = "squashfs";
options = [ "loop" ];
};
fileSystems."/snap/lxd/21835" =
{ device = "/var/lib/snapd/snaps/lxd_21835.snap";
fsType = "squashfs";
options = [ "loop" ];
};
swapDevices = [ ];
}
It's also recommended to name fileSystem."/"
device to /dev/sda3
in case the server
gets relocated (disk UUID will change) and add nvme
to boot.initrd.kernelModules
.
How do I know it's /dev/sda3
and not e.g. sda1 or sda2? Run lsblk
and you will see
the correct pact. In our case:
root@ip:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 32.3M 1 loop /snap/snapd/12883
loop1 7:1 0 61.8M 1 loop /snap/core20/1081
loop2 7:2 0 67.3M 1 loop /snap/lxd/21545
loop3 7:3 0 43.4M 1 loop /snap/snapd/14549
loop4 7:4 0 61.9M 1 loop /snap/core20/1270
loop5 7:5 0 67.2M 1 loop /snap/lxd/21835
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 4M 0 part
├─sda2 8:2 0 106M 0 part /boot/efi
└─sda3 8:3 0 99.9G 0 part /
Optional:
- Add a bit of swap.
- Mount
/dev/sda2
partition on/boot
After you remove all the squashfs
and the efi boot entries you will be left with:
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" ];
boot.initrd.kernelModules = [ "nvme" ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/sda3";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/sda2";
fsType = "vfat";
};
swapDevices = [
{
device = "/swapfile";
size = 1024;
priority = 0;
}
];
}
The last few lines of infect output will look something like this:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "en_US.UTF-8",
LC_CTYPE = "UTF-8",
LANG = "C.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("C.UTF-8").
updating GRUB 2 menu...
installing the GRUB 2 boot loader on /dev/sda...
Installing for i386-pc platform.
/nix/store/jx1qj6fh98fnifslhllpcaqaia2nhxz5-grub-2.06/sbin/grub-install: warning: cannot open directory `/nix/store/jx1qj6fh98fnifslhllpcaqaia2nhxz5-grub-2.06/share/locale': No such file or directory.
Installation finished. No error reported.
Verify /etc/nixos/*.nix
config files and make sure they are correct (especially IPs in
configuration.nix
).
After reboot, you should be able to SSH to the server.