lxd icon indicating copy to clipboard operation
lxd copied to clipboard

Can I config an instance auto exec fsck command when it start

Open equator8848 opened this issue 1 year ago • 2 comments

Required information

  • Distribution: LXC
  • Distribution version: 5.16
  • The output of "lxc info" or if that fails:
    • Kernel version: 5.19.11-051911-generic
    • LXC version: "5.16"
    • Storage backend in use: ceph 17.2.5

Issue description

Hello, can I set thing that my container instance will exec fsck disk when boot system? When file system of container breakdown (it happend after host crash usually), I can not expand instance disk size online successfully. I need to exec command manually like this:

sudo rbd map -p lxd container_xxx

sudo fsck.ext4 -y /dev/rbd0

sudo resize2fs /dev/rbd0

sudo rbd unmap lxd/container_xxx

rbd showmapped

So I want container instance and exec fsck command before system boot. 👀

equator8848 avatar Feb 22 '24 16:02 equator8848

This sounds like an interesting idea, ive flagged it as a new feature as its not something we support currently.

Thanks!

tomponline avatar Feb 23 '24 16:02 tomponline

Thank you, tomponline! Waiting for your great work.

Now I try to exec fsck command by my app before calling lxd start container http api, but I think it is a clumsy design. 😁

equator8848 avatar Feb 24 '24 05:02 equator8848

Going with a fully automated repair (attempt) with fsck.ext4 -y feels risky. Personally I'd only do that after taking a snapshot if I care about the data.

I think that prompting the user on what to do if fsck.ext4 -n returns non-zero would be safer. Alternatively, fsck.ext4 -p might be considered as it repairs "what can be safely fixed without human intervention".

simondeziel avatar Mar 12 '24 20:03 simondeziel

@simondeziel hi, can lxd exec fsck.ext4 -p automatically?

equator8848 avatar Mar 15 '24 15:03 equator8848

@equator8848 not currently but as Tom said, it an idea worth looking into.

simondeziel avatar Mar 15 '24 15:03 simondeziel