Web Hosting Talk







View Full Version : Repartitioning a server remotely: thoughts on methodology


pmak0
12-20-2001, 02:25 PM
I got a Duron 1GHz server from RackShack.net recently, but I found the default partition settings to be sub-optimal: / is 6 GB, and /usr is 13 GB. This distributes most of the space in a partition that doesn't need more than 4 GB, taking away a lot of room from /home. I proceeded to see if it's possible to reconfigure the machine's partitions remotely.

There's a utility called GNU parted that allows one to resize a machine's partitions, without loosing data. However, no utility can resize a partition while it is mounted! But a partition can't be unmounted while the machine is running. Normally, someone repartitioning a machine would boot from a floppy (so that all the partitions are unmounted), but since I don't have physical access to the machine, I can't do that.

I've come up with a possible way of doing this by tag-teaming the partitions.

Setup a special standalone telnetd that does not need any files other than the executable to run (not even /etc/*). Put the telnetd on both / and /usr, and run both telnetds, each on a different port. Make sure that they both work. Also, copy all the system executables (/bin/*) into /usr. This way, the system has enough functionality available with only one partition online.

Use "fuser" to determine which processes are preventing the / partition from being unmounted. Kill them, being careful not to lock yourself out. Now unmount the / partition, and downsize it to how you want.

Now remount the / partition, and start the special telnetd on it; make sure it works. Then use "fuser" to determine which processes are preventing /usr from being unmounted; kill them, unmount /usr, and now I can resize the rest of the drive.

...All that said, I have not tried this, and I'd rather not, considering the risks involved. I asked RackShack about it and am waiting for a response; they probably have a technician on hand who could repartition the box for me. I thought my stupid idea would be interesting to share, though.

pmak0
12-21-2001, 12:18 AM
New idea: Given that my server has 512 MB of physical RAM, I setup a 100 MB ramdisk and install all the critical executables on it, including telnetd. Then maybe I can unmount all the partitions. No tag-teaming (as described above) required.

bitserve
12-21-2001, 02:28 AM
You know what would make it really easy is a second drive.

pmak0
12-21-2001, 06:10 AM
Ok, that was a stupid idea.

<RS-Owen-ASA> what happened?
<pmak> I was trying to adjust the partition sizes so that I could make better use of the space, but I think I didn't unmount the filesystem correctly before adjusting it with GNU parted.
<RS-Owen-ASA> then you probably lost your partition completely\
<pmak> There wasn't anything irreplacable on that machine.
<pmak> Are you sure my box is hosed, though? It was working partially just before I rebooted it.
<RS-Owen-ASA> not positive but we will look at it when we have a chance

I think the problem was that I was not able to unmount the / partition properly. Even though "umount -v /" claimed to have unmounted the root partition, it only remounted it in read-only mode. Then apparently it got screwed up when I resized the partitions.

Maybe it's not possible to unmount the root partition of a running machine because it has to contain /dev? I'm not sure. At any rate, I made a big mess this time. Me and my stupid ideas... It might have worked if I understood Linux filesystems better.

sbrad
12-22-2001, 01:44 PM
oops

priyadi
12-23-2001, 09:37 AM
As far as I can tell it is not possible to unmount the root filesystem, even on single user mode where there is minimal running processes. I think the reason is because the root filesystem contain the directories /usr /home that also mounted.
It will be much easier to do that if you get a second drive.

bobcares
12-23-2001, 12:41 PM
If it's a live server or you do not want to waste money on support then do not attempt this act...
Why not make softlinks to some of the big directories in the smaller partition. This would let you utilise the space without playing with the system.
Repartitioning dynamically on a live server is plain suicidal. Anyway it is just my opinion...

Have a great day :)

regards
amar