From 8e92e2a8e4398c6c46c56eea6752ae1c4ee2077a Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 1 Jun 2019 17:06:56 -0300 Subject: Use sgdisk to automate the creation of partitions --- public/install-nixos.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/public/install-nixos.sh b/public/install-nixos.sh index 95030b55..5f6f8ce4 100755 --- a/public/install-nixos.sh +++ b/public/install-nixos.sh @@ -36,8 +36,8 @@ Usage: DEVICE The LUKS device where to install to. Use lsblk or similar tools to get it's name. Examples: - Download install-nixos.sh and run it with 'velhinho-nixos' as hostName and '/dev/sda3' as LUKS device: - wget -O- https://euandre.org/dotfiles/install-nixos.sh | sh -s velhinho-nixos /dev/sda3 + Download install-nixos.sh and run it with 'velhinho-nixos' as hostName and '/dev/sda' as disk device: + wget -O- https://euandre.org/dotfiles/install-nixos.sh | sh -s velhinho-nixos /dev/sda EOF } @@ -80,16 +80,15 @@ yellow "Moving presented content to '/etc/nixos/local-configuration.nix'..." echo mv "${TMP_DIR}/local-configuration.nix" /etc/nixos/local-configuration.nix green "Done." -yellow "Partitioning '${DEVICE}'..." -# Create a GPT partition table. -parted "${DEVICE}" -- mklabel gpt -# Add the root partition. This will fill the disk except for the end part, where the swap will live, and the space left in front (512MiB) which will be used by the boot partition. -parted "${DEVICE}" -- mkpart primary 512MiB -8GiB -# Add a swap partition of 8GiB. -parted "${DEVICE}" -- mkpart primary linux-swap -8GiB 100% -# Add the boot partition. NixOS by default uses the ESP (EFI system partition) as its /boot partition. It uses the initially reserved 512MiB at the start of the disk. -parted "${DEVICE}" -- mkpart ESP fat32 1MiB 512MiB -parted "${DEVICE}" -- set 3 boot on +yellow "Wiping '${DEVICE}'and partitioning it..." +wipefs --all --force "${DEVICE}" +sgdisk --clear "${DEVICE}" # Unclear the v +sgdisk --zap-all "${DEVICE}" # order here ^ +sgdisk --mbrtogpt "${DEVICE}" +sgdisk --new 1:2048:4095 --change-name 1:"BIOS boot partition" --typecode 1:EF02 "${DEVICE}" +sgdisk --new 2:4096:1028095 --change-name 2:"EFI System" --typecode 2:EF00 "${DEVICE}" +sgdisk --new 3:1028095:0 --change-name 3:"Linux LVM" --typecode 3:8E00 "${DEVICE}" +sgdisk --print "${DEVICE}" green "Done." yellow "Configuring LUKS encryption on '${DEVICE}3'..." -- cgit v1.3