Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like ssh, sudo su and umount /home and run diagnostic on it. Is there a runlevel I can used to close X and other process using /home while keeping network access? Or another way?

thanks

share|improve this question

2 Answers 2

up vote 3 down vote accepted

First, log out all user manually, then ssh with root.

Use "lsof | grep home" to find remaining process that use /home and kill them all.

You can umount.

share|improve this answer

/home is only typically in use when users are logged in. The root user has a /root home specifically so the root user is not dependent upon additional mount points.

Enable root SSH login

For Ubuntu this means you need to give root a password in order to login via ssh:

https://help.ubuntu.com/community/RootSudo#Enabling the root account

Consider that the root account may be disabled from SSH access by default, verify the setting in /etc/ssh/sshd_config:

PermitRootLogin yes

Logoff users and prevent new logins

To kick users off in a multi-user environment one would normally change to the single-user run level 1. However this is pretty much a console or serial port only task as sshd by default is configured only for run levels 2, 3, 4, and 5, and that you will likely lose your ssh connection.

http://www.debianadmin.com/debian-and-ubuntu-linux-run-levels.html

The not so great alternative is judicious use of killall --user but has to be applied to each and every user. Only the login (pseudo) terminal process needs to be killed and a more refined approach can be taken, for example:

skill -KILL -v /dev/pts/*

The next problem is prevent users immediate sign back in. You can create the file /etc/nologin to prevent user logins, you need to ensure pam_nologin.so is enabled on Linux for all PAM methods such as SSH:

http://www.novell.com/support/dynamickc.do?cmd=show&forward=nonthreadedKC&docType=kc&externalId=7007116&sliceId=1

This is also provided by the shutdown -k command:

-k Only send out the warning messages and disable logins, do not actually bring the system down.

Finally

You can unmount /home.

share|improve this answer
    
Instead of giving root a password, I gave it a public key. It allow to log the same way. –  Guillaume Coté Aug 29 '11 at 5:10
    
However, telinit 1 also close the ssh connection and prevent connecting back. –  Guillaume Coté Aug 29 '11 at 5:12
    
Unless we can configure sshd to run in level 1, it is just trouble going there. –  Guillaume Coté Aug 29 '11 at 5:25

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.