LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 11-04-2011, 08:54 PM   #1
gcmartin
LQ Newbie
 
Registered: Aug 2001
Posts: 14

Rep: Reputation: 0
I have a LVM2 need and am confused.


I have just completed building a test system. It has a boot area (kernel) and a LVM2 volume.

I would like to reduce the size of the LVM2 volume to add a swap partition to the system. I have found lots of information of growing but the info on reduction is very confusing. I am lost and am appealing. I saw this, but found that the problem being addressed does not match mine.

Here's my single drive system info. And, I would like to have a 16GB Swap partition.
Code:
# mount
/dev/mapper/pve-root on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/mapper/pve-data on /var/lib/vz type ext3 (rw)
/dev/sda1 on /boot type ext3 (rw)

# df -l
dev/mapper/pve-root ... /
tmpfs ... /lib/ini/rw
udev ... /dev
tmpfs ... /dev/shm    
/dev/mapper/pve-data ... /var/lib/vz
/dev/sda1 ... /boot

# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

  Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          66      524288   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              66       60801   487859712   8e  Linux LVM

Disk /dev/dm-0: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000


Disk /dev/dm-1: 103.0 GB, 103079215104 bytes
255 heads, 63 sectors/track, 12532 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000


Disk /dev/dm-2: 387.9 GB, 387901816832 bytes
255 heads, 63 sectors/track, 47159 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000


# lvdisplay
  --- Logical volume ---
 LV Name                /dev/pve/swap
 VG Name                pve
 LV UUID                fSULxh-H69J-3iu6-6fGv-zyUf-vux4-KUMMp9
 LV Write Access        read/write
 LV Status              available
 # open                 1
 LV Size                4.00 GB
 Current LE             1024
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           254:0
  
 --- Logical volume ---
 LV Name                /dev/pve/root
 VG Name                pve
 LV UUID                64Zfbj-BOdy-Icqm-93wW-Hv6V-eChf-c3ROyL
 LV Write Access        read/write
 LV Status              available
 # open                 1
 LV Size                96.00 GB
 Current LE             24576
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           254:1
  
 --- Logical volume ---
 LV Name                /dev/pve/data
 VG Name                pve
 LV UUID                jSTxnG-kpLx-eyac-SWwy-hgoY-Wy9N-lPgf0l
 LV Write Access        read/write
 LV Status              available
 # open                 1
 LV Size                361.26 GB
 Current LE             92483
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           254:2

# vgdisplay
 --- Volume group ---
 VG Name               pve
 System ID             
 Format                lvm2
 Metadata Areas        1
 Metadata Sequence No  4
 VG Access             read/write
 VG Status             resizable
 MAX LV                0
 Cur LV                3
 Open LV               3
 Max PV                0
 Cur PV                1
 Act PV                1
 VG Size               465.26 GB
 PE Size               4.00 MB
 Total PE              119106
 Alloc PE / Size       118083 / 461.26 GB
 Free  PE / Size       1023 / 4.00 GB
 VG UUID               EPCWMl-xc1n-3xUB-V5TD-YQ1l-6pZY-4NZ464
 
# pvdisplay -m
 --- Physical volume ---
 PV Name               /dev/sda2
 VG Name               pve
 PV Size               465.26 GB / not usable 1.50 MB
 Allocatable           yes
 PE Size (KByte)       4096
 Total PE              119106
 Free PE               1023
 Allocated PE          118083
 PV UUID               JogU1D-cKPA-dQNL-2EwU-YTZT-4kV2-iGkHk6
  
 --- Physical Segments ---
 Physical extent 0 to 1023:
   Logical volume    /dev/pve/swap
   Logical extents    0 to 1023
 Physical extent 1024 to 25599:
   Logical volume    /dev/pve/root
   Logical extents    0 to 24575
 Physical extent 25600 to 118082:
   Logical volume    /dev/pve/data
   Logical extents    0 to 92482
 Physical extent 118083 to 119105:
   FREE
Any guidance would be appreciated.

Last edited by gcmartin; 11-04-2011 at 08:58 PM.
 
Old 11-04-2011, 09:21 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,488

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
What does "swapon -s" show ?. I suspect you'll find no (technical) need to allocate swap outside of LVM.
 
Old 11-04-2011, 09:56 PM   #3
gcmartin
LQ Newbie
 
Registered: Aug 2001
Posts: 14

Original Poster
Rep: Reputation: 0
Request if backup in place

BACKUP is not a problem. I OK on this. But, maybe a recommendation on how I should proceed. What should I designate to reduce? And which toolset? I venturing into a new world of reduction. GParted is not a help.

Last edited by gcmartin; 11-04-2011 at 09:59 PM.
 
Old 11-04-2011, 10:28 PM   #4
tollingalong
Member
 
Registered: Nov 2011
Posts: 41

Rep: Reputation: Disabled
Are you ok with a swap file? You need to be root to do this.

Create a 16GB file:
dd if=/dev/zero of=/swapfile_01 bs=1M count=16000
mkswap /swapfile_01
swapon /swapfile_01

Add the following line at the bottom of your /etc/fstab so the file will load as a swapfile when you reboot.
/swapfile_01 swap swap defaults 0 0

Reducing the size of ext3 file systems didn't always go well for me in the past. It's doable but do you REALLLY need it?

Why do you need the added swap? If you do a free and look at the cached, buffers and free that's what your processes will use (ie apps). The used memory is a cache of your disk so if you need to read from it, the reads will be faster.


free -m
total used free shared buffers cached
Mem: 3763 3612 150 0 0 3422
-/+ buffers/cache: 189 3573
Swap: 0 0 0


If you still want to try resizing here's a page that's a nice read:
http://www.howtoforge.com/linux_resi...xt3_partitions
 
Old 11-04-2011, 10:29 PM   #5
tollingalong
Member
 
Registered: Nov 2011
Posts: 41

Rep: Reputation: Disabled
Oh one more thing. It took me 7.5 minutes to create a 16GB file on a 2nd gen 40GB SSD. I'm assuming it'll take you a lot longer.
 
Old 11-04-2011, 11:26 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,488

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
You didn't answer my question.
 
Old 11-04-2011, 11:32 PM   #7
gcmartin
LQ Newbie
 
Registered: Aug 2001
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks but i really want to reduce the LVM2

Thanks for the assistance thus far.

But, I really want help reducing the LVM such that it ends with 16GB of free space. Then, I can use GParted to make the free space a SWAP partition.

So the help I need is understanding on how to go about
  1. reducing the LVM partttion (VG first/middle/last steps)
  2. reducing LVM size, itself, to create free space on the drive
if someone can guide me with the above steps, GParted can use that free space to create the SWAP partition.

Thanks.

Last edited by gcmartin; 11-04-2011 at 11:33 PM.
 
Old 11-04-2011, 11:41 PM   #8
ptrivino
Member
 
Registered: May 2008
Location: San Diego CA
Distribution: CentOS
Posts: 34

Rep: Reputation: 5
Use the Nancy Reagan method...

...just say No!

I just went through a good deal of research on reducing an LVM2 VG/LV, as an exercise (I had installed CentOS with 'defaults' and it does a big LVM on the whole disk). I wanted to gain experience with LVM so I thought I'd try it. I have a fair amount of Linux experience as well as other OS'es and I can tell you it is *possible* to do it but only if you are absolutely desperate.

Long story short, I searched LQ, CentOS.org, and many other sites for LVM info (tldp.org LVM-HOWTO, and Redhat Mag LVM2/resize fs, and some others) and had a plan to do it, until I got to the 'pvresize' step. The PE's were spread out over the whole disk and while they (apparently) can be moved, it's a bear. I did not continue as this was just a learning exercise.

So unless you have no other choice, I'd suggest you make another choice. If you want to do it as a learning tool, on a test system, by all means give it a try!
 
Old 11-04-2011, 11:59 PM   #9
gcmartin
LQ Newbie
 
Registered: Aug 2001
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks @Ptrivino.

I have a new system with little to no data that cannot be recreated. I don't think I have any PEs that are scattered about as you have.

Did you find a paper or a solution that led you to try this? I like to use it if you can point me to one.

There's lots of experiences on increasing, but the reductions seemingly are very lacking.

If anyone has any solutions tucked away or any knowledge I'll give it a run. I had hope that I could publish something with Pics for others to use as a guide for how to reduce a single drive system where the LVM has consumed the total drive. And, like me, they would want to reduce it for a good reason.

Thanks for any help.
 
Old 11-05-2011, 02:26 AM   #10
gcmartin
LQ Newbie
 
Registered: Aug 2001
Posts: 14

Original Poster
Rep: Reputation: 0
Reduce VG size - Reduce LVM2 size for drive free space

Found it! Looks like this will do the trick. but, there appears to be some confusion on the final step for creating the free space.

Does anyone know if the pvreduce (physical volume) will leave an open free space area on the drive?

Thanks in advance, if you know the answer.

Last edited by gcmartin; 11-05-2011 at 02:53 AM.
 
  


Reply

Tags
lvm2


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
lvm2 sarhang Linux - Newbie 1 01-30-2008 06:23 PM
Confused nay Very Confused chrystlenight Suse/Novell 3 08-28-2007 06:57 PM
Lvm2 fakie_flip Linux - Software 3 08-07-2006 09:05 AM
Using LVM2 chandru.in Linux - Hardware 0 08-30-2005 08:33 AM
Lvm2 pritambhavsar Programming 1 03-03-2005 08:22 PM


All times are GMT -5. The time now is 07:45 PM.

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