lvm

Renaming a Logical Volume (how to rename)

Wednesday, October 29th, 2008 | Techie | No Comments

Today I was asked to rename a logical volume (something I hadn’t done before, but figured it was quite easy). Here’s what I ran:

lvm help

Which showed me the option of:

lvrename Rename a logical volume

Ah.. I thought to myself, this should be easy enough. So I did a quick poke at the man pages of lvmrename which netted me

lvrename [-A|--autobackup {y|n}] [-d|--debug] [-f|--force] [-h|--help] [-t|--test] [-v|--verbose] [--version]
VolumeGroupName OldLogicalVolumeName NewLogicalVolumeName

note: ugggg sorry for the formatting.. thank you wordpress.

So off I went, and here’s what I did:

sudo umount /mountpoint
sudo lvrename /dev/volgroupname/lgvold /dev/volgroupname/lgvnew
sudo vi /etc/fstab
fixed the required fstab settings
sudo mount -a (or you can mount each one individually, but in my situation I was able to just run umouna -a).

That’s it. Simple as that.

If you do happen to rename while mounted you’ll not be able to unmount. In that case just change to the new location in fstab and bounce the box (yes, that’s the easiest way.. sinec the device will keep showing busy, even though lsof and everything reports it shouldn’t be).

That’s it.. hope someone finds this helpful.

Tags: , ,

Resizing Logical Volume (LVM) on ext3

Sunday, October 19th, 2008 | Techie | 1 Comment

I’ve recieved a few emails from people asking “How can I resize an LVM (proper term would be resizing a Logical Volume) on their system”.

In this posting i’ll touch on only ext3 since that’s the default fs. Later, I’ll touch others if it’s requested.

There are a few steps you have to take to resize a partition. First, you have to resize the filesystem (be sure to do this before you reduce the lv, as that could cause data loss).

In this instance i’ll be resizing a mount location at /app. If you want to shrink the /home partition make sure you go into runlvl 3 (sudo init 3) and get out of the /home directory (cd /).

To resize the filesystem lets unmount it by running:

sudo umount /apps

First run a check on the file system:

sudo fs2chk -f /dev/volumegroup/logicalvolume

note: you can find the volume group name, or logical volume name you can use vgscan and lvscan (both are located in /sbin/)

Now lets resize the ext3 partition:

sudo resize2fs /dev/volumegroup/logicalvolume 10G

note: 10G is the NEW size that you want it to be

Once those are completed, you can finally resize the Logical Volume (isn’t this what we wanted in the first place?), to do this do:

sudo lvreduce -L 10G /dev/volumegroup/logicalvolume

note: Use the same output you defined in the resize2fs command.

Lets remount our partition and jump for joy:

sudo mount /dev/volumegroup/logicalvolume /app

note: If this mount point is defined in /etc/fstab, you can remount via sudo mount -a (this will mount everything in /etc/fstab).

Bonus:
If you wanted this space for an existing logical volume, you can run lvextend -L XXG /dev/volumegroup/logicalvolume.
Note: XX is the space you took away from the other reduced partition.


Tags: , ,

Search

Polls

Do you think having RDP on a Linux Host important in the enterprise space?

View Results

Loading ... Loading ...

Powered by