Debian 13: automatická instalace s LVM

ZAJDAN

  • *****
  • 2 100
    • Zobrazit profil
    • E-mail
Debian 13: automatická instalace s LVM
« kdy: 21. 12. 2025, 15:31:56 »
Ahoj,
s Debian 13 testuji Automated installation s preseed konfigurací.
Bojuju s tím, že se neaplikuje nakonfigurovaný LVM layout a podbídne se mi úplně jiný (nějaký default)
Cílem je na celém /dev/sda vytvořit LVM. Nevytvářet separátní oddíl pro boot, protože GRUB2 umí bootovat z LVM.
Uvnitř LVM oddíl pro root, swap, home

Kód: [Vybrat]
### Partitioning
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

d-i partman-auto/expert_recipe string                           \
        pvs ::                                                                 \
              20480 26000 30000 ext4                               \
                      $primary{ }                                          \
                      method{ lvm }                                      \
                      vg_name{ system }                               \
        .                                                                         \
        lv ::                                                                   \
              26000 26000 26000 ext4           \
                      $lvmok{ }                                             \
                      lv_name{ root }                                    \
                      method{ format } format{ }                  \
                      use_filesystem{ } filesystem{ ext4 }      \
                      mountpoint{ / }                                    \
                      in_vg{ system }                                    \
              .                                                                   \
              1048 1500 2048 linux-swap                            \
                      $lvmok{ }                                             \
                      lv_name{ swap }                                   \
                      method{ swap } format{ }                     \
                      in_vg{ system }                                    \
              .                                                                   \
      1048 1048 1048 ext4                                    \
                      $lvmok{ }                                             \
                      lv_name{ home }                                  \
                      method{ format } format{ }                   \
                      use_filesystem{ } filesystem{ ext4 }       \
                      mountpoint{ /home }                             \
                      in_vg{ system }                                    \
              .                                                                   \

Vesele, vesele do továrny dělník běží...vesele, vesele do továrny jde. Vesele se usmívá když mu soustruh zazpívá...vesele, vesele do továrny jde. Vesele si poskočí když se soustruh roztočí ...vesele, vesele do továrny jde.


Re:Debian 13: automatická instalace s LVM
« Odpověď #1 kdy: 21. 12. 2025, 23:17:04 »
"na celom sda LVM" - hm.

Tak ma napadá:
- To je BIOS boot, nie EFI? EFI potrebuje svoju partition.
- Grub2 (ktorý, keď už beží, vie bootovať z LVM) - odkiaľ sa načíta?

ZAJDAN

  • *****
  • 2 100
    • Zobrazit profil
    • E-mail
Re:Debian 13: automatická instalace s LVM
« Odpověď #2 kdy: 22. 12. 2025, 07:44:27 »
"na celom sda LVM" - hm.

Tak ma napadá:
- To je BIOS boot, nie EFI? EFI potrebuje svoju partition.
- Grub2 (ktorý, keď už beží, vie bootovať z LVM) - odkiaľ sa načíta?

Pokud to instaluju standarnim instalátorem, tak vytvářím na celém disku LVM a boot partition vůbec nedělám.
lsblk výstup pak vypadá takto:
Kód: [Vybrat]
NAME                             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda                                8:0    0   50G  0 disk
└─sda1                             8:1    0   50G  0 part
  ├─system-root                  254:1    0 43.8G  0 lvm  /
  ├─system-home                  254:2    0  952M  0 lvm  /home
  └─system-swap                  254:3    0  1.9G  0 lvm  [SWAP]
blkid:
Kód: [Vybrat]
/dev/sda1: UUID="EEFM3a-pUfJ-ZoLO-NeY4-yDGc-kvlh-XSyBad" TYPE="LVM2_member" PARTUUID="94f9a127-01"
/dev/mapper/system-root: UUID="1f9ab151-276d-4073-86b3-fcb682cb9ae8" BLOCK_SIZE="4096" TYPE="ext4"
/dev/mapper/system-home: UUID="610fff2c-c770-40ca-9b05-1673160549f5" BLOCK_SIZE="4096" TYPE="ext4"
/dev/mapper/system-swap: UUID="d72ef9b7-6105-4f76-a773-483b0459a7f7" TYPE="swap"

Vesele, vesele do továrny dělník běží...vesele, vesele do továrny jde. Vesele se usmívá když mu soustruh zazpívá...vesele, vesele do továrny jde. Vesele si poskočí když se soustruh roztočí ...vesele, vesele do továrny jde.

ZAJDAN

  • *****
  • 2 100
    • Zobrazit profil
    • E-mail
Re:Debian 13: automatická instalace s LVM
« Odpověď #3 kdy: 22. 12. 2025, 07:55:35 »
Teď mi dochází, že do toho preseed configu budu muset přidat efi oddíl:
Citace
Yes, GRUB2 can boot an LVM setup without a separate /boot partition in UEFI mode, but for Legacy BIOS, you typically need a small, simple partition (like FAT or ext2/3/4) for GRUB's initial stages outside LVM, especially with GPT, though GRUB2 has strong LVM support to load kernels from LVM directly once initial stages load, requiring insmod lvm in grub.cfg. The key is a small EFI System Partition (ESP) for UEFI or a BIOS Boot Partition for GPT/BIOS, as firmware/BIOS can't read LVM directly, but GRUB2 modules can once loaded from that initial partition.
Vesele, vesele do továrny dělník běží...vesele, vesele do továrny jde. Vesele se usmívá když mu soustruh zazpívá...vesele, vesele do továrny jde. Vesele si poskočí když se soustruh roztočí ...vesele, vesele do továrny jde.

ZAJDAN

  • *****
  • 2 100
    • Zobrazit profil
    • E-mail
Re:Debian 13: automatická instalace s LVM
« Odpověď #4 kdy: 22. 12. 2025, 10:29:46 »
Každopádně v debianích layoutech nemají nic bez separátní boot partition:
https://salsa.debian.org/installer-team/partman-auto/-/tree/master/recipes-amd64?ref_type=heads
Takže kdo ví, zda to přes preseed konfiguraci vůbec jde.
Manuálním způsoben ano, viz obrázek, a je vyzkoušeno, že systém naběhne jak má.
Vesele, vesele do továrny dělník běží...vesele, vesele do továrny jde. Vesele se usmívá když mu soustruh zazpívá...vesele, vesele do továrny jde. Vesele si poskočí když se soustruh roztočí ...vesele, vesele do továrny jde.


Re:Debian 13: automatická instalace s LVM
« Odpověď #5 kdy: 22. 12. 2025, 13:22:16 »
Jen poznámka bokem - my jsme boj s preseedem vzdali a místo toho bootujeme live image s automatickým scriptem (resp. více verzí), který server deboostrapuje (v dalších verzích bychom i toto chtěli optimalizovat). Vzdali jsme to hlavně kvůli tomu, že každý server měl naprosto jiné disky a nedařilo se nám preseed udělat tak, aby fungoval dobře a konzistentně všude.

Příští rok bych to chtěl celé zveřejnit jako opensource, ale je tam ještě několik nedodělků, kterým se někdo začátkem roku musí pověnovat.

Zkusím si vzpomenout a nalinkovat to sem.

ZAJDAN

  • *****
  • 2 100
    • Zobrazit profil
    • E-mail
Re:Debian 13: automatická instalace s LVM
« Odpověď #6 kdy: 22. 12. 2025, 14:31:51 »
Jen poznámka bokem - my jsme boj s preseedem vzdali...
Evidentně ten preseed nemají vyladěnej, páč jsem zkoušel i varianty, které jiným fungují a mě ne.
Vesele, vesele do továrny dělník běží...vesele, vesele do továrny jde. Vesele se usmívá když mu soustruh zazpívá...vesele, vesele do továrny jde. Vesele si poskočí když se soustruh roztočí ...vesele, vesele do továrny jde.

Re:Debian 13: automatická instalace s LVM
« Odpověď #7 kdy: Dnes v 12:49:29 »
Tohle je funkční konfigurace disku pro preseed, kterou používám já. Je to pro systém s UEFI boot:

Kód: [Vybrat]
# necessary for manual LVM:
# actually not sure what this does, removing for now
#d-i partman-auto/init_automatically_partition select Manual

# this selects the disk partman will use, it's required
d-i partman-auto/disk string /dev/sda

# this selects the method partman will use, it's required
d-i partman-auto/method string lvm

#d-i partman-auto/init_automatically_partition select custom

# You can define the amount of space that will be used for the LVM volume
# group. It can either be a size with its unit (eg. 20 GB), a percentage of
# free space or the 'max' keyword.
# not sure if this has to be present
d-i partman-auto-lvm/guided_size string max

# remove any existing LVM
d-i partman-lvm/device_remove_lvm boolean true
# remove any existing RAID
d-i partman-md/device_remove_md boolean true

# this defines the VG name, not sure if it has to be present, removing for now
# multime names can't be present here
# the following definition of vg_main can be uncommented, uncommenting will not change the result
# this is because the vg defined manually is used
#d-i partman-auto-lvm/new_vg_name string vg_main

# the following is probably not necessary
d-i partman-auto/purge_lvm_from_device boolean true

# there used to be a $defaultignore{ } in the definition of the PV/VG partition, but it still works the same after removing it
# you can define extened partition using extended{ }

# a useful trick:
# put the physical partition that will be deleted later to free up space on an extended volume

# partman uses DIFFERENT units !!!
# conversion guide: multiply by 1.048576 and add 1 (MB) + round down

d-i partman-auto/choose_recipe select myrecipe

d-i partman-auto/expert_recipe string myrecipe :: \
630 10 630 fat32 \
method{ efi } format{ } \
mountpoint{ /boot/efi } \
.\
1074 10 1074 ext4 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
1 99999 -1 ext4 \
$primary{ } \
method{ lvm } \
vg_name{ vg_main } \
. \
12885 10 12885 ext4 \
$lvmok{ } in_vg{ vg_main } \
lv_name{ root } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
. \
2148 10 2148 linux-swap \
$lvmok{ } in_vg{ vg_main } \
lv_name{ swap } \
method{ swap } format{ } \
. \
1 99999 -1 ext4 \
$lvmok{ } in_vg{ vg_main } \
lv_name{ deleteme } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /mnt/deleteme } \
.


# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

# for RAID
#d-i partman-md/confirm_nooverwrite boolean true

Vyrobí to nainstalovaný systém, která vypadá takhle:
Kód: [Vybrat]
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda                8:0    0   16G  0 disk
├─sda1             8:1    0  600M  0 part /boot/efi
├─sda2             8:2    0    1G  0 part /boot
└─sda3             8:3    0 14.4G  0 part
  ├─vg_main-root 254:0    0   12G  0 lvm  /
  └─vg_main-swap 254:1    0    2G  0 lvm  [SWAP]
Vše v LVM není, ale snad to pomůže. Minimální velikost disku pro to aby to fungovalo je 16 GB.

Pro BIOS boot stačí odebrat efi oddíl z konfigurace. To jsou tyhle řádky:
Kód: [Vybrat]
630 10 630 fat32 \
method{ efi } format{ } \
mountpoint{ /boot/efi } \
.\

Recept jde upravit tak aby to vytvřilo další oddíly. Tohle je varianta se samostatným /home a /var (tohle potřebuje 24 GB disk):
Kód: [Vybrat]
d-i partman-auto/expert_recipe string myrecipe :: \
630 10 630 fat32 \
method{ efi } format{ } \
mountpoint{ /boot/efi } \
.\
1074 10 1074 ext4 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
1 99999 -1 ext4 \
$primary{ } \
method{ lvm } \
vg_name{ vg_main } \
. \
8590 10 8590 ext4 \
$lvmok{ } in_vg{ vg_main } \
lv_name{ root } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
. \
2148 10 2148 linux-swap \
$lvmok{ } in_vg{ vg_main } \
lv_name{ swap } \
method{ swap } format{ } \
. \
8590 10 8590 ext4 \
$lvmok{ } in_vg{ vg_main } \
lv_name{ var } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /var } \
. \
2148 10 2148 ext4 \
$lvmok{ } in_vg{ vg_main } \
lv_name{ home } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /home } \
. \
1 99999 -1 ext4 \
$lvmok{ } in_vg{ vg_main } \
lv_name{ deleteme } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /mnt/deleteme } \
.