![自動伺服器安裝設定檔 - 如何自動安裝設定“填充磁碟”](https://rvso.com/image/1072194/%E8%87%AA%E5%8B%95%E4%BC%BA%E6%9C%8D%E5%99%A8%E5%AE%89%E8%A3%9D%E8%A8%AD%E5%AE%9A%E6%AA%94%20-%20%E5%A6%82%E4%BD%95%E8%87%AA%E5%8B%95%E5%AE%89%E8%A3%9D%E8%A8%AD%E5%AE%9A%E2%80%9C%E5%A1%AB%E5%85%85%E7%A3%81%E7%A2%9F%E2%80%9D.png)
我正在嘗試創建雲端設定檔“填充磁碟”(lvm) 有人可以檢查並告訴我問題是什麼嗎? (在 ubuntu20.4 伺服器上出現有關根磁碟區的錯誤)
#cloud-config
autoinstall:
apt:
disable_components: []
geoip: true
preserve_sources_list: false
primary:
- arches:
- amd64
- i386
uri: http://archive.ubuntu.com/ubuntu
- arches:
- default
uri: http://ports.ubuntu.com/ubuntu-ports
identity:
hostname: ubuntu-test
password: $6$XhlhJBcl/bxTQcSDA$BLAJBLAatDUh53b/BOEk1.c38CvU4XdlYjeltLav8EGcjpth/or5N33tLye6Og4TESYHFVr7MQaVGUn1tz2o67/Mm/
realname: scadmin
username: scadmin
kernel:
package: linux-generic
keyboard:
layout: us
toggle: null
variant: ''
locale: en_US.UTF-8
network:
ethernets:
ens160:
dhcp4: true
version: 2
ssh:
allow-pw: true
authorized-keys: []
install-server: true
storage:
config:
- ptable: gpt
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
type: partition
id: partition-0
- device: disk-sda
size: -1
wipe: superblock
flag: ''
number: 2
preserve: false
grub_device: false
type: partition
id: partition-1
- name: vg0
devices:
- partition-1
preserve: false
type: lvm_volgroup
id: lvm_volgroup-0
- name: lv-root
volgroup: lvm_volgroup-0
size: -1
wipe: superblock
preserve: false
type: lvm_partition
id: lvm_partition-0
- name: lv-swap
volgroup: lvm_volgroup-0
size: 4290772992B
wipe: superblock
preserve: false
type: lvm_partition
id: lvm_partition-1
- fstype: ext4
volume: lvm_partition-0
preserve: false
type: format
id: format-2
- path: /
device: format-2
type: mount
id: mount-2
- fstype: swap
volume: lvm_partition-1
preserve: false
type: format
id: format-3
- path: ''
device: format-3
type: mount
id: mount-3
swap:
swap: 0
updates: security
version: 1
答案1
首先透過重新排列儲存配置條目來建立交換邏輯磁碟區。
您建立一個將使用所有空間的根邏輯磁碟區。
- name: lv-root
volgroup: lvm_volgroup-0
size: -1
wipe: superblock
preserve: false
type: lvm_partition
id: lvm_partition-0
然後您建立交換邏輯磁碟區。
- name: lv-swap
volgroup: lvm_volgroup-0
size: 4290772992B
wipe: superblock
preserve: false
type: lvm_partition
id: lvm_partition-1
安裝程式不喜歡這樣。我收到此錯誤日誌(使用 22.04 安裝程式)。
LVM_LogicalVolume(name='lv-root', volgroup=lvm_volgroup-0, size=-1, wipe='superblock', type='lvm_partition', id='lvm_partition-0') has negative size but is not final partition of LVM_VolGroup(name='vg0', devices=[partition-1], type='lvm_volgroup', id='lvm_volgroup-0')
答案2
preserve: false
grub_device: false
type: partition
id: partition-3
- fstype: ext4
volume: partition-3
preserve: false
type: format
id: format-0
- name: lv-swap
volgroup: lvm_volgroup-0
size: 4294967296B
wipe: superblock
preserve: false
type: lvm_partition
id: lvm_partition-0
- name: lv-root
volgroup: lvm_volgroup-0
size: 25765609472B
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: /
device: format-3
type: mount
id: mount-3
- fstype: swap
volume: lvm_partition-0
preserve: false
type: format
id: format-4
- path: ''
device: format-4
type: mount
id: mount-4
- path: /boot
device: format-0
type: mount
id: mount-0