LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-13-2010, 01:38 PM   #1
shva
Member
 
Registered: Feb 2009
Distribution: Fedora, Arch, Debian, Ubuntu
Posts: 56

Rep: Reputation: 15
how to free up an LVM logic volumn into a physical partition


In my computer there is only one hard disk with two partitions. /dev/sda1 is mounted as /boot, while /dev/sda2 is used as LVM. In that LVM partition I have only one logic volumn group with several logic volumns. One of the logic volumns is mounted as /data, and now I want to remove this logic volumn, free up the space and make it another physical partition outside LVM as /dev/sda3. Can someone help me on this, especially the procedure of steps I should go through ? Thanks.
 
Old 05-13-2010, 02:16 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,974
Blog Entries: 5

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
You can't really do what you're asking. It is easy enough to get rid of data filesystem and remove the Logical Volume (LV) but the space in the partition is allocated to the Volume Group (VG) and the LV is a subdivision of that. Therefore removing the LV increase free space in the VG but the VG is still taking up the same amount of allocated space in the partition.

However what you CAN do is create a new LV using free space from the VG for whatever purpose you intended to use /dev/sda3 for. This is the main point in LVM - it allows you to reallocate resources more quickly without having to worry about worry about other partitions.

Why do you feel you need a new partition rather than a new LV? (That is to say what is the purpose of /dev/sda3 in this scenario?)
 
Old 05-13-2010, 03:30 PM   #3
shva
Member
 
Registered: Feb 2009
Distribution: Fedora, Arch, Debian, Ubuntu
Posts: 56

Original Poster
Rep: Reputation: 15
After removing a LV, can I use vgreduce to shrink the volumn group in the physical volumn, followed by pvresize? ( I am not sure about these commands though...)

The reason I want to do this is that I want to compile another Linux system in the same hard disk. I am not sure how to boot from a LVM partition, so I just need a new partition /dev/sda3
 
Old 05-13-2010, 03:44 PM   #4
GazL
Senior Member
 
Registered: May 2008
Posts: 3,365

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
No vgreduce is for removing PVs not LVs. It's not what you want.

Have a read of the pvresize and pvmove man-pages. Those look like the commands you'll need (along with lvremove which you'll use to get rid of your /data lv).

It's going to be messy and somewhat risky no matter what you do. Make sure you have a good backup.
 
Old 05-14-2010, 02:58 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
I think you're going to have to wipe sda2 and start over. The point is, a disk partition eg sda2 is at the bottom, which is then set to a PV type (fdisk type 8e), then VG goes on top and LV on top of that.
http://tldp.org/HOWTO/LVM-HOWTO/
 
Old 05-14-2010, 03:28 AM   #6
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 91
The previous 2 Guru's are correct - your best bet is to back up your data (if any) and restart.

I also suggest you do a bit of reading on LVM in terms of how it works from a logical perspective before your start.

LVM is a great technology; however it can be painful if you misconfigure something and realize afterwards.

If you can explain what/how you want to divide the space you have available I can give you some tips on using LVM to achieve your desired goal
 
Old 05-14-2010, 03:34 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,533
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
chrism01's advice is normally dependable so I hesitate to suggest it but the pvresize command might do what you want. Depending on the location of LVs within the LVM partition /dev/sda2 this may not be possible.

Regarding "The reason I want to do this is that I want to compile another Linux system in the same hard disk. I am not sure how to boot from a LVM partition, so I just need a new partition /dev/sda3" you would not have to boot the new distro from a LVM partition; you could boot it from /boot after which it would mount / from an LVM volume. This is a common arrangement.

I used to run ubuntu 8.04 with a LVM volume for / but concluded that the advantages of doing so outweighed the disadvantages and switched to an ordinary partition on migrating to Slackware. If you conclude similarly, you may want to bite the bullet and take this opportunity to have an ordinary partition for the new distro's / .

The easiest way, if you can get another HDD, perhaps temporarily, would be:
  1. Create a partition on it for LVM (let's call it /dev/sdb1).
  2. Add /dev/sdb1 as a PV to the existing VG.
  3. Migrate the LVs from the /dev/sda2 PV to the /dev/sdb1 PV.
  4. Remove the existing PV from the VG.
  5. Re-partition /dev/sda as required (including a new, smaller partition for LVM -- let's call it /dev/sda6)
  6. Add /dev/sda6 as a PV to the VG.
  7. Migrate the LVs from the /dev/sdb1 PV to the /dev/sda6 PV.
  8. Remove the /dev/sda6 PV from the VG.
  9. Win!
Backups would be a valuable insurance!
 
1 members found this post helpful.
Old 05-14-2010, 09:27 AM   #8
shva
Member
 
Registered: Feb 2009
Distribution: Fedora, Arch, Debian, Ubuntu
Posts: 56

Original Poster
Rep: Reputation: 15
Thanks all guys. The reason I considered creating a new partition /dev/sda3/ is that I wanted to try out Linux From Scratch. If LFS's root system is a logic volumn in LVM partition, I remember I had to compile something (initramfs) that supports LVM and put it into /boot (which is /dev/sda1). I am currently not sure how to do it. That's why I need a new /dev/sda3.
 
  


Reply

Tags
lvm


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LVM Physical Volume -- Not Shrinking? CoderMan Linux - Software 4 02-23-2010 06:09 PM
LVM which physical device thllgo Linux - Server 2 09-20-2007 12:18 PM
LVM -creating physical volume satimis Linux - General 2 08-10-2006 01:44 AM
LVM Physical Volume Lucky_Sevin Linux - Software 2 01-10-2006 10:44 AM
How to check up a disk on presence of mistakes - logic and physical? ukrainet Linux - Newbie 2 11-19-2004 08:54 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration