centos centos lvm resizing guide
TRANSCRIPT
Home
CentOS 6
CentOS 5.6CentOS 5.5
CentOS 5.4
CentOS 5.3
Search
Installing LCMP stack on CentOS 5.5 Apache with mod_pagespeed on CentOS 5.5
CentOS LVM Resizing Guide
On November 3, 2010, in CentOS 5.2, CentOS 5.3, CentOS 5.4, CentOS 5.5, by How2CentOS
Since the release of CentOS 5.5 we noticed that the default CentOS install assigns a considerable
amount of its available storage space to Swap. If you don’t catch this during the installation don’t worry, Logical
Volume Manager or LVM will rectify this post install.
LVM is a logical volume manager for the Linux kernel; it manages disk drives and similar mass-storage devices,
in particular large ones. The term “volume” refers to a disk drive or partition thereof.
Before we start just some general housekeeping. The XEN virtual CentOS 5.5 server (base install) in this tutorial
was assigned 10GB of storage with the default partitioning layout.
Let check the amount of disk space available on the file system.
# df -h
Filesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol004.9G 2.4G 2.3G 51% /
/dev/xvda1 99M 23M 72M 25% /boottmpfs 4.0G 0 4.0G 0% /dev/shm
Let see the attributes of the logical volumes like size, read/write status, snapshot information
# lvdisplay
— Logical volume —LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00LV UUID oFXKGg-nBPo-Fk27-3ino-zaHZ-cEcv-fk0dS0
LV Write Access read/writeLV Status available
# open 1LV Size 5.00 GBCurrent LE 160
Segments 1Allocation inherit
Read ahead sectors auto– currently set to 256
Block device 253:0
— Logical volume —LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00LV UUID Ntffw7-dqPh-Rjhy-rWLv-BGA0-iGik-LoyHET
LV Write Access read/write
LV Status available# open 1
LV Size 4.88 GBCurrent LE 156
Segments 1Allocation inherit
Read ahead sectors auto– currently set to 256
Block device 253:1
Let’s begin but first turning off swap on the Swap Logical Volume
# swapoff /dev/VolGroup00/LogVol01
Once swap is off let’s take the disk space we require.
# lvresize -L -4GB /dev/VolGroup00/LogVol01WARNING: Reducing active logical volume to 896.00 MBTHIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce LogVol01? [y/n]: yReducing logical volume LogVol01 to 896.00 MB
Logical volume LogVol01 successfully resized
Now let’s add what we removed to the main Logical Volume.
# lvresize -L +4GB /dev/VolGroup00/LogVol00Extending logical volume LogVol00 to 9.00 GB
Logical volume LogVol00 successfully resized
Resize the File System
# resize2fs -p /dev/VolGroup00/LogVol00resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing requiredPerforming an on-line resize of /dev/VolGroup00/LogVol00 to 2359296 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 2359296 blocks long.
Rebuild the swap partition.
# mkswap /dev/VolGroup00/LogVol01
Setting up swapspace version 1, size = 939520 kB
Turn swap on.
# swapon /dev/VolGroup00/LogVol01
Let’s check the amount of disk space available and LVM attributes to see if our changes took effect.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol008.8G 2.4G 6.0G 28% /
/dev/xvda1 99M 23M 72M 25% /boot
tmpfs 4.0G 0 4.0G 0% /dev/shm
# lvdisplay
— Logical volume —
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00LV UUID oFXKGg-nBPo-Fk27-3ino-zaHZ-cEcv-fk0dS0
LV Write Access read/write
LV Status available# open 1
LV Size 9.00 GB
Current LE 288
Segments 2Allocation inherit
Read ahead sectors auto
– currently set to 256Block device 253:0
— Logical volume —
LV Name /dev/VolGroup00/LogVol01VG Name VolGroup00
LV UUID Ntffw7-dqPh-Rjhy-rWLv-BGA0-iGik-LoyHET
LV Write Access read/write
LV Status available# open 1
LV Size 896.00 MB
Current LE 28
Segments 1Allocation inherit
Read ahead sectors auto
– currently set to 256Block device 253:1
Related posts:
1. ISCSI Initiator Configuration and Mulitipathing Guide
Like
2. Installing XEN on CentOS 5.x
3. CentOS: The most popular Linux distribution for web servers
4. CentOS: Change Hostname5. How to install XEN 3.4.1 on CentOS 5.4
If you enjoyed this article, please consider sharing it!
Tagged with: CentOS • CentOS 5.5
Add New Comment
Showing 5 comments
Sort by Popular now Subscribe by email Subscribe by RSS
Thanks!
Like
NICE !!
Like
Thank you so much for the accurate and detailed post. Very helpful!!
Like
Post as …Image
Денис Пищухин 1 week ago
Reply
Thalamus 2 months ago
Reply
Pgpresto 5 months ago
Reply
ventura10 6 months ago
1 how2centos @
0
Thanks man, you saved my day!
Like
Yay! Excellent post for a quick space recovery. Thanks!
Like
Hi!Welcometo
How2CentOS!
Here you'll a find a repository of tutorials and everything relating to CentOS, CentOS 5.7 and CentOS 6including some other distros like RedHat and Fedora.
" Installing #Bacula on #CentOS 6 #CentOS6 http://goo.gl/ijBgs " — How2CentOS
Home
Home
[How2CentOS] CentOS Tutorials and Howtos
Pages
CentOS 6
CentOS 5.6
CentOS 5.5
CentOS 5.4CentOS 5.3
Reply
James Tanaglia 8 months ago
Reply
Stay In Touch
CentOS 6CentOS 5.6
CentOS 5.5
CentOS 5.4
CentOS 5.3
More
Here you'll a find a repository of tutorials and everything relating to CentOS, CentOS 5.7 and CentOS 6
including some other distros like RedHat and Fedora.
© 2010 How 2 #CentOS