OpenNebula / addon-context-linux

Linux VM Contextualization
Apache License 2.0
56 stars 73 forks source link

Disk Resize might break FreeBSD #298

Closed dann1 closed 1 year ago

dann1 commented 1 year ago

When issuing a onevm disk-resize to a FreeBSD VM, the image OS will corrupt the FS and the VM will no longer be usable. This can happen with both live and POWEROFF resize. When live resize is issued the contextualization will not trigger automatically, but it can be triggered with onevm updateconf.

The problem lies in the execution of /etc/rc.d/growfs onestart triggered by the contextualization service. The problem even happens when commenting out such code and adding it to the START_SCRIPT instead, which is executed lastly by the contextualization service. Looks like some sort of race condition.

Executing this command manually inside the OS after a disk resize has been issued on the hypervisor doesn't seem to cause the FS corruption. The official FreeBSD documentation mentions this is a possibility.

Since there is a manual workaround and extremely high risk, the feature will be disabled for FreeBSD.

dann1 commented 1 year ago

Output should look like this now after a resize is triggered on OpenNebula

root@myh:~ # gpart show
=>     40  8388528  da0  GPT  (5.0G) [CORRUPT]
       40     1024    1  freebsd-boot  (512K)
     1064  8387504    2  freebsd-ufs  (4.0G)

root@myh:~ # /etc/rc.d/growfs onestart
Growing root partition to fill device
da0 recovered
da0p2 resized
gpart: arg0 'gpt/rootfs': Invalid argument
super-block backups (for fsck_ffs -b #) at:
 8975872, 10258112
root@myh:~ # gpart show
=>      40  10485680  da0  GPT  (5.0G)
        40      1024    1  freebsd-boot  (512K)
      1064  10484656    2  freebsd-ufs  (5.0G)