I have been a user of virtualmin GPL for a long time now, but since I moved to CentOS 6 64bits, I cannot create domains anymore.
This is the message I get when I create a new domain with DNS zone:
Adding new DNS zone …
… BIND DNS domain failed! : Failed to replace /var/named/chroot/etc/named.conf with /var/named/chroot/etc/named.conf.webmintmp.4440 : Device or resource busy at …/web-lib-funcs.pl line 1360.
Adding new virtual website …
… Apache website failed! : Failed to replace /var/named/chroot/etc/named.conf with /var/named/chroot/etc/named.conf.webmintmp.4440 : Device or resource busy at …/web-lib-funcs.pl line 1360.
I would replace this file manually later, but it seems it is deleted, or it never existed.
Could you please provide some light on this issue? I am using virtualmin 3.88.gpl GPL, and I have tried rebooting and making simple changes to isolate the problem without success. Could it be related to the differences between centos 5 and centos 6?
Well, things should work just fine on CentOS 6, there’s a lot of folks using that now. It looks like, for some reason, something is holding the file "/var/named/chroot/etc/named.conf " open.
If you run this command, what output do you receive:
It seems that in CentOS 6 the file /etc/named.conf is copied every time after daemon restart in chroot location. After that, it can’t be moved/replaced with another file (as webmin is trying to do):
# mv /var/named/chroot/etc/named.conf /tmp/named.conf
mv: cannot move ‘/var/named/chroot/etc/named.conf’ to ‘/tmp/named.conf’: Device or resource busy
The process ‘named’ itself block access to this file.
So, the solution is to change some parameters in webmin:
Webmin -> Servers -> BIND DNS Server -> Module Config
In “Configuration category -> BIND paths” change “Is named.conf under chroot directory?” parameter to “No”; then webmin/virtualmin will modify named.conf from /etc location of root system file. Obviously, after named daemon restart this file is copied in chroot location so everything should be fine.
In “Configuration category -> System configuration” change “PID file is under chroot directory?” parameter to “No”, as webmin doesn’t read pid from chrooted file and reports me that BIND is not started (event it was).
I had a look into this, and it seems that the cause is the way CentOS 6 sets up the named chroot environment. The best fix for now would be to stop using the chroot completely, as it has few real security benefits in my opinion. To do this :
Stop BIND
Edit /etc/sysconfig/named and remove the ROOTDIR line.
If you are a newbie, maybe it is more secure for you to accept Jamie’s Cameron solution. Remove (or comment) the line with ROOTDIR from file /etc/sysconfig/named
My solution is a little more complicated and is useful only if you really want chroot named.
Method 1: from Webmin interface -> Others -> File Manager, go to /etc/sysconfig directory and then edit ‘named’ file
Method 2: using putty (and maybe midnight commander) in ssh console go to /etc/sysconfig directory and edit ‘named’ file (use your favourite file editor: mcedit, vi, joe etc.)
We will be release a fix for this shortly, but until then the fix is to set “Chroot directory to run BIND under” to “None” and “Command to find chroot directory” to “Use fixed directory above” . Even when BIND is running chroot’d on CentOS 6, Webmin doesn’t need to know about it due to the different way the chroot is setup compared to other systems…