-
Notifications
You must be signed in to change notification settings - Fork 92
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
Make filesystem writable before booting #19
Comments
By the way, I tried to put: RUN mount -o remount,rw / at the end of the dockerfile, to no avail (I guess it was to be expected):
|
I had encountered this problem a while ago actually. I just remembered that I had been looking on google/stack overflow and eventually had came up with this solution: echo -e "\n[Make filesystem writable]"
FS_ROW="$(blkid | awk -F\" "/$(basename "${LOOPDEVICE}")/ {print \"UUID=\"\$2\"\011/\011ext4\011defaults\0110\0110\"}")"
echo -e "fstab entry is '${FS_ROW}'"
echo -e "${FS_ROW}" > /os/mnt/etc/fstab Putting this between the "[Configure grub]" and the "[Unmount]" sections basically adds an entry in However, I can't recall if this script ever worked properly. I just happened to find it in an old clone of this repository. In any case, whether this was working or not: it does not work right now. If this script ever worked before, then I believe what caused it to stop working is the switch from grub to syslinux. [Edit:] I also tried to use echo -e '/dev/sda1\011/\011ext4\011defaults,rw\011\060\011\060' >> /os/mnt/etc/fstab It didn't work with I also found that 2 entries already existed in
I also tried replacing |
Another thing I just realized is that syslinux.cfg contains this line: APPEND ro root=/dev/sda1 rootfstype=ext4 initrd=/boot/initramfs-virt Should replacing |
I tried with the debian and ubuntu images, and now the file system is mounted as rw in each case! My first approach was the right one: echo -e "\n[Make filesystem writable]"
blkid | awk -F\" "/$(basename "${LOOPDEVICE}")/ {print \"UUID=\"\$2\" / ext4 defaults 0 0\"}" >> /os/mnt/etc/fstab Only, it doesn't seem to work on alpine the same way it does on debian. Any clue as to why |
I found a workaround for alpine! I simply created a script #!bin/sh
mount -o remount,rw / Then I let docker copy the script over and add the COPY alpine/remount.start /etc/local.d/remount.start
RUN chmod +x /etc/local.d/remount.start
RUN rc-update add local boot With this configuration, when openRC starts, The issue with this workaround is that the file system is mounted read-write way too late in the boot process. Remounting the root file system should not be necessary: it should be initially mounted read-write to begin with. |
Yeah, that's what I suspect in #17 too.
Hmm... Let me get 100% clear on this, you whole system is in VM? and when your VM boots, its docker service doesn't start automatically each time?
By "force run this" you meant force start your docker service each time when your VM boots? Please summarize your whole setup for the next person to easily understand. thx.
See my question in #17, in which I think the UUID is wrong.
Don't do that even it could. because |
Actually, I was wrong. What was happening was alpine didn't want to use the configuration in
What I meant by "VM" is actually qemu. I've been trying to start a qemu VM of the alpine image (into which I pre-installed docker from within the alpine Dockerfile of this repository using
Sorry if I haven't been super specific in my explanations, I'll try my best to clear things up here. Every time I started my custom alpine image with qemu, the Because of this, I had to manually remount the file system read-write and restart openRC's failed init scripts by issuing I hope I've been clearer now!
I should have said this way earlier I believe, but I actually have no clue what I'm doing :) I've been messing around with small details and hoped for the best when booting an image. TL;DR: I don't know what this value is for. I switched it back to |
Oh thanks for the detailed explanation. I don't know alpine to make any comment, but in Debian's term, that openRC service is happening too early in the boot up sequence. Debian's using |
I finally discovered why the root file system is not getting remounted as read-write upon booting. OpenRC init scripts are located under
The /etc/init.d/root start remounts the root file system as read-write flawlessly. Note that I could not make the I have no idea whether the
I believe you are right in saying that the |
I found that installing the |
I don't know how the |
I also struggled with this problem... Comparing with an alpine vm, I found that the But the real problem comes from the fact that
So the solution is actually pretty simple: delete /.dockerenv 😁 To have the alpine's default configuration install And one last thing, if you want the network service to start, it needs an empty file at |
I forgot one thing, you have to enable the services needed for the boot process. So you may want to add this to the Dockerfile: RUN for s in bootmisc hostname hwclock modules networking swap sysctl urandom syslog; do rc-update add $s boot; done
RUN for s in devfs dmesg hwdrivers mdev; do rc-update add $s sysinit; done |
Thanks for the help @Adphi, I want to test your proposed fix. |
Thanks, @Adphi! This is super helpful! |
Nice! I've been planning to turn this project into more or less production-ready Go binary but have had very little success finding time so far. Kudos for making it happen! |
A few days ago I was playing with the Alpine's if [ -f "$sysroot/etc/.default_boot_services" -o ! -f "$ovl" ]; then
# add some boot services by default
rc_add devfs sysinit
rc_add dmesg sysinit
rc_add mdev sysinit
rc_add hwdrivers sysinit
rc_add modloop sysinit
rc_add modules boot
rc_add sysctl boot
rc_add hostname boot
rc_add bootmisc boot
rc_add syslog boot
rc_add mount-ro shutdown
rc_add killprocs shutdown
rc_add savecache shutdown
rc_add firstboot default
# add openssh
if [ -n "$KOPT_ssh_key" ]; then
pkgs="$pkgs openssh"
rc_add sshd default
fi
rm -f "$sysroot/etc/.default_boot_services"
fi So, in order to have a fully working open-rc configuration, all its needs is:
|
That's helpful, @Adphi! Thanks for sharing! |
I've been trying to install docker in the alpine dockerfile, on my local copy of the repository:
The problem I have currently is that, when the VM boots, the docker service cannot start. It seems to be unable to create mandatory files:
I know that I can make the filesystem writeable and successfully start the service with this script:
However, I simply cannot afford to be forced to run this every time I want to use the image! Simply
reboot
ing makes the filesystem read-only again...Is there a way to tell qemu to mount the file system as rw, or update the image configuration from the builder container to automate this process?
The text was updated successfully, but these errors were encountered: