Skip to content

Instantly share code, notes, and snippets.

@kradalby
Created February 12, 2022 08:23
Show Gist options
  • Save kradalby/0957a5d4fbb9018d0b700b118f5c5341 to your computer and use it in GitHub Desktop.
Save kradalby/0957a5d4fbb9018d0b700b118f5c5341 to your computer and use it in GitHub Desktop.
Oracle Linux 8.5 to NixOS with ESP resizing
#cloud-config
# vim: syntax=yaml
disable_root: false
ssh_authorized_keys: []
write_files:
- path: "/etc/ssh/sshd_config.d/permit_root"
owner: "root:root"
permissions: "0644"
content: |
PermitRootLogin without-password
- path: "/etc/iptables/rules.v4"
- path: "/etc/iptables/rules.v6"
- path: /etc/nixos/host.nix
permissions: "0644"
content: |
{pkgs, lib, config, ...}:
{
environment.systemPackages = with pkgs; [ vim git ];
networking.usePredictableInterfaceNames = true;
nix = {
package = pkgs.nixFlakes;
extraOptions = lib.optionalString (config.nix.package == pkgs.nixFlakes)
"experimental-features = nix-command flakes";
};
}
users:
- name: ubuntu
inactive: true
package_update: true
package_upgrade: false
package_reboot_if_required: false
locale: "en_US.UTF-8"
timezone: "Europe/London"
runcmd:
- /usr/libexec/oci-growfs -y
- pkill OSWatcher
- umount /var/oled
- lvremove /dev/mapper/ocivolume-oled
- lvresize -l +100%FREE /dev/mapper/ocivolume-root
- >
echo "drive d: file=\"/dev/sda1\" exclusive" > /etc/mtools.conf
- echo "mtools_skip_check=1" >> /etc/mtools.conf
- cp -a /boot /root/
# Try to ensure we can unmount and remount /boot
- sed -i '/boot/d' /etc/fstab
- sed -i '/oled/d' /etc/fstab
- systemctl disable boot.mount
- umount /boot/efi
- umount /boot
- sgdisk -d 1 -d 2 -n 1:0:0 -t 1:ef00 -c 1:"EFI System Partition" /dev/sda
- partprobe /dev/sda
- mkfs.fat -F32 /dev/sda1
- mount -v /dev/sda1 /boot
- cp -a /root/boot /
- >
curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect |
NO_SWAP=1
NIXOS_IMPORT=./host.nix
NIX_CHANNEL=nixos-21.11
bash -x |
tee /tmp/infect.log
@vamega
Copy link

vamega commented Jun 3, 2022

What is the purpose of the mtools configuration file in this?

@kradalby
Copy link
Author

kradalby commented Jun 3, 2022

@vamega I don’t think there is, it might be there because I thought I needed some dos flags on the ESP partition.

I have not verified that it’s not needed, but 97% sure. Will update it when I have time to verify

@vamega
Copy link

vamega commented Jun 6, 2022

Thanks, I removed that section and didn't seem to have any issues.
Let me know if you find anything different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment