This is going to be far, far easier if you can create a Kickstart script or otherwise do this during the installation phase. I will assume here that you have one big logical volume mounted to root.
You will first need to boot to Rescue Mode (without mounting the local filesystem) and shrink your root logical volume. You can't create any new ones if all of your available space on the physical volume is consumed.
- Boot to Rescue Mode
lvm vgchange -a y
e2fsck -f /dev/vg0/root
(Or whatever your root Logical Volume is named here.)
resize2fs /dev/vg0/root <targeted size -10MB or so>
Your target size can't be smaller than the amount of data or you will truncate your filesystem!
lvm lvreduce -L <targeted size>
resize2fs /dev/vg0/root
I shrink the filesystem to slightly below targeted size and then grow it back to the logical volumes capacity to save the funky block size / rounding / math crap. If I was good at math, I'd have finished my C.S. degree and not become a Sysadmin.
Then, you need to move the current directories for your targeted mount points to get them out of the way. (Move /var
to /var2
, /home
to /home2
, etc.)
Then, you can create new logical volumes, new mount points and /etc/fstab
entries, mount every thing, then sync your data back from /var2
to the new /var
logical volume. (Repeat as needed.)
This part assumes that the root filesystem (which contains /tmp) was mounted. You can do it manually with mount
or reboot and let Rescue Mode do it this time around.
Basically:
lvcreate -ntmp -L<size> /dev/vg0
(Replace vg0 with your Volume Group like you did above.)
mkfs.ext3 -L tmp /dev/vg0/tmp
mv /tmp /tmp2
mkdir /tmp
- Add entry to
/etc/fstab
for your new mount point.
mount -a
- Move /tmp2's data back into the new /tmp. Delete /tmp2.
pvs
andlvs
.