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...

wpeckham 04-15-2024 10:58 AM

Quote:

Originally Posted by lvm_ (Post 6496003)
... Your physical home PC is not the place for LVM....

That depends entirely upon the hardware, configuration, and use of that home PC.

You know what they say about assumptions....

sundialsvcs 04-15-2024 02:47 PM

I kindly disagree that "LVM is not for your home PC." You actually never know when you might need more space. The LVM subsystem provides an elegant(!) way to address that problem – as well as a way to rid yourself of a drive which ("*click* *click* !! *click* *click* !!") might be beginning to fail. And, it basically doesn't cost you anything – even if you never actually have need to use it. I always select this option when installing everything, and never think twice about doing so.

computersavvy 04-15-2024 10:03 PM

Quote:

Originally Posted by lvm_ (Post 6496003)
Your physical home PC is not the place for LVM.

We all are entitled to our own opinions.
LVM has a definite use, and is also very easy to use.
It is flexible and robust so home use is just as simple as any other location.

In fact, with the currently available drive sizes (both SSD and HDD) a user is forced to 1) over provision file system partitions in anticipation of growth, 2) shutdown and manipulate partition sizes when a critical partition fills up, or 3) use LVM or similar to provide the ability to manage file system sizes on the fly without interrupting operations. This applies to those with systems at home as well as large enterprise servers.

You may voice what ever choices you prefer, but I have used LVM on a raid array for many years (at home) and have never encountered a problem that forced loss of data or time. Even with loss of 2 different HDDs in about 7 years span.

Please feel free to suggest an alternate means of managing file systems and drives which provides the same ease, flexibility, and reliability as LVM.

Note that I do not disagree about the potential risk of data loss that multiplies as the number of devices involved increase when used in JBOD arrangement. (this is also the problem with using raid 0). However, using a actual raid array (raid 5 or 6 is what I prefer) beneath the LVM mitigates that risk almost 100%

pan64 04-16-2024 01:13 AM

Quote:

Originally Posted by computersavvy (Post 6496227)
We all are entitled to our own opinions.
LVM has a definite use, and is also very easy to use.
It is flexible and robust so home use is just as simple as any other location.

In fact, with the currently available drive sizes (both SSD and HDD) a user is forced to 1) over provision file system partitions in anticipation of growth, 2) shutdown and manipulate partition sizes when a critical partition fills up, or 3) use LVM or similar to provide the ability to manage file system sizes on the fly without interrupting operations. This applies to those with systems at home as well as large enterprise servers.

You may voice what ever choices you prefer, but I have used LVM on a raid array for many years (at home) and have never encountered a problem that forced loss of data or time. Even with loss of 2 different HDDs in about 7 years span.

Please feel free to suggest an alternate means of managing file systems and drives which provides the same ease, flexibility, and reliability as LVM.

Note that I do not disagree about the potential risk of data loss that multiplies as the number of devices involved increase when used in JBOD arrangement. (this is also the problem with using raid 0). However, using a actual raid array (raid 5 or 6 is what I prefer) beneath the LVM mitigates that risk almost 100%

You know it is something like use ASERASERF because it is flexible, robust, smells good or can say tramway very well.
I don't care all about that, I just don't need that.
Usually if a partition is full I buy another disk (obviously newer, faster, bigger and can say earthquake too), move my old partition completely to the new device, and over. I don't need to do anything else with it. Additionally I don't want to use the old and slow device any more, therefore extending its partitions does not solve anything.
Having spare space on my disks to be able to manage file system sizes is ok for me. Also there is no need to use raid. OS can be reinstalled in an hour, everything important is backed up into another storage, so I can recover anything any time.
There was only one issue in my life with spinning disks, one of them went into deadlock and stopped to work. Anyway, I don't use old disks.

lvm_ 04-16-2024 03:15 AM

Quote:

Originally Posted by computersavvy (Post 6496227)
Please feel free to suggest an alternate means of managing file systems and drives which provides the same ease, flexibility, and reliability as LVM.

There is a way which is way more simple, efficient and reliable: you don't. There is no need to fiddle with filesystems, you create a create single one which spans the whole array and that's that. YAGNI. And even if you do, loop devices.

wpeckham 04-16-2024 10:16 AM

Quote:

Originally Posted by lvm_ (Post 6496263)
There is a way which is way more simple, efficient and reliable: you don't. There is no need to fiddle with filesystems, you create a create single one which spans the whole array and that's that. YAGNI. And even if you do, loop devices.

For some things that will suffice.
For others there are better options.
If you need maximum performance I find a large RAID 5 array using MDADM and LVM with EXT4 file systems tests fastest for database operations.
For my personal laptop use I prefer BTRFS without RAID or LVM, performance is not as important and BTRFS is more than good enough.

It all depends upon your needs, operation, and available resources. There is no single "right" answer.

If you identify a single WRONG answer you would have to justify that decision and explain what makes it "wrong". I am not seeing that here.

rclark 04-16-2024 04:06 PM

For my personal use ext4 works well for me. Easy to maintain. No need for LVM in any 'my' home systems (desktops/laptops/server/RPIs). Disk space is cheap, so no need to extend/resize etc. Good backups of data is all that is necessary. As said above, there is no 'right' answer for 'everyone'. Each has own set of criteria.


All times are GMT -5. The time now is 07:15 AM.