Have you or do you know someone that has performed a reinstall of an OS and left the partition options at the default ie everything under / and omitted setting up the partitions?
All is not lost.. this guide was performed on a RHEL 5.5 install and worked flawlessly. :)
In a nutshell, we're dumping the filesystem on to the swap partition, repartitioning the drive and then dumping the data back into the respective partitions. The pitfall in this is your swap partition HAS to be large enough to store your data. Are we sitting comfortably?... then I'll begin.
execute lvdisplay to get LogVol01 size, then do a df -h and see if / will fit on swap.
Copy the FS to SWAP.
1) Edit /boot/grub/grub.conf
change root=/dev/VolGroup00/LogVol00 to root=/dev/VolGroup00/LogVol01 (the default swap partition)
2) Edit /etc/fstab
comment /dev/VolGroup00/LogVol00 and change LogVol01 to / ext3 (swap becomes the new root)
3) run swapoff -a
4) mkfs -t ext3 -m 1 -v /dev/VolGroup00/LogVol01 (format the swap partition)
5) mount /dev/VolGroup00/LogVol01 /mnt
6) tar clf - -C / .| tar xf - -C /mnt (this is better than cp as it keeps the file attributes)
clf - create, sym links, file -C / Change directory to / <source> .| pass everything to xf - extract, file -C /mnt Change directory to /mnt <destination>
REBOOT
(execute a df -h and check the size of /, it should be the size of swap previous)
Create the new partitions.
7) lvremove /dev/VolGroup00/LogVol00 (this completely deletes the / partition)
8) lvcreate -L30G -n rootvol VolGroup00 (this creates a 30G partition named rootvol)
9) lvcreate -L30G -n usrlocalvol VolGroup00
10) lvcreate -L4G -n varvol VolGroup00
11) lvcreate -L4G -n optvol VolGroup00
12) mkfs -t ext3 -m 1 -v /dev/VolGroup00/rootvol (format the new partitions)
13) mkfs -t ext3 -m 1 -v /dev/VolGroup00/usrlocalvol
14) mkfs -t ext3 -m 1 -v /dev/VolGroup00/varvol
15) mkfs -t ext3 -m 1 -v /dev/VolGroup00/optvol
16) vi /etc/fstab and add the new partitions: (make the partitions available)
/dev/VolGroup00/rootvol / ext3 defaults 1 1
/dev/VolGroup00/usrlocalvol /usr/local ext3 defaults 1 1
/dev/VolGroup00/varvol /var ext3 defaults 1 1
/dev/VolGroup00/optvol /opt ext3 defaults 1 1
Now to restore the data:
17) mkdir /media/root /media/var /media/opt /media/usr
18) mount /dev/VolGroup00/rootvol /media/root
19) mount /dev/VolGroup00/usrlocalvol /media/usr
20) mount /dev/VolGroup00/varvol /media/var
21) mount /dev/VolGroup00/optvol /media/opt
22) tar clf - -C / .| tar xf - -C /media/root
23) tar clf - -C /var/ .| tar xf - -C /media/var
24) tar clf - -C /opt/ .| tar xf - -C /media/opt
25) tar clf - -C /usr/local/ .| tar xf - -C /media/usr
26) edit /media/root/etc/fstab (ensure new mounts are present & comment
LogVol01)
27) edit /boot/grub/grub.conf
change root=/dev/VolGroup00/LogVol01 to root=/dev/VolGroup00/rootvol
28) rm -rf /media/root/usr/local/* /media/root/var/* /media/root/opt/*
REBOOT
Reactivate the swap partition
29) lvremove /dev/VolGroup00/LogVol01
30) lvcreate -L16G -n swapvol VolGroup00
31) mkswap /dev/VolGroup00/swapvol
32) Edit /etc/fstab
change LogVol01 / ext3 to swapvol swap swap
33) swapon /dev/VolGroup00/swapvol
REBOOT
Congratulations.. your server is now in a sensible condition. Sit back, relax and give yourself a pat on the back for not looking like a complete n00b!