rancher / k3os

Purpose-built OS for Kubernetes, fully managed by Kubernetes.
https://k3os.io
Apache License 2.0
3.5k stars 396 forks source link

LVM volumes are not activated on boot #819

Open spigell opened 2 years ago

spigell commented 2 years ago

Version (k3OS / kernel) v0.20.11-k3s2r1

Architecture amd64

Describe the bug Greeting! I created my own disk layout and installed bootloader. But when k3os boots all volumes not activated. Is there any workarounds?

To Reproduce

Packer boot_command

  default = [
    "rancher", "<enter>",
    "export K3OS_INSTALL_POWER_OFF=true", "<enter>",
    "export INTERACTIVE=true", "<enter>",
    "export K3OS_INSTALL_NO_FORMAT=true", "<enter>",
    "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/create-disk-layout.sh | sudo bash", "<enter>",
    "<wait5m>",
    "sudo -E k3os install", "<enter>",
    "1", "<enter>", "y", "<enter>",
    "http://{{ .HTTPIP }}:{{ .HTTPPort }}/config.yml", "<enter>", "y", "<enter>"
    ...install bootloader...
  ]

create-disk-layout.sh

readonly DEVICE=/dev/vda
readonly PART=${DEVICE}1

dd if=/dev/zero of=${DEVICE} bs=1M count=1

parted -s ${DEVICE} mklabel msdos
parted -s ${DEVICE} mkpart primary 1 100%
parted -s ${DEVICE} set 1 lvm on
parted -s ${DEVICE} set 1 boot on
partprobe ${DEVICE}
sleep 2

pvcreate $PART
vgcreate k3os $PART
lvcreate -n root -l 100%FREE k3os

mkfs.ext4 -F -L K3OS_STATE /dev/k3os/root

Expected behavior All lvm volumes will be activated

Actual behavior Without lvm k3os can't determine boot mode. If I specify mode via kernel (k3os.mode=disk) k3os can't mount root partition Additional context photo_2021-11-25_03-35-26

dweomer commented 2 years ago

I haven't double-checked but LVM should be present in the initrd. You may need a modules entry in your config.yaml.

spigell commented 2 years ago

Hi! i have attached a screenshot to description. I tried to add lvm to modules and also specify 'vgchange -a y' to init_cmd => It can't find partition with K3OS_STATE label because a lvm volume is not activated.

ivan98 commented 2 years ago

@spigell, can you show us your config.yaml? I have successfully mounted a LVM RAID5 device but am now using mdadm for the same.

spigell commented 2 years ago

@ivan98 Hi. Here it is:

init_cmd:
- 'sudo vgchange -a y'
boot_cmd:
- 'sudo sh -c "echo GA_PATH=/dev/vport1p1 > /etc/conf.d/qemu-guest-agent"'
k3os:
  modules:
  - lvm
  - wireguard
  password: "$6$7Mw7WhZ6wwxR28uD$W3VhXiO7zTQm.jubGlxHLxWsXKFLNwQUbIenxjfRnqoUrfyl0ORlYRB9m3AJcvFppkccO6BsCV7cT5hIzglwM."