Last weekend I had to change the size of the root partition of a Fedora Core 12 system. Reason for it was a) the size of the partition where the root file system is located is too large and b) the remaining free space shall be used in another partition (for a different purpose). Due to the circumstances it was not an option to use the disk space within the same partition. The obviously tricky part, however, was clear to me right from the beginning: As the system is running in a productive environment I had set up the system on a software RAID using mdadm (as it is normally done when you use the partitionizing assistant within anaconda during setup of Fedora). How to resize an existing ext3 partition which is not located on software RAID can be done quite easy. Having to understand this part of the task the following webpages helped me to get the basic principle:
Let me briefly comment on the second link above. What is written there is correct: The size of the software RAID is reduced after doing the steps in section 2.1, but compare it to the first link! mdadm does not touch the partition table (via fdisk) and it does good to do so (paradigm No. 2 of the Unix philosophy: Make each program do one thing well.). Consequently, you changed the size of your RAID “filesystem”, but you did not change the size of the partitions.
Adoption Changing also the Partition Size
I therefore adopted my approach as follows:
- Having booted with Fedora Core’s installation DVD using the rescue mode, I ran e2fsck on the md device
- Afterwards I ran resize2fs with a slightly smaller size than I want later (wanting 26 GB at the end I used 25GB, so 1 GB less)
- Using mdadm I stopped the raid array entirely
- By executing fdisk I deleted the partitions on both hard disk where the raid array was located and recreated the raid partitions (with partition type FD) manually again; this time with the correct – not the slightly reduced! – size (quite similarly on how it is described in http://www.howtoforge.com/linux_resizing_ext3_partitions
- Using mdadm I created a new software RAID array which writes a new set of software RAID metadata to the partitions.
- Now I ran resize2fs again not specifying any size as last argument which means “take the largest value possbile” – so it took everything that the software RAID system delivered.
I decided to use this approach, because it can be quite tricky to find out how much size the metadata for the software RAID takes at the end of your partitions. By being able to let resize2fs decide on its own you can safely ignore this question. So good so far.
However, no site on the net discussed about what might happen, if you are doing as described above and promptly I fell into a very ugly problem: The system did not boot anymore (please note: the filesystem on the software RAID on which I executed the procedure above has to be mounted as root partition) saying that the root file system could not be found! I took me two hours to figure out what was happening.