New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linuxkit] can't remount rw / #2566

Closed
lfuelling opened this Issue Feb 5, 2018 · 11 comments

Comments

Projects
None yet
4 participants
@lfuelling

lfuelling commented Feb 5, 2018

Expected behavior

Trying to add a swapfile according to this tutorial, it should be possible to edit /etc/fstab right away (without remounting)

Actual behavior

I got a filesystem is read-only error and tried running mount -o remount rw / inside linuxkit to edit /etc/fstab which didn't work. (-sh: can't create /etc/fstab: Read-only file system)

Information

  • Update that broke the expected behavior: 17.12.0-ce-mac49 (21995)
  • Issues with a different focus but the same problem: #2419

Steps to reproduce the behavior

  1. screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
  2. echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab
  3. mount -o remount rw /
  4. Filesystem still RO.

Why do I need a swapfile in docker?

I tried installing Oracle DB inside a CentOS container. Let me present you this wonderful error message:

Preparing...                          ########################################

This system does not meet the minimum requirements for swap space.  Based on
the amount of physical memory available on the system, Oracle Database 11g
Express Edition requires 2048 MB of swap space. This system has 1023 MB
of swap space.  Configure more swap space on the system and retry the
installation.

error: %pre(oracle-xe-11.2.0-1.0.x86_64) scriptlet failed, exit status 1
error: oracle-xe-11.2.0-1.0.x86_64: install failed

The funny thing is that ODB just checks the swap size during installation. If I start the image again and/or on another system without the swapfile it works.

@pgayvallet

This comment has been minimized.

pgayvallet commented Feb 5, 2018

@djs55 @ijc any help on that ?

@ijc

This comment has been minimized.

Contributor

ijc commented Feb 5, 2018

The rootfs is an ISO so cannot ever be writeable. Also the image is immutable so even if you could write to /etc/fstab it would go away on boot.

I thought d4m already configured a swap file TBH.

@lfuelling

This comment has been minimized.

lfuelling commented Feb 5, 2018

I just need the swap available when building the image. Any changes to /etc/fstab were lost on boot already before the filesystem was read-only. So it's not a problem.

@pgayvallet

This comment has been minimized.

pgayvallet commented Feb 5, 2018

We currently have a 1gig swap in the vm yes. Issue is apparently to not be able to increase it, even temporarily from inside the vm.

@ijc

This comment has been minimized.

Contributor

ijc commented Feb 5, 2018

I can't think of a reason why using swapon to add a second swapfile instead of editing /etc/fstab wouldn't work, but I've not tried it. You'd have to redo the swapon each time d4m was restarted.

It might be possible (I've not tried this either) to swapoff the existing swap, resize/recreate the underlying swapfile to make it larger and then swapon again, that ought to persist even over restarts (unless d4m is recreating it every boot, I don't know what it does).

Of course all of of this involves cracking open the VM which AIUI is not strictly Supported, a much better solution would be for d4m to support configuring the size in the UI.

@lfuelling

This comment has been minimized.

lfuelling commented Feb 6, 2018

I tried using swapon but it fails with invalid argument.

My workaround for now is building the OracleDB image on a Linux machine with sufficient swap space and then export the image to my mac.

@ijc

This comment has been minimized.

Contributor

ijc commented Feb 6, 2018

I tried using swapon but it fails with invalid argument.

We can't really diagnose/advise on that without specifics of what exactly you did, from the start of the VM onwards.

@lfuelling

This comment has been minimized.

lfuelling commented Feb 6, 2018

Sorry, I thought I wouldn't get support on fiddling with the vm so I left that out. Here's what I did:

  1. Start Docker.app, wait for initialization to be finished
  2. connect to the vm: screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
  3. Press enter to get the prompt
  4. Create swapfile: dd if=/dev/zero of=/var/swapfile count=2000000 bs=1024
  5. Create filesystem: chmod go= /var/swapfile && mkswap /var/swapfile
  6. Try to activate swap: swapon -v /var/swapfile

This is the exact output from swapon:

swapon: /var/swapfile: found signature [pagesize=4096, signature=swap]
swapon: /var/swapfile: pagesize=4096, swapsize=2048000000, devsize=2048000000
swapon /var/swapfile
swapon: /var/swapfile: swapon failed: Invalid argument
@ijc

This comment has been minimized.

Contributor

ijc commented Feb 6, 2018

/var is a tmpfs so you wouldn't want to put a swapfile on it (I got ENOMEM at the dd bit so I never looked at the Invalid argument but I suspect the kernel noticed it was a tmpfs)

Try /var/lib/swap.1 (next to the existing /var/lib/swap):

linuxkit-025000000001:~# free -m
             total       used       free     shared    buffers     cached
Mem:          1998        916       1082          0          2        785
-/+ buffers/cache:        128       1870
Swap:         1023          0       1023
linuxkit-025000000001:~# dd if=/dev/zero of=/var/lib/swap.1 count=2000000 bs=1024
2000000+0 records in
2000000+0 records out
linuxkit-025000000001:~# ls -lh /var/lib/swap.1
-rw-r--r--    1 root     root        1.9G Feb  6 10:30 /var/lib/swap.1
linuxkit-025000000001:~# chmod go= /var/lib/swap.1
linuxkit-025000000001:~# ls -lh /var/lib/swap.1
-rw-------    1 root     root        1.9G Feb  6 10:30 /var/lib/swap.1
linuxkit-025000000001:~# mkswap /var/lib/swap.1
Setting up swapspace version 1, size = 1.9 GiB (2047995904 bytes)
no label, UUID=476da740-3ba9-4714-85b9-d319bed5d98d
linuxkit-025000000001:~# swapon -v /var/lib/swap.1
swapon: /var/lib/swap.1: found signature [pagesize=4096, signature=swap]
swapon: /var/lib/swap.1: pagesize=4096, swapsize=2048000000, devsize=2048000000
swapon /var/lib/swap.1
[  193.864668] Adding 1999996k swap on /var/lib/swap.1.  Priority:-2 extents:6 across:2532476k 
linuxkit-025000000001:~# free -m
             total       used       free     shared    buffers     cached
Mem:          1998       1933         65          0          3       1770
-/+ buffers/cache:        160       1838
Swap:         2977          0       2976

(you are correct that this is all unSupported though)

@lfuelling

This comment has been minimized.

lfuelling commented Feb 6, 2018

That worked perfectly.
Strange that dd worked for me 🤔

Anyway, thanks for your help!

@lfuelling lfuelling closed this Feb 6, 2018

@ijc

This comment has been minimized.

Contributor

ijc commented Feb 6, 2018

Strange that dd worked for me 🤔

Since you are trying to run Oracle I expect you've cranked the RAM setting to the max ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment