How do you safely reduce a LVM partitions size?
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
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
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
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.
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:
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
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 !
to extend just do
resize2fs -p /dev/storage/archive
at the same level as you ran the lvextend
|All times are GMT -5. The time now is 12:05 AM.|