The last year that ive been doing I.T Support in London, Ive seen quite a few linux servers which dont have sufficent root partition space.
So here's a procedure ive used several times to extend a ext3 root partiton and filesystem on redhat enterprise 5
If you use ext3 ( not LVM) as your root patition and you run out of space this procedure will enable you to create a larger partition, move existing root files to the new partition and expand the filesystem to new size.
You need to have enough spare disk space on your disk to create a large parition, or fit an additional disk to the server.
This guide is detailing resize2fs utility only. Other third party tools can change the partition itself, but this entry details our current procedure.
In this example partion 5 contains the original root partition and partition 6 is the next available spare area of disk
1.Always backup the partition you will be copying in case of errors.
2. boot from redhat cd1/dvd ( rescue CD or first boot cd)
at boot prompt type
:'linux rescue'
when prompted, dont mount the disk partitions you need to change
(umount /dev/sda5 if needed)
3. create the new partition 9no6) using fdisk
fdisk /dev/sda
(m)ake a new partion at the correct size ( partion 6)
(w)rite the partiton to disk
4. reboot and boot from rhel cd again for partition table to be loaded
fsck.ext3 -f /dev/sda5 ( check original fsystem is clean)
5. copy the old partion files to the new larger partition
dd if=/dev/sda5 of=/dev/sd6
(This can take some time, no progress is show)
Note: dd copies original partiton contents and filesystem size ( inodes), so when you next reboot it will apprear the new partion size has shrunk to the old partition size.
This is becase dd does a track by track copy of the original data including any spare filesystem.
As we hav'nt create the filesystem on the new disk so it is using exactly the same data as partition 5.
Logical Volume Manager (LVM) can be then used to create inodes upto the end of the new partiion size.
Remember resize2fs is not able to extend a partion itself ,only any unused filesystem within that partition.
6. Next you need to extend inodes to continue to the end of the new partion,but keeping the original copied root data untouched .
/sbin/resize2fs -p /dev/sda5 9000M ( extends the file system to 9 GB, the actual partition max size)
This will only extend the filesystem to the current partition size. As mentioned above, if the partition is not big enough (d)elete and (w)wrie the new partion again in fdisk.
Once the correct size and disk dump has completed ,delete the orginal partition on the disk.
In example if you remove sda5 then the new partition sda6 becomes sda5, so there is not need to change partition lables or edit /etc/fstab
Occasionally we have seen that you might need to rewite the journel if the disk doesnt mount properly on first reboot.
Boot from cdrom again,
tune2fs -j /dev/sda5
or tune2fs -O has_journal /dev/sda5 ( to remove the journel or make partition on an older ext version)
Have fun
Akbel
Open Source IT Support for Business in Sussex. Technical Blog detailing LJE Ltd,. projects and common IT Support issues and experiences. Contact us if you have any Business related IT Support Queries in Sussex, Kent. Supporting Market Data Technology and Investment Banks since 1990, offer Premium Linux and Microsoft Small Business Solutions, Red Hat Linux Small Business I.T Support experts: Linux, Samba, Citadel Microsoft SBS replacement Servers, Firewall, VOIP, VPN
No comments:
Post a Comment