The officially official Devuan Forum!

You are not logged in.

#1 2021-08-17 14:31:26

entropyagent
Member
Registered: 2020-05-15
Posts: 48  

Can I share a "data" LVM logical volume in a multi-boot linux setup?

Can I share an lvm logical volume between linux instances in a linux-only dual-boot (OK, maybe multiple-boot) setup?

I  understand that sharing such system-customised partitions as /boot or /home might cause confusion, but have on several occasions shared "data" partitions between linux instances (even ones that are running simultaneously, usually via NFS.) I have also served LVM LVs via NFS. Is native LVM different in this regard? Is there more of a risk of data corruption ?
Are there risks, gotchas, implications to consider?

For example, consider I set up:

Instance01....PV01_on_Inst01....VG01_on_Inst01....LV01_in_VG01_on_Inst01 

Now on the same hardware. I set up the option to boot into another instance:

Instance02....PV01_on_Inst02....VG01_on_Inst02....LV01_in_VG01_on_Inst02

In this case "LV01_in_VG01_on_Inst01"  and "LV01_in_VG01_on_Inst02"  actually contain the same data, because they are the same "logical volume"/"partition"/thing.

Implications, risks, gotchas? Is it possible that this might actually be safe ONLY if the sharing instances never exist at the same time? If so, it's OK in a multi-boot setup on a single machine?

For example, I don't plan on doing this at present, but:

I have the idea that I can create a snapshot of an LV (in this case, say, on Instance01) and it will contain all changes made to the original since the creation of the snapshot. If a change happens while this LV is mounted on Instance02, are these changes lost? Will rebooting back into Instance01 cause a sudden rush of updates to the snapshot, or are the changes lost Will the snapshot be hopelesly corrupted?

Or have I completely misunderstood what LVM is about?

Offline

#2 2021-08-17 16:33:46

rolfie
Member
Registered: 2017-11-25
Posts: 1,047  

Re: Can I share a "data" LVM logical volume in a multi-boot linux setup?

Sharing a LVM logical volume should work fine without any problems as long as its not used for distribution specific configuration data. LVM2 is mature, and there should be no major difference in the LVM implementation between distributions. Booting into one or the other should not matter for a data storage, and as long as you use a mature file system like ext4 on the share.

I have split my /home for my multiboot setup with Beowulf and Chimaera into a partition that holds all office data like pictures, LO files etc, and a distribution specific part that holds all the hidden config and cache files. The office share is linked into the distribution specific part during boot.

rolfie

Online

#3 2021-08-17 17:28:15

entropyagent
Member
Registered: 2020-05-15
Posts: 48  

Re: Can I share a "data" LVM logical volume in a multi-boot linux setup?

Interesting, thanks. Are these 'parts' logical volumes?

So there is an lv with "office data" which is mounted by a Beowulf LVM instance when Beowulf is running, and by the Chimaera LVM instance when Chimaera is running? This seems to be similar to what I am hoping to do. For how long has this polyamorous arrangement been on the go without crashing&burning? (No H8, Love is Love, etc)

Splitting /home into generic/sharable and instance-specific seems like it's worth a separate tutorial(hint, hint)? Or maybe you could link to the guides/tutorials you followed?

Offline

#4 2021-08-17 18:50:08

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,409  

Re: Can I share a "data" LVM logical volume in a multi-boot linux setup?

The host system does not need to be lvm to mount the data lvm. You just need lvm2 to be installed, and you can open the volume and mount it with a few commands.

A howto on keeping the configs separate on a shared home would probably be useful for a lot of people.

Offline

#5 2021-08-17 23:50:37

entropyagent
Member
Registered: 2020-05-15
Posts: 48  

Re: Can I share a "data" LVM logical volume in a multi-boot linux setup?

Well, thanks for the feedback so far. However, I am not really hearing anyone saying that they have actually done this sharing with a logical volume. Nor am I hearing people assuring me that "It's at least as safe as sharing a normal partition, everybody does it, without a second thought" or  "We do it a lot, never had any problems"

Can anyone help with that?

Offline

#6 2021-08-18 01:46:30

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,409  

Re: Can I share a "data" LVM logical volume in a multi-boot linux setup?

I've booted a live-usb and mounted lvm many times. it's just like mounting any other block device, with a few extra commands. Once it's attached to the filesystem, you can read and write files as you normally would.

I've also mounted lvm from another installation on a different hard drive in the same computer. It works the same way.

A few extra commands. (Leave out the cryptsetup lines if your lvm is not encrypted.)

___ MOUNT/UNMOUNT ENCRYPTED LVM ___

sudo cryptsetup luksOpen /dev/sdxY label  # then run lvdisplay to get the vg name and lv name
sudo vgchange -a y <volume_group_name> 
mount /dev/mapper/<vg_name-lv_name>  <mountpoint> 

umount <mountpoint>
sudo vgchange -a n <volume_group_name>
sudo cryptsetup luksClose label

Offline

#7 2021-08-18 18:09:15

rolfie
Member
Registered: 2017-11-25
Posts: 1,047  

Re: Can I share a "data" LVM logical volume in a multi-boot linux setup?

entropyagent wrote:

Interesting, thanks. Are these 'parts' logical volumes?

In my case, no. I have 3 encrypted partitions for the fixed data, volatile Beowulf and volatile Chimaera.

The main system is an encrypted LVM for / and swap.

As fsmithred I have opened LVM shares to fix problems with live systems like Knoppix or the rescue mode of a boot medium often enough to say that I never had any issues.

rolfie

Online

#8 2021-08-18 23:48:19

entropyagent
Member
Registered: 2020-05-15
Posts: 48  

Re: Can I share a "data" LVM logical volume in a multi-boot linux setup?

Thanks to all who replied.

It seems that what I was specifically interested, i.e. sharing a logical volume between linux instances in a multi-boot arrangement in exactly the same way as a normal partition, hopping between instances as the mood or need dictates, is something that our community here has no experience of.

@fsmithred and @rolfie, you seem to be describing doing it once or twice and getting away with it, without catastrophe.
That is encouraging, so thanks for that. However, I would also have been interested to hear from people who do it regularly, as part of their standard operating procedure, but it seems that we don't do that sort of thing here.

It could be that the idea is so ridiculous that it is not discussed, or is so commonplace that it is quite unremarkable.
If I ever get around to the experiment, I should probably start off with data I to which I am not too attached.

Offline

#9 2021-08-19 14:24:45

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,409  

Re: Can I share a "data" LVM logical volume in a multi-boot linux setup?

The commands I posted for you are from the release notes of refracta gnu/linux. I wrote that part about 10 years ago, and I've used it multiple times over the years. It really is just like mounting any other data partition.

On the other hand, if you try to share system files between two different systems, you'll probably run into some interesting problems we've never seen before. But that would happen with or without lvm.

Offline

Board footer