Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 unfortuantly suspect this cannot be done but thought I best check before drawing my conclusions.

Edit: A possible solution might be for me to boot into a network hosted kernel somehow?

Edit2: A second disk isn't possible, this machine is unfortuantly in a very inflexible hosting provider.

Edit3: Would getting rid of the swap temporarily make this possible? That would give me 2GB unpartitioned space to play with.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
Second disk isn't possible, see the edit :-( Question 2 isn't possible without Question 1. –  Adam Gibbins May 3 '09 at 0:51
add comment

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.

share|improve this answer
    
Thanks, I think you're right, that does indeed currently appear to be the best solution. Just for reference, I wasn't the one that originally configured this server, I would have in no way set it up as it is nor was I the one that commissioned the hosting provider. Unfortuantly I'm left picking up the pieces. –  Adam Gibbins May 3 '09 at 1:26
1  
Time to put your 'splaining hat on, and tell the boss what you need to fix, and why. Then get out there and get it fixed. –  womble May 3 '09 at 2:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.