LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-03-2022, 03:58 AM   #1
wearyhacker
LQ Newbie
 
Registered: Jan 2021
Posts: 9

Rep: Reputation: Disabled
Question Can pvresize handle adding space to the front (start) of the partition.


The title says it all.

If I resize a disk partition by adding space at the beginning of a partition instead of the end will pvresize handle this?

Does the partition editor I use to do this have any impact on this?

Is gparted clever enough to do this safely? For example moving the existing data to the start of the new partition so that the offsets are not affected, as it does with normal filesystem partitions.

I can think of many potential pitfalls. I wonder if it would be easier to add the space as a new pv.

Any comments?
 
Old 07-03-2022, 04:24 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by wearyhacker View Post
I wonder if it would be easier to add the space as a new pv.

Any comments?
Much safer.

Never tried it, and LVM is generally pretty accommodating, but it's "your foot, your gun". LVM is an emulation layer, so where the PEs actually reside shouldn't matter. But, like I said ...
 
Old 07-03-2022, 04:40 AM   #3
wearyhacker
LQ Newbie
 
Registered: Jan 2021
Posts: 9

Original Poster
Rep: Reputation: Disabled
I think I will probably go down the new pv route.

But looking into this has made me realise how much I did not know about the actions that higher level partition editors such as gparted perform when partitions are moved or resized. It is fairly obvious what goes on with normal filesystem partitions. But, I suspect, the only way I can find out what will happen when the partition is a lvm2 pv is to look at the code.
 
Old 07-03-2022, 04:49 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Too hard for me these days - I once tried looking at the memory management code for swap. Drove me to drink ...

It's only data - if you're of a mind, try it and see what happens. If it all goes down the drain, restore it and try something else.
 
Old 07-03-2022, 05:17 AM   #5
wearyhacker
LQ Newbie
 
Registered: Jan 2021
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
Too hard for me these days - I once tried looking at the memory management code for swap. Drove me to drink ...

It's only data - if you're of a mind, try it and see what happens. If it all goes down the drain, restore it and try something else.
LOL.

I just looked. Going to put my head in bucket of water now! Many many years ago I came across this comment in the change log of some code. It went something like this. (UK date style)

xx/yy/1971 - Super whizzy new code added.
xx/yy/1972 - When I first wrote this only two people understood it. God and myself. Now, God only knows.

Mind you this guy also used to sprinkle his code with pieces of poetry!
 
Old 07-03-2022, 08:42 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
There would not be any way to invoke pvresize on the enlarged partition. If you add space at the beginning, the partition will no longer begin with an LVM2 header, and pvresize will not recognize it.
 
1 members found this post helpful.
Old 07-03-2022, 01:01 PM   #7
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
You can use gparted to resize and relocate the partition. Properly done you would free the space before the partition, then relocate the partition into the new space while at the same time enlarging it. Doing that would handle the PV question. The PV is merely a partition or device and gparted handles that very nicely.

After the partition is resized then you can use the LVM tools to resize the LV and at the same time resize the file system.
 
Old 07-03-2022, 03:30 PM   #8
wearyhacker
LQ Newbie
 
Registered: Jan 2021
Posts: 9

Original Poster
Rep: Reputation: Disabled
The gparted code actually contains code to execute pvresize for you.
 
Old 07-04-2022, 08:00 AM   #9
wearyhacker
LQ Newbie
 
Registered: Jan 2021
Posts: 9

Original Poster
Rep: Reputation: Disabled
To answer my own question. It looks like it is possible to do this using gparted live disk or similar. The reason for using a live disk is because the lv in question is the system root.

The steps to do it are.

1. Boot the rescue disk (it must support lvm).
2. Launch gparted
3. Select the correct disk.
4. Select the correct lvm2 pv partition.
5. In the partition menu select deactivate. The resize/move option should now be enabled.
6. Resize/move the partition. This process should include a pvresize step.
7. Activate the pv partition.

Now the question is. "Am I feeling lucky?". The answer is not until I really need to do it :-).
 
Old 07-04-2022, 08:10 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
I still can't see why do you need it at all (what is it good for) and how does your steps will do that.
 
Old 07-04-2022, 09:57 AM   #11
wearyhacker
LQ Newbie
 
Registered: Jan 2021
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I still can't see why do you need it at all (what is it good for) and how does your steps will do that.
I was just documenting those steps for posterity. As I said am not going to use them yet. Before I do use them I will probably verify them on a test disk. If I do the test, I might remember to post the results back. If any else wants to try them, feel free.
 
  


Reply

Tags
lvm, lvm2, pvresize



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LVM: pvresize not using all available space blockdump Linux - Server 1 02-27-2015 04:51 AM
file-based locking initialization failed after pvresize clahti Linux - Software 1 07-31-2013 04:50 PM
[SOLVED] Adding disk space to root logical volume with pvresize and lvextend bortbortresson Linux - Software 13 12-27-2009 11:59 PM
"pvresize" an existing PV after it's been resized on a SAN? thechic Red Hat 0 11-10-2008 11:52 PM
pvresize oversteps partition sizes on purpose? phatbrain101 Linux - Software 2 09-17-2007 06:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration