0

I want to automate the install of Debian and have control over how the partitioning is done by providing a custom recipe.

It was easy enough (ish) when I wasn't using luks or lvm, but I can't get the installer to use crypt and a custom recipe at the same time. The only way a successful install with a luks partition went through was when I let partman-auto do it with d-i partman-auto/method string crypto but it seems to ignore my recipe.

### Partitioning
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select crypto-recipe
d-i partman-auto/expert_recipe_file string /crypto-recipe

d-i partman-crypto/passphrase string super-secret
d-i partman-crypto/passphrase-again string super-secret

d-i partman-partitioning/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
d-i partman-basicfilesystems/no_swap boolean false
crypto-recipe ::

    538 538 1075 fat32
        $iflabel{ gpt }
        $reusemethod{ }
        method{ efi }
        format{ } .

    512 1024 768 ext4
        method{ format }
        format{ }
        use_filesystem{ }
        filesystem{ ext4 }
        mountpoint{ /boot } .

    2000 2000 -1 crypt
        $iflabel{ gpt }
        method{ lvm }
        vg_name{ vg0 } .

    1000 1000 -1 lvmpart
        $lvmok{ }
        in_vg{ vg0 }
        lv_name{ root }
        method{ format }
        format{ }
        use_filesystem{ }
        filesystem{ ext4 }
        label{ doomar }
        mountpoint{ / }
        .

I want the installer to use the one and only physical disk, but am not sure if I need to specify something for that to happen. Any other options I should try?

d-i partman-auto/disk string /dev/vda

d-i partman-auto/method string crypto

I've also tried specifying my crypt partition with percentages:

    100% 100% 100% crypt
        $iflabel{ gpt }
        method{ lvm }
        vg_name{ vg0 } .

There are too many other changes here and there I've tried to list and have got lost. Documentation seems a bit unclear. Is there a better alternative to use preseed files? They don't seem great and I've spent a lot of time trying to get them to work how I want, but they seem limited.

A few problems I run into while trying various options:

  • Doesn't select a disk
  • Fails to install system
  • Insists on /boot despite /boot/efi present
  • Many examples are outdated (BIOS, not UEFI/GPT)
  • Falls back to partman-auto and doesn't follow recipe
  • Creates a blank partition (presumably what should be the crypt partition) next to where the system is installed

If anyone can provide a working example, and clarify whether the method should be regular or crypto when specifying the partitions in a recipe, that at least would give me a starting point.

Update

I tried increasing the size of my virtual disk and it is more clear now that the problem is getting an lvm to be created inside the crypt container. Previously, if the crypt partition took the remaining space on disk then there wasn't anything left for the system.

This is what I tried:

crypto-recipe ::

    538 538 538 fat32
        $iflabel{ gpt }
        $reusemethod{ }
        method{ efi }
        format{ } .

    512 1024 512 ext4
        method{ format }
        format{ }
        use_filesystem{ }
        filesystem{ ext4 }
        mountpoint{ /boot } .

    2000 2000 -1 crypt
        $iflabel{ gpt }
        method{ crypto }
        vg_name{ vg0 } .

    2000 2000 -1 lvmpart
        $lvmok{ }
        in_vg{ vg0 }
        lv_name{ root }
        method{ format }
        format{ }
        use_filesystem{ }
        filesystem{ ext4 }
        label{ doomar }
        mountpoint{ / }
        .

Now it is clear

vda                                                                            
├─vda1 vfat   FAT32        390B-57B3                             505.1M     1% /boot/efi
├─vda2 ext4   1.0          48ab2ad8-2744-4fe0-b8ed-dbb9766e0cae  369.7M    11% /boot
├─vda3                                                                         
└─vda4 ext4   1.0   doomar 5ada0c1d-4048-4ff6-ac23-4936dcc16710    1.1G    41% /
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 5369MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  538MB   537MB   fat32        EFI System Partition  boot, esp
 2      538MB   1050MB  512MB   ext4
 3      1050MB  3049MB  2000MB
 4      3049MB  5368MB  2318MB  ext4

vda3 should be the luks crypt partition, and vda4 shouldn't exist, instead being an lvm inside vda3

1 Answer 1

0

Only a partial answer, because it relies on partman auto to setup crypto, and that seems to limit the flexibility of the recipe.

In particular, I had to add $defaultignore{ } to the \boot partition, which I noted from the entek.org.uk blog

d-i partman-auto-lvm/guided_size string max

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-auto/method string crypto
d-i partman-auto/choose_recipe select autocrypt-recipe
d-i partman-auto/expert_recipe_file string /autocrypt-recipe

d-i partman-crypto/passphrase string super-secret
d-i partman-crypto/passphrase-again string super-secret

d-i partman-partitioning/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
d-i partman-basicfilesystems/no_swap boolean false
autocrypt-recipe ::

    256 256 256 fat32
        $iflabel{ gpt }
        $reusemethod{ }
        method{ efi }
        format{ } .

    256 256 256 ext4
        $defaultignore{ }
        method{ format }
        format{ }
        use_filesystem{ }
        filesystem{ ext4 }
        mountpoint{ /boot } .

    2000 2000 -1 ext4
        $lvmok{ }
        lv_name{ root }
        method{ format }
        format{ }
        use_filesystem{ }
        filesystem{ ext4 }
        label{ doomar }
        mountpoint{ / }
        .

Result

vda                                                                                                          
├─vda1                     vfat        FAT32           E692-113B                               233.4M     2% /boot/efi
├─vda2                     ext4        1.0             89d9e5c4-5cba-4b08-bd0f-96c9332a3e07      154M    24% /boot
└─vda3                     crypto_LUKS 2               9d4aa1bd-0706-4ba0-ac48-850ac7499355                  
  └─vda3_crypt             LVM2_member LVM2 001        0EDidF-GVe0-odQX-gPQ9-VXED-Pf7l-snWt8D                
    └─debian--vm0--vg-root ext4        1.0      doomar 099e743c-0c62-4bb8-8f25-71e8c96ce8d9      3.3G    19% /
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 5369MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  256MB   255MB   fat32        EFI System Partition  boot, esp
 2      256MB   512MB   256MB   ext4
 3      512MB   5368MB  4856MB

I would still like to know if it is possible to use the regular method and specify the crypto and lvm partitions in the recipe more explicitly instead of relying on partman-auto?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .