lvmteam / lvm2

Mirror of upstream LVM2 repository
https://gitlab.com/lvmteam/lvm2
GNU General Public License v2.0
134 stars 72 forks source link

LVM Snapshot got mounted instead of source/Origin's logical volume #146

Closed HarinadhD closed 5 months ago

HarinadhD commented 6 months ago

Hi , I have used UUID's in /etc/fstab to mount logical volumes automatically across the boots, I have noticed sometimes LVM snapshot got mounted instead of Source logical volume.

Snapshot volume and Source logical volume has same UUID's , can this leads to snapshot getting mounted sometimes?

Environment details: LVM version: 2.03.10 Linux Version: 5.10.214 systemd version:247.13

To avoid this scenario(Snapshots getting mounted) , I have updated the UUID of snapshot volume using tune2fs command ((generated uuid using uuidgen , executed e2fsck and then used tune2fs to change the snapshot UUID) , after that snapshot volume never mounted during the boots.

But I got another problem during the snapshot revert operation because of changing snapshot UUID, Snapshot revert operation updated Source logical volume UUID with Snapshot UUID and which lead to boot failure ( UUID in /etc/fstab doesn't match with any volume in the system)

I know using logical volumes path(/dev/<vg name/) for mounting (in /etc/fstab file) will solve these problem , But my question here why Origin(source volume) UUID got changed during the snapshot merge , which is a conflict with the statement is lvconvert man page ?

lvconvert man page ( https://linux.die.net/man/8/lvconvert ) says , During the snapshot merge the resulting logical volume will have the origin's UUID, minor number and name.

--merge Merges a snapshot into its origin volume or merges a raid1 image that has been split from its mirror with --trackchanges back into its mirror. To check if your kernel supports the snapshot merge feature, look for 'snapshot-merge' in the output of dmsetup targets. If both the origin and snapshot volume are not open the merge will start immediately. Otherwise, the merge will start the first time either the origin or snapshot are activated and both are closed. Merging a snapshot into an origin that cannot be closed, for example a root filesystem, is deferred until the next time the origin volume is activated. When merging starts, the resulting logical volume will have the origin's name, minor number and UUID. While the merge is in progress, reads or writes to the origin appear as they were directed to the snapshot being merged. When the merge finishes, the merged snapshot is removed. Multiple snapshots may be specified on the commandline or a @tag may be used to specify multiple snapshots be merged to their respective origin.

Is it not recommended to use UUID's for mounting lvm logical volumes ?

Thanks, Harinadh D

zkabelac commented 5 months ago

Yep - if you use snapshots - likely try to use some other identifier.

Note - you can also check whether thin snapshot isn't better fit - here you do not need to active all snapshots with origin, so it makes situation in some way more easier to handle...

In general old 'thick' snapshots were mostly designed for a 'temporary' snapshot-ting - so most users do not need to solve 'booting' problems with them - for a more permanent snapshot 'thin' snapshots give much better performance and usability...