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

loadkmap in sysinit runlevel disrupts localmount #814

Open ivan98 opened 2 years ago

ivan98 commented 2 years ago

Version (k3OS / kernel) k3os version v0.22.2-k3s2r0 5.4.0-88-generic _99 SMP Tue Oct 5 16:53:38 UTC 2021

Architecture x86_64

Describe the bug I need to mount a LVM disk before k3s-service starts, so I did the following:

Thinking that service localmount will auto mount the entry in /etc/fstab

To Reproduce

boot_cmd:
  - "rc-update add lvm boot"
  - "sed -i 's|^#critical_mounts.*|critical_mounts=\"/data\"|' /etc/conf.d/localmount"
  - "sed -i '$arc_before=\"localmount\"' /etc/conf.d/lvm"
write_files:
  - path: /etc/fstab
    content: |-
      /dev/cdrom     /media/cdrom iso9660 noauto,ro 0 0
      /dev/usbdisk   /media/usb   vfat    noauto,ro 0 0
      /dev/vg2/lvol0 /data        xfs     noatime,nodiratime,attr2,logbsize=256k 0 2
      #
    owner: root
    permissions: '0644'

Expected behavior /dev/vg2/lvol0 should be mounted at /data before k3s-service starts

Actual behavior During the sysinit phase of boot up, loadkmap requires and runs the localmount service. localmount fails to find /dev/vg2/lvol0 as lvm has not started yet.

In the boot phase, lvm starts but since localmount has already started in the previous phrase, it no longer runs. /dev/vg2/lvol0 is now present but not mounted to /data.

Additional context I downloaded Alpine Linux 3.14.2, and notice that its loadkmap service is in the boot runlevel, not in the sysinit runlevel. While I update my config.yaml accordingly, it is working:

boot_cmd:
  - "rc-update del loadkmap sysinit"
  - "rc-update add loadkmap boot"
  - "rc-update add lvm boot"
  - "sed -i 's|^#critical_mounts.*|critical_mounts=\"/data\"|' /etc/conf.d/localmount"
  - "sed -i 's/^#rc_logger.*/rc_logger=\"YES\"/' /etc/rc.conf"
  # - "sed -i 's/^#rc_verbose.*/rc_verbose=\"YES\"/' /etc/rc.conf"
  - "sed -i '$arc_before=\"localmount\"' /etc/conf.d/lvm"
write_files:
  - path: /etc/fstab
    content: |-
      /dev/cdrom     /media/cdrom iso9660 noauto,ro 0 0
      /dev/usbdisk   /media/usb   vfat    noauto,ro 0 0
      /dev/vg2/lvol0 /data        xfs     noatime,nodiratime,attr2,logbsize=256k 0 2
      #
    owner: root
    permissions: '0644'
dkowis commented 2 years ago

I think I also just encountered this trying to get lvm of disks working, and failing miserably. Thanks for this workaround.