LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 05-11-2009, 05:12 AM   #1
Igby
LQ Newbie
 
Registered: May 2009
Posts: 13

Rep: Reputation: 0
How do you safely reduce a LVM partitions size?


Good Day,

3 of our servers are virtualized with Xen. I am currently working on a mail archive server.

Here is the details for the Logical volume:

--- Logical volume ---
LV Name /dev/storage/archive
VG Name storage
LV UUID NZe0HC-7GK5-cb3t-UMWs-310y-iPUA-F0P4X3
LV Write Access read/write
LV Status available
# open 1
LV Size 990.62 GB
Current LE 253600
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:10



I have recently increased the logical volume's size with:
lvextend -L +10000 /dev/storage/archive. The volume size successfully increased, but i do not see the changes reflect on the guest os of
Xen.

I have read in several mailing lists, that you should also increase the partition size with resize2fs, however i think this might be dangerous and could destroy data on the partition. If you could do it without destroying data that would be great.

This is the configuration for Xen guest:

kernel = "/boot/vmlinuz-xen-domU"
memory = 768
name = "archive"
vif = [ 'mac=00:16:3e:01:01:07,bridge=xenbr1' ]
disk = [ 'phy:/dev/storage/archive,sda1,w' ]
root = "/dev/sda1 ro"

I believe i'm left with only one option, to reduce the logical volume back to its previous size, with lvreduce, then create a new logical volume partition with lvcreate. I would like to know if this can be done without losing any data that resides on the partition.

I would appreciate suggestions or ideas on the best way to approach this issue.

Your help is much appreciated
 
Old 05-11-2009, 06:44 AM   #2
bhaslinux
Member
 
Registered: Oct 2003
Location: UnitedKingdom
Distribution: Debian Lenny
Posts: 351

Rep: Reputation: 47
since the LV is exported as sda1, i assume u have an ext3 file system inside the LV
if this is the case, you are missing resize2fs on the LV.

1. To reduce, use resize2fs to reduce the file system and then do the lvreduce
2. There is no danger in doing it online as resize2fs (in conjunction with ext2online) can do resizes live.
 
Old 05-11-2009, 07:34 AM   #3
Igby
LQ Newbie
 
Registered: May 2009
Posts: 13

Original Poster
Rep: Reputation: 0
I was hoping i could enlarge the partition.

This is what the manpage says, for enlarging :-(

The resize2fs program does not manipulate the size of partitions. If you wish to enlarge a filesystem, you must first make sure you can expand the size of the underlying partition first. This can be done using fdisk(8) by deleting the partition and recreating it with a larger size. When recreating the partition, make sure you create it
with the same starting disk cylinder as before! Otherwise, the resize
operation will certainly not work, and you may lose your entire filesystem.

The partition was 600GB prior to me extending it to 1TB with lvextend.

This is what i see:

fdisk -l

Disk /dev/sda1: 1063.6 GB, 1063675494400 bytes
255 heads, 63 sectors/track, 129317 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

archive:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 591G 548G 14G 98% /
tmpfs 385M 0 385M 0% /lib/init/rw
udev 10M 12K 10M 1% /dev
tmpfs 385M 8.0K 385M 1% /dev/shm

Any suggestions?

Last edited by Igby; 05-11-2009 at 07:38 AM. Reason: Didn't provide enough information
 
Old 05-11-2009, 08:01 AM   #4
bhaslinux
Member
 
Registered: Oct 2003
Location: UnitedKingdom
Distribution: Debian Lenny
Posts: 351

Rep: Reputation: 47
The resize2fs is difficult to be preformed inside the domU since there is no partition table as such
and sda1 is directly exported in the machine.

You might want to do resize2fs on the dom0.
I am sure this may not corrupt the data if it is not being used by domU but I remember reading somewhere that if you do the
resize in dom0 it will be taken up by domU and you can do a 'hot' resize. But i am not 100% sure of this. So
better backup the data before doing any 'dangerous' things to the file system.

try resize2fs on dom0 and the domU must have got the data space !
 
Old 05-12-2009, 12:41 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
to extend just do

resize2fs -p /dev/storage/archive

at the same level as you ran the lvextend
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reduce LVM Partition size without any data loss viral_Ahire Linux - Software 1 04-11-2008 04:42 PM
How to reduce LVM partition ^ Guillaume777 Linux - Software 1 08-27-2007 06:01 AM
LXer: Back Up (And Restore) LVM Partitions With LVM Snapshots LXer Syndicated Linux News 0 04-17-2007 12:16 PM
How to safely reduce kernel compile time? rollo Linux - General 5 10-21-2005 03:03 PM
reduce an LVM partition in Red Hat jhnsegers Linux - Software 0 11-25-2004 02:57 AM


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

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