[Lxc-users] PostgreSQL - "sh: cannot create /dev/null: Permission denied" - LXC Issue?
Christoph Willing
cwilling at users.sourceforge.net
Sat Jan 28 13:58:07 UTC 2012
On 25/01/2012, at 3:54 AM, Patrick Kevin McCaffrey wrote:
>
> On 24/01/2012, at 7:27 AM, Patrick Kevin McCaffrey wrote:
>
>>
>>
>> ...
>>
>>>> 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."
>>>>
>>
>>> Try adding this to config file:
>>
>>
>>> lxc.cgroup.devices.allow = c 1:3 rwm
>> ##This line is already in my config file. The entire config file is
>> further below.
>>
>>
>>> 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
>
>
>> 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
>> the real cause of the problem - is to comment out the config line:
>> 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
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.
> 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
> I'm just lost as to where I've gone wrong.
>
>
> -Pat
>
>
>> 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?
>>
>>>
>>> ----- 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
>>>
>>> ------------------------------------------------------------------------------
>>> 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
>
>
>
More information about the lxc-users
mailing list