Resize Switch DynamicallyExtended Logical Volume Successfully

| 1 Comment

p { margin-bottom: 0.08in; }

I used the “-r” option to resize
the underlying filesystem with the “lvextend” command for the
first time. The “-r” option allowed the logical volume &
filesystem to be extended with just one command. I saw the “-r” switch there on the man page and decided to try it!

To top it off the partition I extended
was my root “/” partition. The man page says that the “-r”
option calls the “fsadm” command to extend or resize the
filesystem.

What caused me to use this option was
that I just did a fresh install of one of my Fedora Linux systems
that has served alternately as a game server, web server, backup
server. Currently in this iteration it will take over as my new game
server. I have all of my files in two logical volumes on a separate
physical drive from my OS drive so that I will not have to worry
about data files I don’t wish overwritten during OS installs or I can
just take that drive to the next server I build and manually mount it
on that new server.

The drive of course is using LVM and
is its own volume group so that information is on the drive is
imported easily into LVM. I have two logical volumes on this physical
drive within the volume group..

One logical volume I mount to /home
and the other to /usr/local/games. These logical volumes have files I
have downloaded to various home directories and working files &
binaries for the games I host on my servers.

I didn’t include this extra physical
drive that I store my data on as a target during the fresh Fedora 14
install, so I needed to unmount the /home that was created with the
install and then mount my logical volume that holds data for my home
directories I mount on “/home/” and game data which I mount on
“/usr/local/games/”.

The reason I ended up extending my “/”
partition was that I didn’t pay attention to how much space the
installation of Fedora 14 was giving “/home” or “/”. I
didn’t even intend for the install to make the “/home” a separate
partition but oh well it did and I needed the space the install
allocated for “/home” to move to “/”.

I won’t speak about partition sizing
and the reasoning’s for that since I started getting really liberal
with that with the partitions I used to be strict on since drives are
so large now.

Anyway not a big deal to those of you
who may have used this “-r” feature before but I never have, even
with HP-UX. I truthfully don’t know if HP-UX has the “-r” switch
for the lvextend command something I’ll research and find out later
since the person who was bringing by my HP-UX box hasn’t brought it
by yet.

Normally you would do the “lvextend”
and then use the “resize2” command which doesn’t take long but
its always nice to use the least amount of commands.

Anyway this is what I did:

  1. Logged in as root in “gdm”
    (Gnome Xwindows) after commenting out the “root” user lines in
    /etc/pamd.d/gdm & etc/pamd.d/gdm-password. I know, not what you
    are supposed to do but I didn’t feel like rebooting and wanted
    multiple windows up.

  2. Killed the processes that were
    still running on /home

    1. fuser -ku /home (didn’t work)

    2. lsof /home (showed pid)

    3. kill -9 “pid”

  3. unmout /home

  4. vgdisplay -v|more (showed my vg
    that was on my physical drive)

  5. vi /etc/ fstab

    1. /dev/mapper/home_vg-lvol1 /home
      ext4 defaults 1 2

    2. /dev/mapper/home_vg-lvol2
      /usr/local/games ext4 defaults 1 2

  6. mount -a

  7. df -kh

  8. lvchange -a n
    /dev/vg_system-name/lv_home

  9. lvdisplay
    /dev/vg_system-name/lv_home

  10. lvremove
    /dev/vg_system-name/lv_home

  11. llvextend -l <PE -total size>
    /dev/vg_system-name/lv_root -r

    1. Since its “/” it will not
      unmout but perform an online filesystem extension even if you
      answer “no’.

That was it in a nutshell, took much
longer to write this post! This is just my story of a new switch I
found and decided to play with if you decide to try this please if
your system or data is valuable back it up and do your research for
your environment! Make sure you have the online LVM packages etc. if
you want to do an online filesystem extension. As they say mileage
will vary!

LVM is different for HP-UX than with
Linux and a bit different on other UNIX systems as well so I couldn’t
find the command to see if the physical extents were concurrent but I
suspect they are not. Just an FYI. You know please post, I ran out of
time tonight and didn’t look much further.

This isn’t meant to be a tutorial but
if you have any question please ask! Maybe I’ll clean this up at a
later time and present it in more of a tutorial fashion with better
explanations but its time for me to go to bed!

Man how verbose no wonder I don’t
post as much as I should!

Dude I even have charts from Wikipedia:

Linux Logical Volume Management (LVM) v1 Diagram

Image via Wikipedia

Unix filesystem

Image via Wikipedia

Enhanced by Zemanta

One Comment

Leave a Reply

Required fields are marked *.


%d