我在尝试自动创建 Debian VM 模板时遇到了问题。我尝试使用 lvm 创建特定的磁盘分区,一切正常。但启动后,我发现我的机器上有多个不需要的分区。
# Disk Partitioning
# Use LVM, and wipe out anything that already exists
d-i partman-auto/disk string /dev/sda /dev/sdb /dev/sdc
# The presently available methods are: "regular", "lvm" and "crypto"
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string 100%
d-i partman-auto/expert_recipe string \
custom :: \
100 300 500 ext3 \
$primary{ } \
$bootable{ } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext3 } \
mountpoint{ /boot } . \
100 10000 1000000000 lvm \
$primary{ } \
$defaultignore{ } \
method{ lvm } \
device{ /dev/sdb } \
vg_name{ rootvg } . \
100 3000 5000 ext4 \
$lvmok{ } \
in_vg{ rootvg } \
lv_name{ root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
mountpoint{ / } . \
1024 1024 100% linux-swap \
$lvmok{ } \
in_vg{ rootvg } \
lv_name{ swap } \
method{ swap } \
format{ } . \
1 512 1024 ext4 \
$lvmok{ } \
in_vg{ rootvg } \
lv_name{ tmp } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
mountpoint{ /tmp } . \
1 512 1024 ext4 \
$lvmok{ } \
in_vg{ rootvg } \
lv_name{ var } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
mountpoint{ /var } . \
1 256 512 ext4 \
$lvmok{ } \
in_vg{ rootvg } \
lv_name{ home } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
mountpoint{ /home } . \
100 5000 1000000000 lvm \
$primary{ } \
$defaultignore{ } \
method{ lvm } \
device{ /dev/sdc } \
vg_name{ datavg } . \
2048 1 2048 ext4 \
$lvmok{ } \
in_vg{ datavg } \
lv_name{ opt } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
mountpoint{ /opt } . \
d-i partman-auto/choose_recipe select custom
# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/purge_lvm_from_device boolean true
# This makes partman automatically partition without confirmation.
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# Mount Partitions by UUID
d-i partman/mount_style select uuid
结果如下:
~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 400M 0 disk
├─sda1 8:1 0 132M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 265M 0 part
sdb 8:16 0 5,9G 0 disk
└─sdb1 8:17 0 5,9G 0 part
├─rootvg-root 254:0 0 3,5G 0 lvm /
├─rootvg-swap 254:1 0 976M 0 lvm [SWAP]
├─rootvg-tmp 254:3 0 596M 0 lvm /tmp
├─rootvg-var 254:4 0 596M 0 lvm /var
└─rootvg-home 254:5 0 296M 0 lvm /home
sdc 8:32 0 2,2G 0 disk
└─sdc1 8:33 0 2,2G 0 part
└─datavg-opt 254:2 0 1,9G 0 lvm /opt
sr0 11:0 1 1024M 0 rom
所以我的问题是:为什么sda2、sda5、sdb1 和 sdc1分区是如何创建的以及如何避免它?
谢谢。