~tieong/bootstrap-guix

0dc18dff02e647a368c65b0f6c6109f150994c7e — Thomas Ieong 1 year, 29 days ago 785d8bf
Added an interactive script that will install guix on a Kimsufi.
1 files changed, 90 insertions(+), 0 deletions(-)

A kimsufi-guix.sh
A kimsufi-guix.sh => kimsufi-guix.sh +90 -0
@@ 0,0 1,90 @@
#!/usr/bin/env bash

# From the web ui, select netboot -> rescue64-pro then restart -> OVH will email you the rescue credentials.
# If you ssh into the machine with tmux I recommend export TERM=xterm so that you can CTRL+L

# Guix

wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
chmod +x guix-install.sh
# Press enter to every prompt
./guix-install.sh
guix pull

# Partitions
# See https://blog.hqcodeshop.fi/archives/273-GNU-Parted-Solving-the-dreaded-The-resulting-partition-is-not-properly-aligned-for-best-performance.html
# https://wiki.archlinux.org/title/Advanced_Format#Partition_alignment

mdadm --stop /dev/md127
mdadm --zero-superblock /dev/sda2 /dev/sdb2

wipefs -a /dev/sda
wipefs -a /dev/sdb

parted /dev/sda --align=opt -s -m -- mklabel gpt
parted /dev/sda --align=opt -s -m -- \
 mkpart bios_grub 1049kb 512MiB \
 set 1 bios_grub on
parted /dev/sda --align=opt -s -m -- \
 mkpart primary 512MiB -512MiB
 set 2 raid on
parted /dev/sda --align=opt -s -m -- mkpart primary linux-swap 512MiB 100% # Swap

parted /dev/sdb --align=opt -s -m -- mklabel gpt
parted /dev/sdb --align=opt -s -m -- \
     mkpart bios_grub 1049kb 512MiB \
     set 1 bios_grub on
parted /dev/sdb --align=opt -s -m -- \
     mkpart primary 512MiB -512MiB \
     set 2 raid on
parted /dev/sdb --align=opt -s -m -- mkpart primary linux-swap 512MiB 100% # Swap

## RAID

## Use btrfs instead of mdadm?
mdadm --create /dev/md127 --level=1 --raid-disks=2 --metadata=0.90 /dev/sda2 /dev/sdb2

## Boot partitions
mkfs.ext4  /dev/sda1
mkfs.ext4  /dev/sdb1

## Root filesystem
mkfs.ext4 /dev/md127

## Swap partitions
mkswap /dev/sda3
swapon /dev/sda3
mkswap /dev/sdb3
swapon /dev/sdb3

# Installing guix system

mkdir /mnt/guix
mount /dev/md127 /mnt/guix

# Chroot

# You do need to transfer your os.scm via scp/rsync in /mnt/root/

guix install bash-static parted htop util-linux-with-udev coreutils guix

cd /mnt || exit 1

mkdir -p bin etc gnu/store root/.guix-profile/ root/.config/guix/current var/guix proc sys dev

cp /etc/resolv.conf etc/

mount --rbind /proc /mnt/proc
mount --rbind /sys /mnt/sys
mount --rbind /dev /mnt/dev
mount --rbind /var/guix/ var/guix/
mount --rbind /gnu/store gnu/store/
mount --rbind /root/.config/ root/.config/
mount --rbind /root/.guix-profile/bin/ bin
mount --rbind /root/.guix-profile root/.guix-profile/

chroot /mnt/ /bin/bash

guix system init /root/os.scm /guix

# Then on the web ui change the netboot to boot to disk and restart (also from the web ui).