I set up a webserver a while ago and made a mistake. I do have the following:
/dev/md0 swap (made from sda1 and sdb1)
/dev/md1 /boot (made from sda2 and sdb2)
/dev/md2 / (made from sda3 and sdb3)
/dev/md3 /home (made from sda5 and sdb5)
(sda4 and sdb4 are the extended partitions)
I mistyped while setting up the RAID (I was using an installer script), and ended up with the following sizes:
swap 10GB
/boot 500MB
/ 50GB
/home The Rest (About 1,8TB)
Everything worked fine.. until I uploaded about 80GB of files into /var/www, and the transfer crashed half way. Everything went nuts. After a while I found out that I simply filled up the / partition which crashed the MySQL server, and immediately recognized that making / so small was dumb (or at least I should have put /var/www on a different partition). Well, the server is in use now for quite some time and I really am not interested in setting up everything again. I backed everything up, just in case, but as you all know, setting up a server is work, and setting it up to a known state while using backups is even more work. so I would like to fix the problem.
What I would like to do now is the following:
- shrink the /home partition to about 1TB
- add a new partition in the now free space
- move over /var/www
- mount the new partition in that location
So, my plan was the following:
- unmount /home
- do an e2fsck on /dev/md3
- resize2fs /dev/md3 to a size of about 990GB to have 10GB as a security margin
- mdadm resize /dev/md3 to 1TB
- resize2fs without naming a size to grow it to the maximum available on the new md
(so far so good, everything up to this point worked)
- add new partitions sda/b6 in the now free space
- make them a raid
- mount it to /mnt
- copy over /var/www
- diff /var/www and /mnt just to make sure
- rm -rf * in /var/www
- mount /dev/md4 to /var/www, and add a corresponding entry into fstab to make it permanent.
I am now stuck at no. 6: The raid is shrinked, /dev/md3 has a size of about 1TB, everything is perfectly fine, but the partitions /dev/sda5 and /dev/sdb5 are still the old size. wWhat did I miss? Shouldnt the partitions have shrinked with the md? How do I shrink them without breaking the raid?