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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-04-2011, 07:54 PM
|
#1
|
|
LQ Newbie
Registered: Aug 2001
Posts: 14
Rep:
|
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 07:58 PM.
|
|
|
|
11-04-2011, 08:21 PM
|
#2
|
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,231
|
What does "swapon -s" show ?. I suspect you'll find no (technical) need to allocate swap outside of LVM.
|
|
|
|
11-04-2011, 08:56 PM
|
#3
|
|
LQ Newbie
Registered: Aug 2001
Posts: 14
Original Poster
Rep:
|
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 08:59 PM.
|
|
|
|
11-04-2011, 09:28 PM
|
#4
|
|
Member
Registered: Nov 2011
Posts: 40
Rep: 
|
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
|
|
|
|
11-04-2011, 09:29 PM
|
#5
|
|
Member
Registered: Nov 2011
Posts: 40
Rep: 
|
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.
|
|
|
|
11-04-2011, 10:26 PM
|
#6
|
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,231
|
You didn't answer my question.
|
|
|
|
11-04-2011, 10:32 PM
|
#7
|
|
LQ Newbie
Registered: Aug 2001
Posts: 14
Original Poster
Rep:
|
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 - reducing the LVM partttion (VG first/middle/last steps)
- 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 10:33 PM.
|
|
|
|
11-04-2011, 10:41 PM
|
#8
|
|
Member
Registered: May 2008
Location: San Diego CA
Distribution: CentOS
Posts: 34
Rep:
|
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!
|
|
|
|
11-04-2011, 10:59 PM
|
#9
|
|
LQ Newbie
Registered: Aug 2001
Posts: 14
Original Poster
Rep:
|
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.
|
|
|
|
11-05-2011, 01:26 AM
|
#10
|
|
LQ Newbie
Registered: Aug 2001
Posts: 14
Original Poster
Rep:
|
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 01:53 AM.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
|
lvm2
|
sarhang |
Linux - Newbie |
1 |
01-30-2008 05:23 PM |
|
Confused nay Very Confused
|
chrystlenight |
Suse/Novell |
3 |
08-28-2007 05:57 PM |
|
Lvm2
|
fakie_flip |
Linux - Software |
3 |
08-07-2006 08:05 AM |
|
Using LVM2
|
chandru.in |
Linux - Hardware |
0 |
08-30-2005 07:33 AM |
|
Lvm2
|
pritambhavsar |
Programming |
1 |
03-03-2005 07:22 PM |
All times are GMT -5. The time now is 08:38 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|