v3.0.1 /var mounted as read-only filesystem, even when using sudo

780 views
Skip to first unread message

PaulJ

unread,
Nov 6, 2018, 2:44:35 PM11/6/18
to singularity
Hi All:

I created my own singularity "container" with the build file:

host> cat test3.script

BootStrap: yum
OSVersion: 6
MirrorURL: http;//localhost/centos/%{OSVERSION}/os/$basearch/
Include: yum

After building the image (sudo singularity build test3.sif test3.script), I can run it with:
host> sudo singularity shell test3.sif

in the image, if I attempt to write to /var (and I am the root user because I called singularity with sudo), it returns an error message:

> id
uid=0(root) gid=0(root) groups=0(root)
> touch /var/abc
touch: cannot touch '/var/abc': Read-only file system

I discovered this, since I was trying to perform yum commands in the image, and they were hanging (because it could not write to /var/lib/rpm)

thanks,
Paul

Thomas Hartmann

unread,
Nov 7, 2018, 3:58:46 AM11/7/18
to singu...@lbl.gov
Hi Paul,

have you tried to bind /var/abc explicitly in the container?
I.e.,
--bind /var/abc

But mounting your host's /var might be not really desirable as you are
mixing your container's and hots's /var/lib etc.
Probably a sandbox-container or --writable would be safer.

Cheers,
Thomas


On 2018-11-06 20:44, PaulJ wrote:
> Hi All:
>
> I created my own singularity "container" with the build file:
>
> host> cat test3.script
>
> /BootStrap: yum/
> /OSVersion: 6/
> /MirrorURL: http;//localhost/centos/%{OSVERSION}/os/$basearch//
> /Include: yum/
> /
> /
> After building the image (sudo singularity build test3.sif
> test3.script), I can run it with:
> host> sudo singularity shell test3.sif
>
> in the image, if I attempt to write to /var (and I am the root user
> because I called singularity with sudo), it returns an error message:
>
>> id
> uid=0(root) gid=0(root) groups=0(root)
>> touch /var/abc
> touch: cannot touch '/var/abc': Read-only file system
>
> I discovered this, since I was trying to perform yum commands in the
> image, and they were hanging (because it could not write to /var/lib/rpm)
>
> thanks,
> Paul
>
> --
> You received this message because you are subscribed to the Google
> Groups "singularity" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to singularity...@lbl.gov
> <mailto:singularity...@lbl.gov>.

PaulJ

unread,
Nov 7, 2018, 10:13:57 AM11/7/18
to singularity, thomas....@desy.de
Hi Thomas:

I would not be able to use --bind, since my host is Fedora 28, while the guest is CentOS 6, and it would mess up the host if I tried to yum install anything in the guest.

I did try the --writable option, but that gives me a message: WARNING: no overlay partition found

I tried the --writable-tmpfs and this works.  It will allow me to write to /var.  But, the way the /var filesystem shows up in df, it looks like there is 0% space available on it:

> df -kh .
df: Warning: cannot read table of mounted file system: No such file or directory
Filesystem          Size     Used     Avail    Use Mounted on
-                             0           0           0       -   /

And, a "yum install" or "yum update" will fail, since it believe the filesystem is out of space so it can't download the files

thanks,
Paul

Dave Godlove

unread,
Nov 7, 2018, 11:13:40 AM11/7/18
to singu...@lbl.gov
It sounds like you need to create a sandbox (writable container).  Try adding the --sandbox option to your build command and then invoke the container with the --writable option.  

By default Singularity creates a squashfs partition housed in a SIF file and that is read-only.  

--
You received this message because you are subscribed to the Google Groups "singularity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to singularity...@lbl.gov.


--
Dave Godlove
Engineering Coordinator, Sylabs Inc.
Reply all
Reply to author
Forward
0 new messages