How can I create a read-only LVM snapshot?

0
1
Asked By TechSavvyGamer93 On

I'm trying to create a read-only LVM snapshot using the command `lvcreate -s -n test -p r backup/vault`, but it gives me an error saying I need to specify either a size or extents for the snapshot. I understand that if I provide a size with `--size`, the command works, but I really just want a snapshot that doesn't allow writing. Is it feasible to make a read-only snapshot without specifying a size? There's a post that suggests it's possible, but I'm not sure how to do it. Thanks!

3 Answers

Answered By FilesystemNinja88 On

You could consider mounting the snapshot in read-only mode in your fstab file. This way, while the snapshot might still technically have a writable aspect, you can make sure that it's configured to be read-only when it's accessed.

Answered By CuriousCoder21 On

You definitely need to specify a size for the snapshot, even if you don't plan on writing to it. The reason behind this is that a snapshot needs to have some space allocated to manage the copy-on-write mechanism. If changes are made to the original volume, those changes need to be tracked in the snapshot, which requires some reserved space. There are types of logical volumes related to thin pools that might offer more flexibility, but generally, you'll have to provide a size when creating a snapshot.

AnonymousUserNaN -

Using a thin LVM might be the way to go then!

Answered By DiskMasterX On

Here's a command example to create a read-only snapshot:
`lvcreate -s -l 1 -pr -n LV-snap /dev/test/LV`
This will create a logical volume called "LV-snap" that is read-only. You will still need to define size or extents, but it's crucial to do this right. If you're working with thin volumes, you might get around the size requirement though. Be sure to check the documentation too!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.