Discussion:
[Lxc-users] PostgreSQL - "sh: cannot create /dve/null: Permission denied" - LXC Issue?
Patrick Kevin McCaffrey
2011-12-20 07:49:25 UTC
Permalink
I'm running into this issue when trying to set up a PostgreSQL server inside one of my containers. The Postgre mailing list seems suspect of my LXC setup, so I thought I'd see if anyone has any input. The outline of my problem is below. I've got Postgre installed/configured, but I can't run the "initdb" command as seen below...



----- Forwarded Message -----
From: "Tom Lane" <tgl at sss.pgh.pa.us>
To: "Patrick Kevin McCaffrey" <pkm at uwm.edu>
Cc: "Steve Atkins" <steve at blighty.com>, "PostgreSQL General" <pgsql-general at postgresql.org>
Sent: Monday, December 19, 2011 3:01:20 PM
Subject: Re: [GENERAL] New User: PostgreSQL Setup - "The Program 'postgress' is needed by initdb but was not found in the same directory..."
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
sh: cannot create /dev/null: Permission denied
This line suggests that your environment is broken - the chroot container hasn't been set up fully.
fgets failure: Success
This isn't good, either. I'm suspicious of your lxc chroot.
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
This suggests that your build broke. Is there a /usr/local/pgsql/bin/postgres binary?
I think nobody pointed out yet that those last two messages are almost
certainly direct results of the first one. initdb tries to verify that
the postgres binary is of a matching version by doing (more or less,
this isn't cut-and-pasted from the sources)

system("postgres -V 2>/dev/null")

and seeing what version string it gets back. If /dev/null isn't
writable inside your LXC chroot, then the shell will fail to execute
that command (producing the first error message), and what initdb will
get back is only an empty string, which I think explains the "fgets"
whinge and definitely explains the wrong-version complaint.

regards, tom lane
---------------------------------------------------------------------


Any and all help would be appreciated. My containers all seem to be working fine otherwise. The only thing I've really got set up at this point is email (Dovecot/Postfix), but it's functioning fine in a container that was constructed in the same way that this one (for Postgre) was.

Pat
Jäkel, Guido
2011-12-20 08:06:49 UTC
Permalink
Dear Patrick,

As I understand /dev/null isn't writable in your container. That's definitely a wrong configuration.

Please check, that there is a real device node for /dev/null (and others) in your container and you have it (and others) in the lxc device access control list (lxc.cgroup.devices.allow = c 1:3 rw)

Note that -- depending on the linux flavor in your LXC container -- you might have to populate /dev by your own, because it's not reasonable to run udev or something like this inside a container.

Greetings

Guido
Patrick Kevin McCaffrey
2011-12-21 06:47:31 UTC
Permalink
There is indeed a node at /dev/null. The configuration that I base my containers off of is as follows:

--------------------------------------------------------------------------------------------

lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = /lxc/debian_squeeze_template/rootfs
lxc.cgroup.devices.deny = a
lxc.network.type = veth
lxc.network.link = br0
#lxc.network.veth.pair =
lxc.network.ipv4 = 192.168.80.100
# /dev/null and zero
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
# consoles
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
lxc.cgroup.devices.allow = c 4:0 rwm
lxc.cgroup.devices.allow = c 4:1 rwm
# /dev/{,u}random
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 5:2 rwm
# rtc
lxc.cgroup.devices.allow = c 254:0 rwm

# mounts point
lxc.mount.entry=proc /lxc/debian_squeeze_template//rootfs/proc proc nodev,noexec,nosuid 0 0
lxc.mount.entry=sysfs /lxc/debian_squeeze_template//rootfs/sys sysfs defaults 0 0

-------------------------------------------------------------------------------------------------------

Everything stays the same from container to container except for the IP and the rootfs. I think I have it set up right? Am I missing it?

Pat



----- Original Message -----
From: "Guido J?kel" <G.Jaekel at dnb.de>
To: "Patrick Kevin McCaffrey" <pkm at uwm.edu>, "lxc-users" <lxc-users at lists.sourceforge.net>
Sent: Tuesday, December 20, 2011 2:06:49 AM
Subject: Re: [Lxc-users] PostgreSQL - "sh: cannot create /dev/null: Permission denied" - LXC Issue?

Dear Patrick,

As I understand /dev/null isn't writable in your container. That's definitely a wrong configuration.

Please check, that there is a real device node for /dev/null (and others) in your container and you have it (and others) in the lxc device access control list (lxc.cgroup.devices.allow = c 1:3 rw)

Note that -- depending on the linux flavor in your LXC container -- you might have to populate /dev by your own, because it's not reasonable to run udev or something like this inside a container.

Greetings

Guido
Dennis T Kaplan
2011-12-23 22:13:39 UTC
Permalink
You need a name as in:
lxc.utsname = vm0

I have a wiki you can check & follow:
http://wiki.robotamer.com/linux/lxc
Gordon Henderson
2011-12-24 19:52:26 UTC
Permalink
Post by Patrick Kevin McCaffrey
I'm running into this issue when trying to set up a PostgreSQL server
inside one of my containers. The Postgre mailing list seems suspect of
my LXC setup, so I thought I'd see if anyone has any input. The outline
of my problem is below. I've got Postgre installed/configured, but I
can't run the "initdb" command as seen below...
Subject: Re: [GENERAL] New User: PostgreSQL Setup - "The Program 'postgress' is needed by initdb but was not found in the same directory..."
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
sh: cannot create /dev/null: Permission denied
If the other replies aren't helping, I'm wondering if your running your
container under NFS?

I've been doing this recently and having issues with NFSv3 & 4, but 2 is
OK. I think it's something to do with ACSs possibly being enabled, but
I've not had time to check further - as it works with good old v2 and
that's OK for me, for now...

Gordon
Patrick Kevin McCaffrey
2012-01-17 07:47:39 UTC
Permalink
Sorry for the long delay, but the holidays and school got in the way. I originally thought this was originally a PostgreSQL problem (or so I thought), but it seems to be an LXC one now. Anyway, I've added "lxc.utsname" to my containters' configuration files, as suggested by another user. I'm still left with the same problem that I had before. I have one container set up (email) which run perfectly, and I'm working on a database container, but when I run:

"/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"

to set up my database, it errors out with:

"sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation."

I tried adding sudo privileges for user "postgres" but then I get "initdb: cannot be run as root"

I can attach logs and config files as necessary. I'm kind of at a dead end here.

Thanks in advance,

Pat


----- Original Message -----
From: "Guido J?kel" <G.Jaekel at dnb.de>
To: "Patrick Kevin McCaffrey" <pkm at uwm.edu>, "lxc-users" <lxc-users at lists.sourceforge.net>
Sent: Tuesday, December 20, 2011 2:06:49 AM
Subject: Re: [Lxc-users] PostgreSQL - "sh: cannot create /dev/null: Permission denied" - LXC Issue?

Dear Patrick,

As I understand /dev/null isn't writable in your container. That's definitely a wrong configuration.

Please check, that there is a real device node for /dev/null (and others) in your container and you have it (and others) in the lxc device access control list (lxc.cgroup.devices.allow = c 1:3 rw)

Note that -- depending on the linux flavor in your LXC container -- you might have to populate /dev by your own, because it's not reasonable to run udev or something like this inside a container.

Greetings

Guido
T.Michael Turney
2012-01-17 14:53:04 UTC
Permalink
Quoting Patrick Kevin McCaffrey <pkm at uwm.edu>:

...
Post by Patrick Kevin McCaffrey
"/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
"sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation."
Try adding this to config file:

lxc.cgroup.devices.allow = c 1:3 rwm

This allows the container to read/write/mknod
character device major 1, minor 3

tmike at tmike-Inspiron-1464:~/lxc/oneiric$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 2012-01-13 13:45 /dev/null

This should take care of the

"sh: cannot create /dev/null: Permission denied

Not sure about the postgres error, is it installed in container?
Post by Patrick Kevin McCaffrey
I tried adding sudo privileges for user "postgres" but then I get
"initdb: cannot be run as root"
I can attach logs and config files as necessary. I'm kind of at a dead end here.
Thanks in advance,
Pat
----- Original Message -----
From: "Guido J?kel" <G.Jaekel at dnb.de>
To: "Patrick Kevin McCaffrey" <pkm at uwm.edu>, "lxc-users"
<lxc-users at lists.sourceforge.net>
Sent: Tuesday, December 20, 2011 2:06:49 AM
Permission denied" - LXC Issue?
Dear Patrick,
As I understand /dev/null isn't writable in your container. That's
definitely a wrong configuration.
Please check, that there is a real device node for /dev/null (and
others) in your container and you have it (and others) in the lxc
device access control list (lxc.cgroup.devices.allow = c 1:3 rw)
Note that -- depending on the linux flavor in your LXC container --
you might have to populate /dev by your own, because it's not
reasonable to run udev or something like this inside a container.
Greetings
Guido
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Lxc-users mailing list
Lxc-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users
Patrick Kevin McCaffrey
2012-01-23 21:27:12 UTC
Permalink
...
Post by Patrick Kevin McCaffrey
Post by Patrick Kevin McCaffrey
"/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
"sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation."
lxc.cgroup.devices.allow = c 1:3 rwm
##This line is already in my config file. The entire config file is further below.
Post by Patrick Kevin McCaffrey
This allows the container to read/write/mknod
character device major 1, minor 3
tmike at tmike-Inspiron-1464:~/lxc/oneiric$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 2012-01-13 13:45 /dev/null
This should take care of the
"sh: cannot create /dev/null: Permission denied
## Again, sorry for the how long it took me to reply. Getting this system setup is sort of a side project, and other things have gotten in the way of me working on it lately. Anyway, When I "ls -l" on /dev/nul, I get the following:

crw-r--r-- 1 root root 1, 3 Jan 16 23:24 null

It looks like I definitely don't have write support, if I understand that output correctly. Here is my entire config file for this container:

---------------------------------------------------------------------

lxc.utsname = PE1800-db0
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = /lxc/PE1800-db0/rootfs
lxc.cgroup.devices.deny = a
lxc.network.type = veth
lxc.network.link = br0
#lxc.network.veth.pair =
lxc.network.ipv4 = 192.168.80.4
# /dev/null and zero
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
# consoles
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
lxc.cgroup.devices.allow = c 4:0 rwm
lxc.cgroup.devices.allow = c 4:1 rwm
# /dev/{,u}random
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 5:2 rwm
# rtc
lxc.cgroup.devices.allow = c 254:0 rwm

# mounts point
lxc.mount.entry=proc /lxc/PE1800-db0//rootfs/proc proc nodev,noexec,nosuid 0 0
lxc.mount.entry=sysfs /lxc/PE1800-db0//rootfs/sys sysfs defaults 0 0

----------------------------------------------

I still get exactly the same output when running "/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data":

sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation.


Anyone?
Post by Patrick Kevin McCaffrey
----- Original Message -----
From: "Guido J?kel" <G.Jaekel at dnb.de>
To: "Patrick Kevin McCaffrey" <pkm at uwm.edu>, "lxc-users"
<lxc-users at lists.sourceforge.net>
Sent: Tuesday, December 20, 2011 2:06:49 AM
Permission denied" - LXC Issue?
Dear Patrick,
As I understand /dev/null isn't writable in your container. That's
definitely a wrong configuration.
Please check, that there is a real device node for /dev/null (and
others) in your container and you have it (and others) in the lxc
device access control list (lxc.cgroup.devices.allow = c 1:3 rw)
Note that -- depending on the linux flavor in your LXC container --
you might have to populate /dev by your own, because it's not
reasonable to run udev or something like this inside a container.
Greetings
Guido
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Lxc-users mailing list
Lxc-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users
Patrick Kevin McCaffrey
2012-01-24 17:54:55 UTC
Permalink
Post by Patrick Kevin McCaffrey
...
Post by Patrick Kevin McCaffrey
Post by Patrick Kevin McCaffrey
"/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
"sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation."
lxc.cgroup.devices.allow = c 1:3 rwm
##This line is already in my config file. The entire config file is
further below.
Post by Patrick Kevin McCaffrey
This allows the container to read/write/mknod
character device major 1, minor 3
tmike at tmike-Inspiron-1464:~/lxc/oneiric$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 2012-01-13 13:45 /dev/null
This should take care of the
"sh: cannot create /dev/null: Permission denied
## Again, sorry for the how long it took me to reply. Getting this
system setup is sort of a side project, and other things have gotten
in the way of me working on it lately. Anyway, When I "ls -l" on /
crw-r--r-- 1 root root 1, 3 Jan 16 23:24 null
What are the permissions on /dev/null before you start the container?
i.e. what is output of ls -l /lxc/PE1800-db0/rootfs/dev/null ?
Probably 644 - if so, fix the permissions for that location, then try
running the container again.
Something else you could perhaps try - just temporarily till you find
lxc.cgroup.devices.deny = a
chris
Here is the output of "ls -l" before starting the containter:

pat at PowerEdge1800:/lxc$ ls -l /lxc/PE1800-db0/rootfs/dev/null
crw-r--r-- 1 root root 1, 3 Jan 16 23:24 /lxc/PE1800-db0/rootfs/dev/null

I haven't tried removing "lxc.cgroup.devices.deny = a" yet, but it seems like that's my next step. I'm just lost as to where I've gone wrong.


-Pat
Post by Patrick Kevin McCaffrey
It looks like I definitely don't have write support, if I understand
that output correctly. Here is my entire config file for this
---------------------------------------------------------------------
lxc.utsname = PE1800-db0
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = /lxc/PE1800-db0/rootfs
lxc.cgroup.devices.deny = a
lxc.network.type = veth
lxc.network.link = br0
#lxc.network.veth.pair =
lxc.network.ipv4 = 192.168.80.4
# /dev/null and zero
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
# consoles
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
lxc.cgroup.devices.allow = c 4:0 rwm
lxc.cgroup.devices.allow = c 4:1 rwm
# /dev/{,u}random
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 5:2 rwm
# rtc
lxc.cgroup.devices.allow = c 254:0 rwm
# mounts point
lxc.mount.entry=proc /lxc/PE1800-db0//rootfs/proc proc
nodev,noexec,nosuid 0 0
lxc.mount.entry=sysfs /lxc/PE1800-db0//rootfs/sys sysfs defaults 0 0
----------------------------------------------
I still get exactly the same output when running "/usr/local/pgsql/
sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation.
Anyone?
Post by Patrick Kevin McCaffrey
----- Original Message -----
From: "Guido J?kel" <G.Jaekel at dnb.de>
To: "Patrick Kevin McCaffrey" <pkm at uwm.edu>, "lxc-users"
<lxc-users at lists.sourceforge.net>
Sent: Tuesday, December 20, 2011 2:06:49 AM
Permission denied" - LXC Issue?
Dear Patrick,
As I understand /dev/null isn't writable in your container. That's
definitely a wrong configuration.
Please check, that there is a real device node for /dev/null (and
others) in your container and you have it (and others) in the lxc
device access control list (lxc.cgroup.devices.allow = c 1:3 rw)
Note that -- depending on the linux flavor in your LXC container --
you might have to populate /dev by your own, because it's not
reasonable to run udev or something like this inside a container.
Greetings
Guido
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft
developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Lxc-users mailing list
Lxc-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft
developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Lxc-users mailing list
Lxc-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users
Christoph Willing +61 7 3365 8316
Research Computing Centre
University of Queensland
Christoph Willing
2012-01-28 13:58:07 UTC
Permalink
Post by Patrick Kevin McCaffrey
Post by Patrick Kevin McCaffrey
...
Post by Patrick Kevin McCaffrey
Post by Patrick Kevin McCaffrey
"/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
"sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation."
lxc.cgroup.devices.allow = c 1:3 rwm
##This line is already in my config file. The entire config file is
further below.
Post by Patrick Kevin McCaffrey
This allows the container to read/write/mknod
character device major 1, minor 3
tmike at tmike-Inspiron-1464:~/lxc/oneiric$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 2012-01-13 13:45 /dev/null
This should take care of the
"sh: cannot create /dev/null: Permission denied
## Again, sorry for the how long it took me to reply. Getting this
system setup is sort of a side project, and other things have gotten
in the way of me working on it lately. Anyway, When I "ls -l" on /
crw-r--r-- 1 root root 1, 3 Jan 16 23:24 null
What are the permissions on /dev/null before you start the container?
i.e. what is output of ls -l /lxc/PE1800-db0/rootfs/dev/null ?
Probably 644 - if so, fix the permissions for that location, then try
running the container again.
Something else you could perhaps try - just temporarily till you find
lxc.cgroup.devices.deny = a
chris
pat at PowerEdge1800:/lxc$ ls -l /lxc/PE1800-db0/rootfs/dev/null
crw-r--r-- 1 root root 1, 3 Jan 16 23:24 /lxc/PE1800-db0/rootfs/dev/
null
Thats not good - it should look like:
chris at v1:~$ ls -l /var/lib/lxc/v1video/rootfs/dev/null
crw-rw-rw- 1 root root 1, 3 Jul 20 2011 /var/lib/lxc/v1video/rootfs/
dev/null

You can change yours with:
sudo chmod go+w /lxc/PE1800-db0/rootfs/dev/null

Now run the container.
Post by Patrick Kevin McCaffrey
I haven't tried removing "lxc.cgroup.devices.deny = a" yet, but it
seems like that's my next step.
That won't help if the initial permissions are not fixed (as suggested
above) and won't be needed when the permissions are fixed.

Of course this doesn't explain how the permissions became wrong in the
first place ...


chris
Post by Patrick Kevin McCaffrey
I'm just lost as to where I've gone wrong.
-Pat
Post by Patrick Kevin McCaffrey
It looks like I definitely don't have write support, if I understand
that output correctly. Here is my entire config file for this
---------------------------------------------------------------------
lxc.utsname = PE1800-db0
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = /lxc/PE1800-db0/rootfs
lxc.cgroup.devices.deny = a
lxc.network.type = veth
lxc.network.link = br0
#lxc.network.veth.pair =
lxc.network.ipv4 = 192.168.80.4
# /dev/null and zero
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
# consoles
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
lxc.cgroup.devices.allow = c 4:0 rwm
lxc.cgroup.devices.allow = c 4:1 rwm
# /dev/{,u}random
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 5:2 rwm
# rtc
lxc.cgroup.devices.allow = c 254:0 rwm
# mounts point
lxc.mount.entry=proc /lxc/PE1800-db0//rootfs/proc proc
nodev,noexec,nosuid 0 0
lxc.mount.entry=sysfs /lxc/PE1800-db0//rootfs/sys sysfs defaults 0 0
----------------------------------------------
I still get exactly the same output when running "/usr/local/pgsql/
sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation.
Anyone?
Post by Patrick Kevin McCaffrey
----- Original Message -----
From: "Guido J?kel" <G.Jaekel at dnb.de>
To: "Patrick Kevin McCaffrey" <pkm at uwm.edu>, "lxc-users"
<lxc-users at lists.sourceforge.net>
Sent: Tuesday, December 20, 2011 2:06:49 AM
Permission denied" - LXC Issue?
Dear Patrick,
As I understand /dev/null isn't writable in your container. That's
definitely a wrong configuration.
Please check, that there is a real device node for /dev/null (and
others) in your container and you have it (and others) in the lxc
device access control list (lxc.cgroup.devices.allow = c 1:3 rw)
Note that -- depending on the linux flavor in your LXC container --
you might have to populate /dev by your own, because it's not
reasonable to run udev or something like this inside a container.
Greetings
Guido
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft
developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Lxc-users mailing list
Lxc-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft
developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Lxc-users mailing list
Lxc-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users
Christoph Willing +61 7 3365 8316
Research Computing Centre
University of Queensland
Patrick Kevin McCaffrey
2012-01-31 06:58:19 UTC
Permalink
Just wanted to fill everyone in. I edited the permissions of /lxc/PE1800-db0/dev/null as suggested, restarted the container and all seems to be well now. I also changed permissions of /dev/null on my other containers (and my template), as I assume this is the correct setup.

Thanks for your help,

Pat

----- Original Message -----
From: "Christoph Willing" <cwilling at users.sourceforge.net>
To: "lxc-users" <lxc-users at lists.sourceforge.net>
Sent: Saturday, January 28, 2012 7:58:07 AM
Subject: Re: [Lxc-users] PostgreSQL - "sh: cannot create /dev/null: Permission denied" - LXC Issue?
Post by Patrick Kevin McCaffrey
Post by Patrick Kevin McCaffrey
...
Post by Patrick Kevin McCaffrey
Post by Patrick Kevin McCaffrey
"/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
"sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation."
lxc.cgroup.devices.allow = c 1:3 rwm
##This line is already in my config file. The entire config file is
further below.
Post by Patrick Kevin McCaffrey
This allows the container to read/write/mknod
character device major 1, minor 3
tmike at tmike-Inspiron-1464:~/lxc/oneiric$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 2012-01-13 13:45 /dev/null
This should take care of the
"sh: cannot create /dev/null: Permission denied
## Again, sorry for the how long it took me to reply. Getting this
system setup is sort of a side project, and other things have gotten
in the way of me working on it lately. Anyway, When I "ls -l" on /
crw-r--r-- 1 root root 1, 3 Jan 16 23:24 null
What are the permissions on /dev/null before you start the container?
i.e. what is output of ls -l /lxc/PE1800-db0/rootfs/dev/null ?
Probably 644 - if so, fix the permissions for that location, then try
running the container again.
Something else you could perhaps try - just temporarily till you find
lxc.cgroup.devices.deny = a
chris
pat at PowerEdge1800:/lxc$ ls -l /lxc/PE1800-db0/rootfs/dev/null
crw-r--r-- 1 root root 1, 3 Jan 16 23:24 /lxc/PE1800-db0/rootfs/dev/
null
Thats not good - it should look like:
chris at v1:~$ ls -l /var/lib/lxc/v1video/rootfs/dev/null
crw-rw-rw- 1 root root 1, 3 Jul 20 2011 /var/lib/lxc/v1video/rootfs/
dev/null

You can change yours with:
sudo chmod go+w /lxc/PE1800-db0/rootfs/dev/null

Now run the container.
Post by Patrick Kevin McCaffrey
I haven't tried removing "lxc.cgroup.devices.deny = a" yet, but it
seems like that's my next step.
That won't help if the initial permissions are not fixed (as suggested
above) and won't be needed when the permissions are fixed.

Of course this doesn't explain how the permissions became wrong in the
first place ...


chris
Post by Patrick Kevin McCaffrey
I'm just lost as to where I've gone wrong.
-Pat
Post by Patrick Kevin McCaffrey
It looks like I definitely don't have write support, if I understand
that output correctly. Here is my entire config file for this
---------------------------------------------------------------------
lxc.utsname = PE1800-db0
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = /lxc/PE1800-db0/rootfs
lxc.cgroup.devices.deny = a
lxc.network.type = veth
lxc.network.link = br0
#lxc.network.veth.pair =
lxc.network.ipv4 = 192.168.80.4
# /dev/null and zero
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
# consoles
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
lxc.cgroup.devices.allow = c 4:0 rwm
lxc.cgroup.devices.allow = c 4:1 rwm
# /dev/{,u}random
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 5:2 rwm
# rtc
lxc.cgroup.devices.allow = c 254:0 rwm
# mounts point
lxc.mount.entry=proc /lxc/PE1800-db0//rootfs/proc proc
nodev,noexec,nosuid 0 0
lxc.mount.entry=sysfs /lxc/PE1800-db0//rootfs/sys sysfs defaults 0 0
----------------------------------------------
I still get exactly the same output when running "/usr/local/pgsql/
sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation.
Anyone?
Post by Patrick Kevin McCaffrey
----- Original Message -----
From: "Guido J?kel" <G.Jaekel at dnb.de>
To: "Patrick Kevin McCaffrey" <pkm at uwm.edu>, "lxc-users"
<lxc-users at lists.sourceforge.net>
Sent: Tuesday, December 20, 2011 2:06:49 AM
Permission denied" - LXC Issue?
Dear Patrick,
As I understand /dev/null isn't writable in your container. That's
definitely a wrong configuration.
Please check, that there is a real device node for /dev/null (and
others) in your container and you have it (and others) in the lxc
device access control list (lxc.cgroup.devices.allow = c 1:3 rw)
Note that -- depending on the linux flavor in your LXC container --
you might have to populate /dev by your own, because it's not
reasonable to run udev or something like this inside a container.
Greetings
Guido
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft
developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Lxc-users mailing list
Lxc-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft
developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Lxc-users mailing list
Lxc-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users
Christoph Willing +61 7 3365 8316
Research Computing Centre
University of Queensland
Loading...