canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.35k stars 931 forks source link

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

Open equator8848 opened 7 months ago

equator8848 commented 7 months ago

Required information

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. 👀

tomponline commented 7 months ago

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

Thanks!

equator8848 commented 7 months ago

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. 😁

simondeziel commented 7 months ago

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".

equator8848 commented 7 months ago

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

simondeziel commented 7 months ago

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