From: Duane Clark <duane_clark@pacbell.net>
To: linux-lvm@redhat.com
Subject: [linux-lvm] Howto suggestion: Reducing a logical volume
Date: Wed, 16 Aug 2006 17:23:20 -0700 [thread overview]
Message-ID: <44E3B6F8.3000207@pacbell.net> (raw)
I just recently finished reducing a logical volume, and thought I would
pass along some suggested steps. I had found the HOWTO and referred to
it, and it helped with a couple of critical steps. But it was not
sufficient because, well, I only have a single large root partition, and
that was the one I wanted to shrink. And fundamental to doing the
reduction is that one needs to be able to unmount the partition. If you
have another machine around to stick the disk in, that is easy. But it
turned out to not be terribly difficult without that.
Of course it may be that I did things the hard way, and that would be
worth knowing too ;)
Mainly, the reason for this was that I wanted to install another OS
version in a separate logical volume on an existing disk. The disk had
the (FC4) default layout of two volumes, one for / and one for swap,
occupying most of the disk in a single group. So without further ado, my
suggestions for the howto (Section 11.10.)...
If the volume to be reduced is the root partition that you currently
have booted, then you won't be able to unmount, and a somewhat more
involved procedure is needed. If you already have another bootable
harddisk, then perhaps the easiest thing to do is boot that disk with
the disk to be modified as a secondary disk, and then just modify the
volume using the above mentioned steps.
If you don't have another bootable harddisk, presumably you have a
bootable OS installation cdrom/dvd, which can be booted in linux rescue
mode. That is, allow the CD to boot, and at the first prompt, type
"linux rescue". If that works, you are on your way. When a prompt is
given asking whether you want it to find and mount partitions, select
"skip". I found that if I allowed it to mount the root partition, I
could not unmount it. After a few more moments, it should finish and
drop you to a prompt.
In rescue mode, the vgscan, etc commands are not directly present, but
the executable lvm is, which can do all those things. When you run lvm,
you will get a new prompt, where you type lvm commands. In the
following, the linux prompt is '#' and the lvm prompt is '>'. And I have
used the default group/volume names supplied by Fedora, since presumably
a newbie reading this will have used the defaults, and anyone else will
be able to figure out what to change.
When we skipped allowing linux rescue to find and mount the logical
volumes, it also did not create device files we will need to use. So the
first task to be accomplished is to use lvm to create those device files.
# lvm
> vgscan
It should should show the existing group or groups. The first task
required is to activate the group.
> vgchange -a y VolGroup00
Then generate the device files.
> vgmknodes
> exit
Now shrink the existing filesystem to something a bit smaller than what
you want the final filesystem size to be. You will first need to run
fsck on the filesystem. For example, I wanted a 36GByte final size, so I
used:
# e2fsck -f /dev/mapper/VolGroup00-LogVol00
# resize2fs /dev/mapper/VolGroup00-LogVol00 35G
Now we can shrink the volume to the desired size. Yes, the lvreduce
command uses a different device file name.
# lvm
> lvreduce -L36G /dev/VolGroup00/LogVol00
> exit
Now expand the filesystem to the full size of the volume. Notice that no
size parameter is used in the resize command this time.
# resize2fs /dev/mapper/VolGroup00-LogVol00
Now you can try to mount and look at it.
# mkdir /mnt/sysimage
# mount /dev/mapper/VolGroup00-LogVol00 /mnt/sysimage
# df
# ls /mnt/sysimage
It should show up with the right 36GByte size, and everything intact.
reply other threads:[~2006-08-17 0:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44E3B6F8.3000207@pacbell.net \
--to=duane_clark@pacbell.net \
--cc=linux-lvm@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).