diff options
author | zsdc <taras@vyos.io> | 2021-01-23 23:41:52 +0200 |
---|---|---|
committer | zsdc <taras@vyos.io> | 2021-03-15 19:48:41 +0200 |
commit | 1d711c0159a7b8abbc7c801f9b4b2ff08a615317 (patch) | |
tree | 0084503c95db4791f420a7464ac781d5aacf3062 /roles/setup-root-partition | |
parent | 430392dc3e8385567f97f56c8107130968709227 (diff) | |
download | vyos-vm-images-1d711c0159a7b8abbc7c801f9b4b2ff08a615317.tar.gz vyos-vm-images-1d711c0159a7b8abbc7c801f9b4b2ff08a615317.zip |
Added partition table type select option (MBR/GPT/hybrid)
Since some of the build target platforms do not support hybrid partition table and require only MBR (AWS AMI), was added option that allows selecting a partition table type:
```
-e parrtable_type=type
```
where `type` can be one of: `mbr`, `gpt`, `hybrid`.
Default value is `hybrid`.
Diffstat (limited to 'roles/setup-root-partition')
-rw-r--r-- | roles/setup-root-partition/tasks/main.yml | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/roles/setup-root-partition/tasks/main.yml b/roles/setup-root-partition/tasks/main.yml index 57ba5ae..bf183f3 100644 --- a/roles/setup-root-partition/tasks/main.yml +++ b/roles/setup-root-partition/tasks/main.yml @@ -1,7 +1,38 @@ -- name: Partition disk +- name: Partition disk (MBR) + become: true + command: + cmd: "sfdisk -q -X dos {{ vyos_raw_img }}" + stdin: "3,+,L,*" + when: vyos_parttable_type == "mbr" + +- name: Partition disk (GPT) + become: true + command: + cmd: "sgdisk -a1 -n1:34:+256M -t1:EF00 -n2:0:0:+100% -t2:8300 {{ vyos_raw_img }}" + when: vyos_parttable_type == "gpt" + +- name: Partition disk (hybrid) become: true command: cmd: "sgdisk -a1 -n1:34:2047 -t1:EF02 -n2:2048:+256M -t2:EF00 -n3:0:0:+100% -t3:8300 {{ vyos_raw_img }}" + when: vyos_parttable_type == "hybrid" + +- name: Set partition numbers for next actions (MBR) + set_fact: + partition_num_root: 1 + when: vyos_parttable_type == "mbr" + +- name: Set partition numbers for next actions (GPT) + set_fact: + partition_num_efi: 1 + partition_num_root: 2 + when: vyos_parttable_type == "gpt" + +- name: Set partition numbers for next actions (hybrid) + set_fact: + partition_num_efi: 2 + partition_num_root: 3 + when: vyos_parttable_type == "hybrid" - name: Reread partitions from image and mount to loopback become: true @@ -21,20 +52,21 @@ become: true filesystem: fstype: "vfat" - device: "{{ vyos_target_drive }}p2" + device: "{{ vyos_target_drive }}p{{ partition_num_efi }}" opts: "-n EFI -F 32 -s 1" - + when: partition_num_efi is defined + - name: Create a fileystem on root partition become: true filesystem: fstype: "{{ vyos_root_fstype }}" - device: "{{ vyos_target_drive }}p3" + device: "{{ vyos_target_drive }}p{{ partition_num_root }}" opts: "-L persistence" - name: Mount root partition become: true mount: name: "{{ vyos_write_root }}" - src: "{{ vyos_target_drive }}p3" + src: "{{ vyos_target_drive }}p{{ partition_num_root }}" fstype: "{{ vyos_root_fstype }}" state: mounted |