LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Reinstall Linux with LVM partitions (https://www.linuxquestions.org/questions/linux-newbie-8/reinstall-linux-with-lvm-partitions-4175735837/)

Jason.nix 04-09-2024 11:56 AM

Reinstall Linux with LVM partitions
 
Hello,
When Linux is installed with LVM partitions, if I want to reinstall Linux and need the information of a partition in the new installation, should the partitioning type in the new installation also be LVM?

Thank you.

wpeckham 04-09-2024 12:09 PM

You are doing a reinstall. Do you want to preserve one or more current file systems, or do a full reinstall?
A full reinstall gives you the option to reconfigure the storage to your liking and there is no reason to preserve the existing structure.
If you want to preserve a current file system, you need to preserve AT LEAST the current structure as it contains or defines the current file system that you want to preserve.

Actually my better advice would be to back up any file system you want to retain, and verify the backup. Then do that again on different media. This way, with two verified backups, you are assured that you can restore even if a backup device goes south on you. Then do a full install overwriting the old structure with whatever you have planned: then restore the backup so you have access to that data.

Having those backups also protects you against the case that something goes bad during the install and ALL of your storage gets wiped! I have seen devices that have worked perfectly for years suddenly decide that maintenance day was the day to finally fail, and a backup protects you against that kind of thing.

Get the backups first, then you can decide how to proceed from there at your leisure with less pressure.

sundialsvcs 04-09-2024 12:24 PM

Indeed, one of the key advantages of LVM is that you don’t (!!) have to be concerned with the physical (drive and/or partition) arrangement, because “Linux file systems” never see it. They only see a “logical volume,” which lives in an endlessly-expandable “storage pool.” (Which can be re-configured “on the fly.” For instance, if that “failing drive” is generous enough to give you a little warning …)

When setting up your new environment, it can be “physically” configured any way you like.

lvm_ 04-09-2024 01:27 PM

No, you can mix normal and LVM devices any way you want. Also, LVM volume is not a partition but more akin to loop device, but that's beside the point.

pan64 04-10-2024 05:40 AM

yes, LVM is not a partition type, but a way to manage partitions. You can install your OS with or without it.

JJJCR 04-12-2024 12:57 AM

as it name says. logical volume manager it's just helps to manage volumes

as Gemini AI says:
Quote:

Logical: LVM deals with logical volumes, which are virtual representations of storage space carved out of underlying physical devices. These logical volumes can be resized, moved, and managed independently of the physical devices they reside on.

Volume: A volume refers to a specific chunk of storage space that can be used by the operating system. In LVM, logical volumes act as these chunks, providing a layer of abstraction over the physical storage.

Manager: The LVM toolset provides functionalities to create, manage, resize, and extend these logical volumes as needed.

Jason.nix 04-13-2024 08:15 AM

Hello,
Thanks for all the replies.
Consider the following partitioning:
Code:

# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda          8:0    0  512G  0 disk
└─sda1        8:1    0  512G  0 part
  ├─LB-Root 254:0    0  74.5G  0 lvm  /
  ├─LB-Home 254:1    0  18.6G  0 lvm  /home
  └─LB-Data 254:2    0 418.9G  0 lvm  /mnt/data
sr0          11:0    1  1024M  0 rom

I want to reinstall Linux, but this time I don't want to use LVM and I want to use the data in LB-Data partition. Is this possible? Shouldn't the whole disk be reformatted when LVM wants to convert to normal partitioning?

sundialsvcs 04-13-2024 08:17 AM

Just continue to use LVM. Eventually, you will be very glad you did.

lvm_ 04-13-2024 11:21 AM

Quote:

Originally Posted by Jason.nix (Post 6495671)
I want to reinstall Linux, but this time I don't want to use LVM and I want to use the data in LB-Data partition. Is this possible? Shouldn't the whole disk be reformatted when LVM wants to convert to normal partitioning?

LVM is just like drugs, mortgages and clouds - once you got into this mess, it's not that easy to get out. If LB-Data volume is more than 50% free you can shrink the filesystem, then the volume, then the LVM partition, create a new partition in the freed space, create a filesystem there and copy the data, but that requires some skills. Otherwise you'll have to copy data to a backup device, re-partition the disk and copy data back, but that requires that backup device.

Quote:

Originally Posted by sundialsvcs (Post 6495672)
Just continue to use LVM. Eventually, you will be very glad you did.

Or not. Unless LVM usage is indicated, it's just a useless thing which can go wrong and wastes resources. Its forte - virtualised storage, not a physical one.

computersavvy 04-13-2024 01:20 PM

Quote:

Originally Posted by lvm_ (Post 6495707)
LVM is just like drugs, mortgages and clouds - once you got into this mess, it's not that easy to get out. If LB-Data volume is more than 50% free you can shrink the filesystem, then the volume, then the LVM partition, create a new partition in the freed space, create a filesystem there and copy the data, but that requires some skills. Otherwise you'll have to copy data to a backup device, re-partition the disk and copy data back, but that requires that backup device.


Or not. Unless LVM usage is indicated, it's just a useless thing which can go wrong and wastes resources. Its forte - virtualised storage, not a physical one.

We all have our own opinions.
LVM is actually a physical storage, not virtual. It is a means of managing flexible storage without the limiting features of physical drives or partition sizes and adds the ability for storage in a single file system to span multiple physical drives seamlessly.

I have been using LVM for many years, and I love the ability to add space and grow the file system seamlessly while the machine is in use.
I use a raid array with LVM and have gradually grown from a measly 1 TB size to more than 10 TB on that raid array and never needed to be concerned about shutting down to do so. I have had drives fail and be replaced without problems with the raid, and I have had the file system grow as needed with more data storage, also without shutdown nor partitioning hassles.

wpeckham 04-13-2024 06:21 PM

If you have, and will only ever have, a single physical drive that will never change then LVM works but provides little value. As soon as you are adding drives or moving storage (resizing partitions or file systems) then LVM is golden.

There is no reason to use it with ZFS or BTRFS, but if you are using EXT4 on RAID (physical or using MDADM) it can save you no end of complications.

lvm_ 04-14-2024 01:20 AM

Quote:

Originally Posted by computersavvy (Post 6495730)
We all have our own opinions.

True, but some of them are correct while some - not so much.

Quote:

Originally Posted by computersavvy (Post 6495730)
LVM is actually a physical storage, not virtual.

And this is an example of opinion which is egregious. L in LVM stands for Logical - as opposed to physical.

Quote:

Originally Posted by computersavvy (Post 6495730)
I have been using LVM for many years, and I love the ability to add space and grow the file system seamlessly while the machine is in use.
I use a raid array with LVM and have gradually grown from a measly 1 TB size to more than 10 TB on that raid array and never needed to be concerned about shutting down to do so. I have had drives fail and be replaced without problems with the raid, and I have had the file system grow as needed with more data storage, also without shutdown nor partitioning hassles.

Yep, the same here - but without the LVM. Are you really unaware that arrays and filesystems can be grown online all by themselves, and LVM in this scenario is superfluous?

wpeckham 04-14-2024 10:51 AM

Quote:

Originally Posted by lvm_ (Post 6495795)
Yep, the same here - but without the LVM. Are you really unaware that arrays and filesystems can be grown online all by themselves, and LVM in this scenario is superfluous?

Except that LVM was specifically designed to make it easy to make changes that are difficult, make changes possible where they are impossible otherwise, and combine storage devices without the restrictions (or advantages) of RAID?

It is useful and powerful, and had you ever encountered a situation where it made the difference between a 12 hour outage maintenance and completing the change without outage on a Monday morning you would know that.

That said, it is unclear if the situation justifies it for the OP. We have options now that make LVM less a requirement than an option. Also, his does not sound like a production environment and a short outage to make storage changes might be perfectly suitable for his operation. We cannot change that or determine that, we can only give information and allow the OP to make that judgement.

More important here is that the OP wants to preserve some of the data. The best way, with or without LVM, is to back that data up. This also simplifies everything else the OP has planned.

JJJCR 04-14-2024 09:36 PM

Quote:

Originally Posted by computersavvy (Post 6495730)
We all have our own opinions.
LVM is actually a physical storage, not virtual. It is a means of managing flexible storage without the limiting features of physical drives or partition sizes and adds the ability for storage in a single file system to span multiple physical drives seamlessly.

I have been using LVM for many years, and I love the ability to add space and grow the file system seamlessly while the machine is in use.
I use a raid array with LVM and have gradually grown from a measly 1 TB size to more than 10 TB on that raid array and never needed to be concerned about shutting down to do so. I have had drives fail and be replaced without problems with the raid, and I have had the file system grow as needed with more data storage, also without shutdown nor partitioning hassles.

Just to add, LVM is definitely good for resizing or adding space. However, if the application is overly sensitive to IO (r/w) adding more disk to LVM will add disk IO r/w latency. So, basic stuff, like forecasting what space will be needed is still good. Rather than doing firefighting when there is some issue.

lvm_ 04-15-2024 12:00 AM

Quote:

Originally Posted by wpeckham (Post 6495892)
Except that LVM was specifically designed to make it easy to make changes that are difficult, make changes possible where they are impossible otherwise, and combine storage devices without the restrictions (or advantages) of RAID?

Well, leaving the idle rhetoric out, the last one is quite true, but as no IT man worth his salt will use RAID0 or JBOD (BTW LVM essentially is a glorified JBOD) for any data worth keeping, he also won't use LVM unless underlying devices are themselves redundant, and so we come again to serious stuff - virtual redundant storage and SAN arrays, as the only environment where LVM is acceptable. Your physical home PC is not the place for LVM.

Quote:

Originally Posted by wpeckham (Post 6495892)
It is useful and powerful, and had you ever encountered a situation where it made the difference between a 12 hour outage maintenance and completing the change without outage on a Monday morning you would know that.

Yes, it sure is a fast way of doing things, but also a sloppy one. These VMs with disks grown historically of half a dozen PVs are so sad...


All times are GMT -5. The time now is 04:36 AM.