Skip to main content
added 44 characters in body
Source Link

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)

/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)

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)

swap   10GB
/boot  500MB
/      50GB
/home  The Rest (About    1,8TB)

So, my plan was the following: 1 unmount /home 2 do an e2fsck on /dev/md3 3 resize2fs /dev/md3 to a size of about 990GB to have 10GB as a security margin 4 mdadm resize /dev/md3 to 1TB 5 resize2fs without naming a size to grow it to the maximum available on the new md

  1. unmount /home
  2. do an e2fsck on /dev/md3
  3. resize2fs /dev/md3 to a size of about 990GB to have 10GB as a security margin
  4. mdadm resize /dev/md3 to 1TB
  5. 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) 6 add new partitions sda/b6 in the now free space 7 make them a raid 8 mount it to /mnt 9 copy over /var/www 10 diff /var/www and /mnt just to make sure 11 rm -rf * in /var/www 12 mount /dev/md4 to /var/www, and add a corresponding entry into fstab to make it permanent.

  1. add new partitions sda/b6 in the now free space
  2. make them a raid
  3. mount it to /mnt
  4. copy over /var/www
  5. diff /var/www and /mnt just to make sure
  6. rm -rf * in /var/www
  7. mount /dev/md4 to /var/www, and add a corresponding entry into fstab to make it permanent.

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)

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)

So, my plan was the following: 1 unmount /home 2 do an e2fsck on /dev/md3 3 resize2fs /dev/md3 to a size of about 990GB to have 10GB as a security margin 4 mdadm resize /dev/md3 to 1TB 5 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) 6 add new partitions sda/b6 in the now free space 7 make them a raid 8 mount it to /mnt 9 copy over /var/www 10 diff /var/www and /mnt just to make sure 11 rm -rf * in /var/www 12 mount /dev/md4 to /var/www, and add a corresponding entry into fstab to make it permanent.

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)

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)

So, my plan was the following:

  1. unmount /home
  2. do an e2fsck on /dev/md3
  3. resize2fs /dev/md3 to a size of about 990GB to have 10GB as a security margin
  4. mdadm resize /dev/md3 to 1TB
  5. 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)

  1. add new partitions sda/b6 in the now free space
  2. make them a raid
  3. mount it to /mnt
  4. copy over /var/www
  5. diff /var/www and /mnt just to make sure
  6. rm -rf * in /var/www
  7. mount /dev/md4 to /var/www, and add a corresponding entry into fstab to make it permanent.
Source Link

Shrinking a RAID1 to free up space on the HDD for a new RAID1 Partition

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: 1 unmount /home 2 do an e2fsck on /dev/md3 3 resize2fs /dev/md3 to a size of about 990GB to have 10GB as a security margin 4 mdadm resize /dev/md3 to 1TB 5 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) 6 add new partitions sda/b6 in the now free space 7 make them a raid 8 mount it to /mnt 9 copy over /var/www 10 diff /var/www and /mnt just to make sure 11 rm -rf * in /var/www 12 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?