我在计算机上使用了 PXE 安装,用户数据中的相关参数如下:
storage:
layout:
name: lvm
match:
ssd: yes
这意味着 SSD(机器仅包含一个)应该自动格式化和分区。
安装完成后分区信息和我预期的一样
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
但可用空间只有应有的一半。此外还有奇怪的额外安装
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 /
我该如何设置自动安装程序参数才能使用全部 118.2G?
提前致谢。
[解决方法]
如果您将其替换name: lvm
为,name: direct
我将获得全部容量,但显然 LVM 不起作用。机器似乎也没有单独的启动分区:
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 /
我更愿意使用 LVM 来获得全部容量。
[/解决方法]
[使用 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>
用户数据:
#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
[/使用 LVM 配置]
[手动调整大小]
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!
[/手动调整大小]
答案1
这是我使用过的存储配置。它将创建一个布局
- 1MB bios_grub
- 1GB /boot 分区
- 100% 的剩余空间被 LVM 用于根逻辑卷
根据您在原始问题中的输出,我相信您正在基于 BIOS 的机器上进行安装。我从我的完整 BIOS 自动安装示例中获取了此配置部分https://askubuntu.com/a/1240068/376778
我还没有实际测试过storage
使用该match
选项进行配置。磁盘选择扩展部分建议这应该可行: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}