void-linux / void-packages

The Void source packages collection
https://voidlinux.org
Other
2.47k stars 2.1k forks source link

Data loose on lvm after reboot #40589

Closed superiums closed 1 year ago

superiums commented 1 year ago

i have two ext4 logical volum, one normal, one with luks crypt. one day i found all data on luks lost. but the lv can be mounted normally, and fsck found no err. i reformated it with luksFormat and mkfs.ex4. then tried seral times to write, and found:

all these situation happens in both luks lv and normal lv.

additional

versions

ahesford commented 1 year ago

You should probably post your /etc/crypttab and clarify what you mean by "mount point i usually use /dev/shm/xxx". None of your physical disks or LVM devices should be in /dev/shm.

superiums commented 1 year ago

You should probably post your /etc/crypttab and clarify what you mean by "mount point i usually use /dev/shm/xxx". None of your physical disks or LVM devices should be in /dev/shm.

i mean i usually do like this:

sudo mount /dev/mapper/vg-lv3   /dev/shm/lv3

sorry for my unclear description. my lv was not listed in /etc/crypttab

ahesford commented 1 year ago

Why are you mounting things under /dev/shm? That's ill advised.

superiums commented 1 year ago

Why are you mounting things under /dev/shm? That's ill advised.

aha, got it ! this is the reason which caused the issue. i've tried to mount lv to /media/xxx, and it never loose now.

i mount it to /dev/shm/xxx for temp use, usuallay i use /dev/shm as temp directory. before use void linux, in arch, there's no problem in this way. but seems in voidLinux it works in different way from other os .

i'm now interesting with why mount to /dev/shm/xxx will cause data loose.

sgn commented 1 year ago

Do you have elogind installed and enabled?

ahesford commented 1 year ago

/dev/shm is used by the shared-memory interface and not intended for direct use by users. In general, you should never mount thing inside /dev.

Edit: turns out /dev/shm is just a tmpfs mount and is intended for users to store things guaranteed not to be on disk (this seems like a poorly developed concept, because you shouldn't expect any particular storage behavior based solely on where you save and read files), but that has no bearing on the recommendation against mounting things under /dev/

superiums commented 1 year ago

Do you have elogind installed and enabled?

yes , elogind was installed, and started. but the service was not enabled. maybe started by greetd.

superiums commented 1 year ago

~/dev/shm is used by the shared-memory interface and not intended for direct use by users.~ In general, you should never mount thing inside /dev.

Edit: turns out /dev/shm is just a tmpfs mount and is intended for users to store things guaranteed not to be on disk (this seems like a poorly developed concept, because you shouldn't expect any particular storage behavior based solely on where you save and read files), but that has no bearing on the recommendation against mounting things under /dev/

thank you very much!

sgn commented 1 year ago

/dev/shm is for SHared Memory IPC, it will be cleaned up up on logging out. https://github.com/systemd/systemd/issues/2039

superiums commented 1 year ago

/dev/shm is for SHared Memory IPC, it will be cleaned up up on logging out. systemd/systemd#2039

yeh, files in it will be cleaned. but mount device to it , data is not saved in it. in arch and ubuntu , no data will loose if do the same thing.

maybe the mount options differs from each other.

sgn commented 1 year ago

Noone care if it's a normal directory or mount-point:

https://github.com/systemd/systemd/blob/d9338387d94ad611233cf0753801eefccfda432a/src/shared/clean-ipc.c#L221-L300

Re: arch and Ubuntu, I don't know your configuration, I can't comment.