1

My scenario is as follows.

I've deployed several servers, and each has generated the /var/log/installer/autoinstall-user-data. Of course, things have changed on the devices, i.e., network config and storage config.

Now, I'd like to create a new version of the autoinstall-user-data that matches the server's current config. For the network, it seems relatively straightforward to extract the current netplan config. However, is there any way to do a similar operation for the storage? i.e., extracting it in a suitable format to replace the old storage config found in the autoinstall-user-data file?

Clarification; After the initial installation, the storage config was this;

node:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0  63.3M  1 loop /snap/core20/1822
loop1    7:1    0 111.9M  1 loop /snap/lxd/24322
loop2    7:2    0  49.8M  1 loop /snap/snapd/18357
loop3    7:3    0  63.5M  1 loop /snap/core20/2015
loop4    7:4    0  40.9M  1 loop /snap/snapd/20290
sda      8:16   0 447.1G  0 disk 
├─sda1   8:17   0     1G  0 part /boot/efi
└─sda2   8:18   0   446G  0 part /

After some tinkering, post-install, the storage config looks like this;

node:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0  63.3M  1 loop /snap/core20/1822
loop1    7:1    0 111.9M  1 loop /snap/lxd/24322
loop2    7:2    0  49.8M  1 loop /snap/snapd/18357
loop3    7:3    0  63.5M  1 loop /snap/core20/2015
loop4    7:4    0  40.9M  1 loop /snap/snapd/20290
sda      8:0    0   1.8T  0 disk 
└─sda1   8:1    0   1.8T  0 part /data
sdb      8:16   0 447.1G  0 disk 
├─sdb1   8:17   0     1G  0 part /boot/efi
└─sdb2   8:18   0   446G  0 part /

Any tool/method that allows me to update the storage config in autouser-install, to match the new storage layout?

BR/Patrik

1

1 Answer 1

1

If I understand your problem correctly, you want to do an autoinstall installation where you're able to specifically define your storage config. This is easily done by configuring your storage layout in a user-data file that Subiquity and curtin will reference during installation.

As you mentioned in your question, a standard server installation generates a file called /var/log/installer/autoinstall-user-data. So as a start, you can simply copy the storage config section from this file and add it to a custom user-data file that you'll use as your autoinstall file for future installations.

For example, on a standard server installation for Ubuntu 22.04.3, here is the storage config section that is generated and shown in /var/log/installer/autoinstall-user-data.

  storage:
    config:
    - ptable: gpt
      serial: VBOX_HARDDISK_VB33ff5bd3-8d67f93f
      path: /dev/sda
      wipe: superblock-recursive
      preserve: false
      name: ''
      grub_device: true
      type: disk
      id: disk-sda
    - device: disk-sda
      size: 1048576
      flag: bios_grub
      number: 1
      preserve: false
      grub_device: false
      offset: 1048576
      path: /dev/sda1
      type: partition
      id: partition-0
    - device: disk-sda
      size: 2147483648
      wipe: superblock
      number: 2
      preserve: false
      grub_device: false
      offset: 2097152
      path: /dev/sda2
      type: partition
      id: partition-1
    - fstype: ext4
      volume: partition-1
      preserve: false
      type: format
      id: format-0
    - device: disk-sda
      size: 24692916224
      wipe: superblock
      number: 3
      preserve: false
      grub_device: false
      offset: 2149580800
      path: /dev/sda3
      type: partition
      id: partition-2
    - name: ubuntu-vg
      devices:
      - partition-2
      preserve: false
      type: lvm_volgroup
      id: lvm_volgroup-0
    - name: ubuntu-lv
      volgroup: lvm_volgroup-0
      size: 12343836672B
      wipe: superblock
      preserve: false
      path: /dev/ubuntu-vg/ubuntu-lv
      type: lvm_partition
      id: lvm_partition-0
    - fstype: ext4
      volume: lvm_partition-0
      preserve: false
      type: format
      id: format-1
    - path: /
      device: format-1
      type: mount
      id: mount-1
    - path: /boot
      device: format-0
      type: mount
      id: mount-0

This generated a storage layout on /dev/sda with LVM as follows:

$ lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0                       7:0    0  63.4M  1 loop /snap/core20/1974
loop1                       7:1    0  53.3M  1 loop /snap/snapd/19457
loop2                       7:2    0 111.9M  1 loop /snap/lxd/24322
sda                         8:0    0    25G  0 disk 
├─sda1                      8:1    0     1M  0 part 
├─sda2                      8:2    0     2G  0 part /boot
└─sda3                      8:3    0    23G  0 part 
  └─ubuntu--vg-ubuntu--lv 253:0    0  11.5G  0 lvm  /
sr0                        11:0    1  1024M  0 rom  

To use this standard storage configuration in an autoinstall installation, create a user-data file as follows. Take note, however, that I removed a few unnecessary keys such as serial and path that fall under various device top-level keys. Additionally, the autoinstall and identity keys are required, as is the first commented line, #cloud-config. This config defines a default user of ubuntu and password of ubuntu, which is hashed. A different password can be created with mkpasswd --method=SHA-512 --rounds=4096. Change accordingly.

#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: ubuntu-server
    password: $6$5lpwCLsKLEzMkSJc$keOAhA6aO/5RocGThmhVA7LSNuW911Rx5HHXFEa75oGK20cEdAAgn14H5f5nGeq6QgcSyLPrWcg1.JvjXbhrN/
    realname: Ubuntu User
    username: ubuntu
  storage:
    config:
    - ptable: gpt
      wipe: superblock-recursive
      preserve: false
      name: ''
      grub_device: true
      type: disk
      id: disk-sda
    - device: disk-sda
      size: 1048576
      flag: bios_grub
      number: 1
      preserve: false
      grub_device: false
      offset: 1048576
      type: partition
      id: partition-0
    - device: disk-sda
      size: 2147483648
      wipe: superblock
      number: 2
      preserve: false
      grub_device: false
      offset: 2097152
      type: partition
      id: partition-1
    - fstype: ext4
      volume: partition-1
      preserve: false
      type: format
      id: format-0
    - device: disk-sda
      size: 24692916224
      wipe: superblock
      number: 3
      preserve: false
      grub_device: false
      offset: 2149580800
      type: partition
      id: partition-2
    - name: ubuntu-vg
      devices:
      - partition-2
      preserve: false
      type: lvm_volgroup
      id: lvm_volgroup-0
    - name: ubuntu-lv
      volgroup: lvm_volgroup-0
      size: 12343836672B
      wipe: superblock
      preserve: false
      path: /dev/ubuntu-vg/ubuntu-lv
      type: lvm_partition
      id: lvm_partition-0
    - fstype: ext4
      volume: lvm_partition-0
      preserve: false
      type: format
      id: format-1
    - path: /
      device: format-1
      type: mount
      id: mount-1
    - path: /boot
      device: format-0
      type: mount
      id: mount-0

For more information on customizing the storage configuration, read the docs at Automated Server installer config file reference as well as the curtin documentation.


Documentation at Automated Server install quickstart indicates that you can utilize the user-data file in one of several ways for an installation. You can read the documentation to study yourself.

  • By providing autoinstall data over the network
  • By using another volume to provide autoinstall data

However, you can also add the custom user-data file to an ISO by unpacking the ISO file, adding the user-data file as well as a blank meta-data file, modifying grub, and then repacking the ISO. An easy way to do this is using Cubic, which I'll outline below.


Add custom user-data file to an ISO using Cubic

Run Cubic

  1. Select your working directory enter image description here

  2. Select your ISO. I'm using ubuntu-22.04.3-live-server-amd64.iso enter image description here

  3. Click Next to continue enter image description here

  4. On the next page, select the Preseed tab and upload your custom user-data file and a blank meta-data file to the preseed directory enter image description here

  5. Select the Boot tab and edit the grub.cfg file as follows: enter image description here

    You are specifically changing the 10th line to the following. Take note of the directory name where we placed the user-data and meta-data files. It is /cdrom/preseed/, which is what was already created in Cubic.

     linux   /casper/vmlinuz  autoinstall ds=nocloud\;s=/cdrom/preseed/ ---
    

    Here is the entire grub.cfg file:

     set timeout=30
    
     loadfont unicode
    
     set menu_color_normal=white/black
     set menu_color_highlight=black/light-gray
    
     menuentry "Try or Install Ubuntu Server" {
         set gfxpayload=keep
         linux   /casper/vmlinuz  autoinstall ds=nocloud\;s=/cdrom/preseed/ ---
         initrd  /casper/initrd.gz
     }
     menuentry "Ubuntu Server with the HWE kernel" {
         set gfxpayload=keep
         linux   /casper/vmlinuz  ---
         initrd  /casper/initrd.gz
     }
     grub_platform
     if [ "$grub_platform" = "efi" ]; then
     menuentry 'Boot from next volume' {
         exit 1
     }
     menuentry 'UEFI Firmware Settings' {
         fwsetup
     }
     else
     menuentry 'Test memory' {
         linux16 /boot/memtest86+.bin
     }
     fi
    
  6. Click Next to come to the following page. Click Generate to create your custom ISO. enter image description here

  7. When complete, you'll see this page enter image description here


After this, your custom ISO can be used for an autoinstall Ubuntu 2.04.3 Server installation.

3
  • I've added some clarifications about my case. Commented Oct 20, 2023 at 11:20
  • @PatrikArlos You have? Where? Your question has not been updated with any new info.
    – mpboden
    Commented Oct 20, 2023 at 14:04
  • :facepalm: forgot to press save, closed browser. Updated now. Commented Oct 23, 2023 at 6:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .