Changing partition sizes with LVM
Magnus Runesson
mr-ubuntu at linuxalert.org
Tue Oct 17 19:05:22 UTC 2006
On Tue, 2006-10-17 at 14:27 -0400, stan wrote:
> I've got an Ubuntu machine that I have sliced up 2Tb worth of dsks (4 x
> 500G). Now I find out I need to make one partion smaller, and move the
> resulting free space to one of the other partions.
>
> This is a Daper machine. Is this do-able? Can any kind sould point me to a
> HOWTO on this?
>
Yes it is doable. Be aware that reducing disk and file systems is always
a bit risky. So I recommend you to backup your data. I assume according
to the subject that you have LVM based partitions.
The four steps you should perform are:
1. Reduce the file system
2. Reduce the logical volume
3. Expand the other logical volume.
4. Expand the file system.
To be on the safe side: I recommend you to backup your data.
Everything needs to be done as superuser so do:
sudo -s
Step 1.
Assuming you have ext3. You will use the command ext2resize to shrink
the file system. Read the manpage carefully.
Unmount the volume.
ext2resize /device/... newSize
Di not make it smaller than the amount of data you have.
Step 2.
Reduce de device/logical volume.
Be careful to not reduce the device to a smaler size than the file
system, then you will be lost. I have done that by my self, its not
funny. Also here read the man page carefully before doing anything.
lvresize -L newSize LogicalVolumePath
Step 3
Expand the other logical volume
Use lvresize again.
Step 4
Expand the other file system.
Unmount the partiton
Run ext2resize as in step 1.
Mount the file systems again.
When setting up new system I usually recommends to only create the
partitions as large as you need them in the beginning. And have the rest
of the disk as spare. There are fewer things that can go wrong when
expanding, than shrinking file systems. In this way we can avoid
shrinking file systems.
Note that you can also shrink the area on large file systems that are
reserved to the root user. Use tune2fs and the m or r option.
Good luck!
/Magnus
PS! I recommend you to backup your data. Did I say that? DS!
> --
> Unix is very simple, but it takes a genius to understand the simplicity.
> (Dennis Ritchie)
--
Magnus Runesson <mr-ubuntu at linuxalert.org>
Linuxalert
More information about the ubuntu-users
mailing list