Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm running Ubuntu 10.04 and I would like to move /var to another partition using a python script. I found some directions that I thought were pretty good, but they call for switching to runlevel 1 (single-user mode) to prevent changes to /var while it is moved.

Is switching the runlevel necessary? Do I just call os.system('init 1') directly in my script? Can I put the system back in its normal state just by calling os.system('init 2') after the script is done?

When I'm connected over SSH I get booted out when I run init 1 myself, even if I'm connected as root. If I'm at the keyboard when I do init 1 I get the message: Will now switch to single-user mode, Give root password for maintenance (or type Control-D to continue):. My root password does not work at that point so I've tried Control-D and logging in as a user. runlevel then says the system is back at runlevel 2, but I can't reconnect by SSH until I reboot the system.

Any help understanding what is going on is appreciated!

share|improve this question
add comment

1 Answer

For moving /var as a whole, I'd recommend booting from a live CD (or USB) unless you're very confident in what you're doing (and if you were, you wouldn't be asking this question).

Separating /var isn't particularly useful anyway. If your / partition is almost full, look for a large directory or two that you can move away more easily, such as /var/www or /var/mail or /var/cache. Oh, and run apt-get clean to make sure you're not worrying over a large amount of downloaded and installed .deb packages.

share|improve this answer
    
It's a web server on a virtual host, so I'm wary of overflowing log files and such. I don't think I would be able to do the live boot. Thanks for the tip on apt-get clean though. –  M. Dudley Oct 25 '11 at 0:06
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.