0

I am trying to install ubuntu 22.04 iso from disk, stored at partition /dev/sda3 mounted at /ota. Following is my current disk layout in RHEL.

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 59.6G  0 disk 
├─sda1   8:1    0    1M  0 part 
├─sda2   8:2    0   10G  0 part /
├─sda3   8:3    0  5.1G  0 part /ota
├─sda4   8:4    0    5G  0 part /tmp
├─sda5   8:5    0    2G  0 part [SWAP]
├─sda6   8:6    0 37.5G  0 part /data
└─sda7   8:7    0   74M  0 part /boot/efi

I have written an autoinstall script which works fine when booted via pendrive.

#cloud-config
autoinstall:
  version: 1
  locale: en_US.UTF-8
  keyboard:
    layout: us
    variant: ""
  user-data:
    timezone: UTC
    hostname: ubuntu
    users:
      - name: ubuntu
        passwd: "abcd"  # Replace this with the hashed root password
        lock-passwd: false
        groups: [ sudo,wheel,lock,dialout,video,kiosk_svcs,danbo]
        shell: /bin/bash
  network:
    version: 2
    renderer: networkd
    ethernets:
      enp1s0:
        dhcp4: true
      enp2s0:
        dhcp4: no
        addresses: [ 192.168.2.1/24 ]
  storage:
    config:
      - ptable: gpt
        path: /dev/sda
        wipe: superblock-recursive
        preserve: false
        name: ''
        # Adding a placeholder in Disk command. This will be replaced with true/false according to boot method.
        grub_device: BIOS_ENABLED
        id: disk-sda
        type: disk
        # BIOS boot partition
      - device: disk-sda
        size: 4194304
        wipe: superblock
        number: 1
        preserve: false
        id: bios-boot
        type: partition
        flag: bios_grub
        # EFI System Partition (ESP)
      - device: disk-sda
        size: 5476188160
        wipe: superblock
        flag: boot
        number: 2
        preserve: false
        # Adding a placeholder in ESP. Follow: https://askubuntu.com/questions/1487504/ubuntu-22-04-autoinstall-works-on-uefi-but-not-mbr-in-virtualbox
        # During installation, we will check the boot mode and accordingly set this field.
        grub_device: UEFI_ENABLED
        id: partition-0
        type: partition
      - fstype: fat32
        volume: partition-0
        preserve: false
        id: format-0
        type: format
      - path: /boot/efi
        device: format-0
        id: mount-0
        type: mount
      - device: disk-sda
        size: 5478809600
        wipe: superblock
        number: 3
        preserve: false
        grub_device: false
        id: partition-1
        type: partition
      - fstype: ext4
        volume: partition-1
        preserve: false
        id: format-1
        type: format
      - path: /ota
        device: format-1
        id: mount-2
        type: mount
      - device: disk-sda
        size: 5476188160
        wipe: superblock
        number: 4
        preserve: false
        grub_device: false
        id: partition-2
        type: partition
      - fstype: ext4
        volume: partition-2
        preserve: false
        id: format-2
        type: format
      - path: /boot
        device: format-2
        id: mount-3
        type: mount
  - device: disk-sda
    size: -1
    wipe: superblock
    number: 5         # When changing this, please make sure to update disk_encrypt.sh as well
    preserve: false
    grub_device: false
    id: partition-3
    type: partition
  - volume: partition-3
    key: 'abcd'
    preserve: false
    id: dm_crypt-0
    type: dm_crypt
  - name: ubuntu-vg
    devices: [ dm_crypt-0 ]
    preserve: false
    type: lvm_volgroup
    id: lvm_volgroup-0
  - { name: swap, volgroup: lvm_volgroup-0, size: 1G, preserve: false, type: lvm_partition, id: lvm_partition-0 }
  - { fstype: swap, volume: lvm_partition-0, preserve: false, type: format, id: format-4 }
  - { name: ubuntu-lv, volgroup: lvm_volgroup-0, size: -1, preserve: false,type: lvm_partition, id: lvm_partition-1 }
  - { fstype: ext4, volume: lvm_partition-1, preserve: false, type: format, id: format-3 }
  - path: /
    device: format-3
    id: mount-1
    type: mount

Beware of file-name /autoinstall.yaml. During the live installation, the installer (subiquity) takes your provided

user-data (which includes your autoinstall configuration) and merges it with its own default answers for any questions

that you haven't explicitly configured. The result is a generated file (often named autoinstall.yaml) that resides

in the root directory of the live environment. This final YAML file is what the installer uses to drive the installation process.

early-commands: - | # Check if the system booted in UEFI, then change the grub_device flag to true for ESP, else false if [ -e "/sys/firmware/efi" ]; then sed -i -e "s/grub_device: UEFI_ENABLED/grub_device: true/" /autoinstall.yaml sed -i -e "s/grub_device: BIOS_ENABLED/grub_device: false/" /autoinstall.yaml echo "Updated grub_device to true for UEFI" else sed -i -e "s/grub_device: UEFI_ENABLED/grub_device: false/" /autoinstall.yaml sed -i -e "s/grub_device: BIOS_ENABLED/grub_device: true/" /autoinstall.yaml echo "Updated grub_device to false for UEFI" fi true late-commands: - # some commands shutdown: 'reboot' # Perform reboot once installation completes

I want to retain /dev/sda3 content after installation as I have matched the size, filetype, everything.

  • Is it even possible to perform auto install from disk when we are changing disk layout?
  • Is there a way to achieve this?

I followed curtin storage doc - https://curtin.readthedocs.io/en/latest/topics/storage.html and tried changing preserve flag on /dev/sda3 but that doesn't seems to work

0 Answers0