···28 # partition of reasonable size is created in addition to the root partition.
29 # For "legacy", the msdos partition table is used and a single large root
30 # partition is created.
00031 # For "hybrid", the GPT partition table is used and a mandatory ESP
32 # partition of reasonable size is created in addition to the root partition.
33 # Also a legacy MBR will be present.
···54 format ? "raw"
55}:
5657-assert partitionTableType == "legacy" || partitionTableType == "efi" || partitionTableType == "hybrid" || partitionTableType == "none";
58# We use -E offset=X below, which is only supported by e2fsprogs
59assert partitionTableType != "none" -> fsType == "ext4";
60···7576 rootPartition = { # switch-case
77 legacy = "1";
078 efi = "2";
79 hybrid = "3";
80 }.${partitionTableType};
···84 parted --script $diskImage -- \
85 mklabel msdos \
86 mkpart primary ext4 1MiB -1
000000000087 '';
88 efi = ''
89 parted --script $diskImage -- \
···28 # partition of reasonable size is created in addition to the root partition.
29 # For "legacy", the msdos partition table is used and a single large root
30 # partition is created.
31+ # For "legacy+gpt", the GPT partition table is used, a 1MiB no-fs partition for
32+ # use by the bootloader is created, and a single large root partition is
33+ # created.
34 # For "hybrid", the GPT partition table is used and a mandatory ESP
35 # partition of reasonable size is created in addition to the root partition.
36 # Also a legacy MBR will be present.
···57 format ? "raw"
58}:
5960+assert partitionTableType == "legacy" || partitionTableType == "legacy+gpt" || partitionTableType == "efi" || partitionTableType == "hybrid" || partitionTableType == "none";
61# We use -E offset=X below, which is only supported by e2fsprogs
62assert partitionTableType != "none" -> fsType == "ext4";
63···7879 rootPartition = { # switch-case
80 legacy = "1";
81+ "legacy+gpt" = "2";
82 efi = "2";
83 hybrid = "3";
84 }.${partitionTableType};
···88 parted --script $diskImage -- \
89 mklabel msdos \
90 mkpart primary ext4 1MiB -1
91+ '';
92+ "legacy+gpt" = ''
93+ parted --script $diskImage -- \
94+ mklabel gpt \
95+ mkpart no-fs 1MB 2MB \
96+ set 1 bios_grub on \
97+ align-check optimal 1 \
98+ mkpart primary ext4 2MB -1 \
99+ align-check optimal 2 \
100+ print
101 '';
102 efi = ''
103 parted --script $diskImage -- \
+1-1
nixos/maintainers/scripts/ec2/amazon-image.nix
···57 inherit (cfg) contents format name;
58 pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
59 partitionTableType = if config.ec2.efi then "efi"
60- else if config.ec2.hvm then "legacy"
61 else "none";
62 diskSize = cfg.sizeMB;
63 fsType = "ext4";
···57 inherit (cfg) contents format name;
58 pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
59 partitionTableType = if config.ec2.efi then "efi"
60+ else if config.ec2.hvm then "legacy+gpt"
61 else "none";
62 diskSize = cfg.sizeMB;
63 fsType = "ext4";