我正在使用 Ubuntu 20.40,在其中创建一个包含映像上的用户数据/元数据的 ISO,然后从中启动 VMware VM。我观察了输出,它似乎创建了逻辑卷和挂载点;它安装了软件、我配置的用户、更新等,但每次我得到的都是一个我没有要求的文件系统。我已将其通过 YAML 验证器,使用 cloud-init 对其进行了验证,并将其与其他配置进行了比较,但我无法找出问题所在。
我将其精简到只剩下最基本的部分,但它仍然做同样的事情。以下是用户数据(已清理):
#cloud-config autoinstall: version: 1 # Reboot doesn't work shutdown: reboot apt:
geoip: true
preserve_sources_list: false
primary:
- arches: [amd64]
uri: http://mirror.domain.com/ubuntu
- arches: [default]
uri: http://mirror.domain.com/ubuntu-ports keyboard: {layout: us, toggle: null, variant: ''} locale: en_US user-data:
disable_root: false
users:
- default
- name: username
gecos: Gecos Name
ssh-authorized-keys:
- ssh-ed25519 OMITTED
passwd: OMITTED
lock_passwd: false
shell: /bin/bash
groups: adm, sudo, root
sudo: ALL=(ALL) NOPASSWD:ALL packages: [openssh-server, build-essential, htop, chrony, vim, clevis, clevis-luks,
dracut-network, oddjob, oddjob-mkhomedir, cups-client, yp-tools, postfix, libopenscap8,
aide, crypto-policies, firefox, perl, git, build-essential] ssh:
allow-pw: true
authorized-keys: []
install-server: true storage: grub:
reorder_uefi: false
config:
- {ptable: gpt, path: /dev/sda, wipe: superblock, preserve: false, name: '', grub_device: true,
type: disk, id: disk-sda}
- {device: disk-sda, size: 5M, flag: bios_grub, number: 1, preserve: false,
type: partition, id: partition-0}
- {device: disk-sda, size: 1G, flag: '', number: 2, preserve: false, type: partition, id: partition-1}
- {fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-1}
- {device: disk-sda, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id:
partition-2 }
- {name: system, devices: [ partition-2 ], preserve: false, type: lvm_volgroup, id: lvm_volgroup-0 }
- {name: root, volgroup: lvm_volgroup-0, size: 70G, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-0}
- {fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: format-2}
- {path: /, device: format-2, type: mount, id: mount-2}
- {name: tmp, volgroup: lvm_volgroup-0, size: 15G, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-1}
- {fstype: ext4, volume: lvm_partition-1, preserve: false, type: format, id: format-3}
- {path: /tmp, device: format-3, type: mount, id: mount-3}
- {name: var, volgroup: lvm_volgroup-0, size: 15G, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-2}
- {fstype: ext4, volume: lvm_partition-2, preserve: false, type: format, id: format-4}
- {path: /var, device: format-4, type: mount, id: mount-4}
- {name: varlogaudit, volgroup: lvm_volgroup-0, size: 15G, wipe: superblock, preserve: false, type: lvm_partition, id: lvm_partition-3}
- {fstype: ext4, volume: lvm_partition-3, preserve: false, type: format, id: format-5}
- {path: /var/log/audit, device: format-5, type: mount, id: mount-5}
完成后,我重新启动虚拟机,文件系统如下所示。磁盘空间充足(250GB)且 RAM 为 10GB。资源不是问题。cloud-init 日志没有告诉我任何明显的信息(其中有很多):
Filesystem Size Used Avail Use% Mounted on
udev 4.9G 0 4.9G 0% /dev
tmpfs 995M 1.2M 994M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 122G 7.0G 109G 6% /
tmpfs 4.9G 0 4.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 4.9G 0 4.9G 0% /sys/fs/cgroup
/dev/sda2 974M 111M 796M 13% /boot
/dev/loop1 70M 70M 0 100% /snap/lxd/19188
/dev/loop2 32M 32M 0 100% /snap/snapd/10707
/dev/loop0 56M 56M 0 100% /snap/core18/1944
tmpfs 995M 0 995M 0% /run/user/1000
我看不出这里出了什么问题。
谢谢!
答案1
这是我的存储>配置部分
storage:
config:
#DEVICE
- {ptable: gpt, path: /dev/xvda, wipe: superblock, preserve: false, name: '', grub_device: true, type: disk, id: disk-sda}
#PARTITION 0: GRUB 1048576 bytes = 1 MB
- {device: disk-sda, size: 1048576, flag: bios_grub, number: 1, preserve: false,
grub_device: false, type: partition, id: partition-0}
#PARTITION 1 /BOOT PARTITION : 1073741824 bytes = 1GB
- {device: disk-sda, size: 1073741824, wipe: superblock, flag: '', number: 2,
preserve: false, grub_device: false, type: partition, id: partition-1}
- {fstype: ext4, volume: partition-1, preserve: false, type: format, id: format-0}
- {path: /boot, device: format-0, type: mount, id: mount-0}
#PARTITION 2 / VOLUME GROUP
- {device: disk-sda, size: -1, wipe: superblock, flag: '', number: 3, preserve: false, grub_device: false, type: partition, id: partition-2}
- name: ubuntu-vg
devices: [partition-2]
preserve: false
type: lvm_volgroup
id: lvm_volgroup-0
#/ROOT
- {name: ubuntu-lv-root, volgroup: lvm_volgroup-0, size: 20%, wipe: superblock,preserve: false, type: lvm_partition, id: lvm_partition-0}
- {fstype: ext4, volume: lvm_partition-0, preserve: false, type: format, id: lvmformat-0}
- {path: /, device: lvmformat-0, type: mount, id: lvmmount-0}
#/HOME
- {name: ubuntu-lv-home, volgroup: lvm_volgroup-0, size: 1073741824, wipe: superblock,preserve: false, type: lvm_partition, id: lvm_partition-1}
- {fstype: ext4, volume: lvm_partition-1, preserve: false, type: format, id: lvmformat-1}
- {path: /home, device: lvmformat-1, type: mount, id: lvmmount-1}
#/TMP
- {name: ubuntu-lv-tmp, volgroup: lvm_volgroup-0, size: 1073741824, wipe: superblock,preserve: false, type: lvm_partition, id: lvm_partition-2}
- {fstype: ext4, volume: lvm_partition-2, preserve: false, type: format, id: lvmformat-2}
- {path: /tmp, device: lvmformat-2, type: mount, id: lvmmount-2}
#/VAR/LOG/AUDIT
- {name: ubuntu-lv-audit, volgroup: lvm_volgroup-0, size: 1073741824, wipe: superblock,preserve: false, type: lvm_partition, id: lvm_partition-3}
- {fstype: ext4, volume: lvm_partition-3, preserve: false, type: format, id: lvmformat-3}
- {path: /var/log/audit, device: lvmformat-3, type: mount, id: lvmmount-3}
#/VAR/LOG
- {name: ubuntu-lv-log, volgroup: lvm_volgroup-0, size: 1073741824, wipe: superblock,preserve: false, type: lvm_partition, id: lvm_partition-4}
- {fstype: ext4, volume: lvm_partition-4, preserve: false, type: format, id: lvmformat-4}
- {path: /var/log, device: lvmformat-4, type: mount, id: lvmmount-4}
#/VAR/TMP
- {name: ubuntu-lv-vtmp, volgroup: lvm_volgroup-0, size: 1073741824, wipe: superblock,preserve: false, type: lvm_partition, id: lvm_partition-5}
- {fstype: ext4, volume: lvm_partition-5, preserve: false, type: format, id: lvmformat-5}
- {path: /var/tmp, device: lvmformat-5, type: mount, id: lvmmount-5}
#SWAP
- {name: ubuntu-lv-swap, volgroup: lvm_volgroup-0, size: 2147483648, wipe: superblock,preserve: false, type: lvm_partition, id: lvm_partition-6}
- {fstype: swap, volume: lvm_partition-6, preserve: false, type: format, id: lvmformat-6}
#/VAR
- {name: ubuntu-lv-var, volgroup: lvm_volgroup-0, wipe: superblock,preserve: false, type: lvm_partition, id: lvm_partition-7}
- {fstype: ext4, volume: lvm_partition-7, preserve: false, type: format, id: lvmformat-7}
- {path: /var, device: lvmformat-7, type: mount, id: lvmmount-7}
上述配置将创建以下存储布局
xvda 20G
├─xvda1 1M
├─xvda2 ext4 1G /boot
└─xvda3 LVM2_member 19G
├─ubuntu--vg-ubuntu--lv--root ext4 3.8G /
├─ubuntu--vg-ubuntu--lv--home ext4 1G /home
├─ubuntu--vg-ubuntu--lv--tmp ext4 1G /tmp
├─ubuntu--vg-ubuntu--lv--audit ext4 1G /var/log/audit
├─ubuntu--vg-ubuntu--lv--log ext4 1G /var/log
├─ubuntu--vg-ubuntu--lv--vtmp ext4 1G /var/tmp
├─ubuntu--vg-ubuntu--lv--swap swap 2G
└─ubuntu--vg-ubuntu--lv--var ext4 8.2G /var
我故意删除了“var”部分中的“size”参数。文档指出我们可以输入 -1 来填充剩余空间,但在我的情况下不起作用,缺少大约 2 个字节。
我没有找到足够的信息,所以我希望它能够帮助遇到同样问题的人。