I've two closely related questions, so I'll keep them in one SF question:
Question 1
I've a Linux (debian) server that must have minimal downtime. The disk has two partitions, one is /
(ext3) and one is swap. I'd like to move /home
to its own partition as it was originally for some reason built with everything in one partition; I however don't want to take the machine down for multiple minutes to resize the disk and create a new partition.
Is it possible for me to resize /
while its in use?
Question 2
I'd like to reinstall this same server eventually. Once again, without downtime. Once I've resized the disk using the answer provided to Question 1, can I somehow install on a new partition while the original system is still online. So I can simply reboot into the new OS and delete the old OS partition and resize the new partition to takeover the space of the old now delete partition.
Thanks for your responses to this somewhat weird question, unpleasantly I'm a tad short of servers for this particular project. I unfortunately suspect this cannot be done but thought I best check before drawing my conclusions.
Some notes and questions:
- Perhaps there are possible solution might be for me to boot into a network hosted kernel somehow?
- A second disk isn't possible, this machine is unfortunately in a very inflexible hosting provider.
- Would getting rid of the swap temporarily make this possible? That would give me 2GB unpartitioned space to play with.
Question 1:
No. from man resize2fs "If the filesystem is mounted, it can be used to expand the size of the mounted filesystem, assuming the kernel supports on-line resizing."
Question 2:
Yes you can install on a different partition while its running using a chroot.
Buy it an extra disk. Or if you don't have physical access, migrate stuff to another server while its online, then do a quick switch.
Answer to edits:
Yes, there are additional options for doing stuff with the network that can help you have less downtime. It depends on exactly what your server is doing and what options you have. I gave a general solution of moving your data to another server while both are online, stop server 1, start server 2 doing what server 1 was doing. Fix server 1, then go back to it in the same way.
Without the network, you could do swapoff, install linux in the swap using a chroot, reboot or try something with kexec, and quickly shrink your other partition and add a new one.
Get yourself a new hosting provider. As Ian already answered, you can't shrink a mounted ext3 filesystem, but once you've got the space you can do the reinstall in a chroot (with debootstrap) and do a reboot to switch.
Removing swap is a possibility for getting the space for part 2, in that if you can squeeze everything you need to reinstall into the swap partition, you can boot that partition, fiddle the current root partition to make it a bit smaller and turn it into /home, make a new swap partition in the newly freed space, and continue on your way from there.
Given the downtime that will be necessary, and the chances of screwing something up and making a huge mess, and not to mention the cost of your time to do it all (including the cost required to clean up in the event of a screwup) I'd fix your hosting situation first and foremost. Just because you can do this stuff if you really have to doesn't mean you should be forced into doing it by a useless supplier.
Oh, and next time, give LVM a try, and only allocate space as you need it. Online expansion of ext3 is a godsend.