0

I used a PXE install on a computer with the following relevant parameters in user-data:

  storage:
    layout:
      name: lvm
      match:
        ssd: yes

meaning the SSD (machine only contains one) should be formatted and partitioned automatically.

After the installation finishes the partition information is as I expected

sudo partx -s /dev/sda
NR   START       END   SECTORS   SIZE NAME UUID
 1    2048      4095      2048     1M      c22ce821-a730-4ba4-9992-3014acb4c332
 2    4096   2101247   2097152     1G      24379366-30d3-4967-b9d7-31a42ea2043d
 3 2101248 250066943 247965696 118.2G      d15a6cd2-b73e-427b-b7ea-0d99f6c6fce5

Yet free space is only about half what it should be. Also their are weird extra mounts

 sudo lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0                       7:0    0  29.9M  1 loop /snap/snapd/8790
loop1                       7:1    0  55.3M  1 loop /snap/core18/1885
loop2                       7:2    0  71.5M  1 loop /snap/lxd/16740
sda                         8:0    0 119.2G  0 disk
├─sda1                      8:1    0     1M  0 part
├─sda2                      8:2    0     1G  0 part /boot
└─sda3                      8:3    0 118.2G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0  59.1G  0 lvm  /

How can I set the auto installer parameters that I have the whole 118.2G available?

Thanks in advance.

[Workaround]

If you replace name: lvmwith name: directI get the full capacity but then obviousl LVM is not working. The Machine also then does not seem to have a separate boot partition:

sudo lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0  29.9M  1 loop /snap/snapd/8790
loop1    7:1    0  55.3M  1 loop /snap/core18/1885
loop2    7:2    0  71.5M  1 loop /snap/lxd/16740
sda      8:0    0 119.2G  0 disk
├─sda1   8:1    0     1M  0 part
└─sda2   8:2    0 119.2G  0 part /

I would prefer to have the full capacity available with LVM.

[/Workaround]

[Config with LVM]

pxelinux.cfg:

DEFAULT install
LABEL install
  KERNEL vmlinuz
  INITRD initrd
  APPEND root=/dev/ram0 ramdisk_size=1500000 ip=dhcp url=http://10.2.1.20/efi_focal/ubuntu-20.04.1-live-server-amd64.iso autoinstall net.ifnames=0 biosdevname=0 ip=dhcp ipv6.disa>

user-data:

#cloud-config
autoinstall:
  version: 1
  early-commands:
    - systemctl stop ssh # otherwise packer tries to connect and exceed max attempts
  network:
    network:
      version: 2
      ethernets:
        eth0:
          dhcp4: yes
          dhcp-identifier: mac
          optional: true
        eth1:
          dhcp4: yes
          dhcp-identifier: mac
          optional: true
        eth2:
          dhcp4: yes
          dhcp-identifier: mac
          optional: true
        eth3:
          dhcp4: yes
          dhcp-identifier: mac
          optional: true
        eth4:
          dhcp4: yes
          dhcp-identifier: mac
          optional: true
        eth5:
          dhcp4: yes
          dhcp-identifier: mac
          optional: true
  locale: en_US
  keyboard:
    layout: de
  apt:
    http_proxy: http://10.2.1.1:8080/
    https_proxy: http://10.2.1.1:8080/
    preserve_sources_list: false
    primary:
      - arches: [amd64]
        uri: "http://archive.ubuntu.com/ubuntu/"
  storage:
    layout:
      name: lvm
      match:
        ssd: yes
  ssh:
    install-server: yes
    allow-pw: yes
  identity:
    hostname: decosrv02
    password: Hash of the PW
    username: ipc 
  packages:
    - net-tools
    - docker
    - docker-compose
  user-data:
    idisable_root: false
  late-commands:
    - echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu
    - sed -ie 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="net.ifnames=0 ipv6.disable=1 biosdevname=0"/' /target/etc/default/grub
    - curtin in-target --target /target update-grub2
    - apt-get update && apt-get upgrade -y

[/Config with LVM]

[resize by hand]

ipc@decosrv02:~$ sudo lvextend -l 100%FREE ubuntu--vg-ubuntu--lv
  Please specify a logical volume path.

ipc@decosrv02:~$ sudo lvextend -l 100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  New size given (15134 extents) not larger than existing size (15135 extents)

ipc@decosrv02:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.45.5 (07-Jan-2020)
The filesystem is already 15498240 (4k) blocks long.  Nothing to do!

[/resize by hand]

4
  • I have found a workaround and edited the question accordingly. – Michael Oct 1 '20 at 14:18
  • You don't have to use the layout setting. You can configure the storage section explicitly. This would allow you to configure partitions, volume groups, and logical volumes. With logical volumes you can specify 100% as a size – Andrew Lowther Oct 1 '20 at 15:19
  • @AndrewLowther I discovered that via the IRC chat I had with the cloud-init folks, and have an example config I'm working on converting to an answer. Is a headache though because you have to sort of do a from-scratch disk config from disk partition table to the filesystems - and that isn't immediately clear to many (nor myself even after pouring through Curtin docs) – Thomas Ward Oct 2 '20 at 14:06
  • I'll post the config I've used as an answer. It might be a useful example. – Andrew Lowther Oct 2 '20 at 20:23
0

This is a storage configuration I've used. It will create a layout of

  • 1MB bios_grub
  • 1GB /boot partition
  • 100% of remaining space is used by LVM for a root logical volume

Based on your output in the original question I believe you are installing on a BIOS based machine. I took this config section from my full BIOS autoinstall example at https://askubuntu.com/a/1240068/376778

I haven't actually tested configuring storage using the match option. The Disk selection extensions section suggests this should work: https://ubuntu.com/server/docs/install/autoinstall-reference

  storage:
    config:
    - {ptable: gpt, match: {ssd: yes}, wipe: superblock, preserve: false, name: '', grub_device: true,
      type: disk, id: disk-sda}
    - {device: disk-sda, size: 1048576, flag: bios_grub, number: 1, preserve: false,
      type: partition, id: partition-0}
    - {device: disk-sda, size: 1073741824, wipe: superblock, flag: '', number: 2,
      preserve: false, type: partition, id: partition-1}
    - {fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-0}
    - {device: disk-sda, size: -1, wipe: superblock, flag: '', number: 3,
      preserve: false, 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: 100%, preserve: false,
      type: lvm_partition, id: lvm_partition-0}
    - {fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-1}
    - {device: format-1, path: /, type: mount, id: mount-1}
    - {device: format-0, path: /boot, type: mount, id: mount-0}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.