'Vagrant root filesystem becomes read-only after first boot
I am developing a NodeJS project and using a Vagrant VM to ensure a consistent dev environment. This works fine for the very first boot of the VM, but on any subsequent vagrant up it errors complaining about a read-only file system. Sure enough, if I run mount from within the VM, it shows that the root filesystem is mounted as read-only:
/dev/sda1 on / type ext4 (ro,relatime)
I can solve this by running vagrant destroy && vagrant up, but obviously having to entirely recreate the VM every time I use it makes using vagrant extremely slow and cumbersome.
I had a feeling it might have something to do with this known bug regarding symlinks in VirtualBox, but the solution described there does not work for me. In any case, according to the Vagrant docs this option is now enabled by default., so maybe that really isn't it after all.
This is extremely annoying and driving me nuts, I hope somebody is able to help.
Output from vagrant up:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/impish64' version '20220204.0.0' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 9229 (guest) => 9229 (host) (adapter 1)
default: 10000 (guest) => 10000 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
[default] GuestAdditions 6.1.26 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /home/myproject
default: /opt/A Folder => /home/myproject/folder
default: /home/vagrant/.config/myproject => /home/myproject/config
default: /home/vagrant/.local/share/myproject => /home/myproject/data
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
sed -i '/#VAGRANT-BEGIN/,/#VAGRANT-END/d' /etc/fstab
Stdout from the command:
Stderr from the command:
sed: couldn't open temporary file /etc/sedGih0MF: Read-only file system
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/impish64"
# Need this plugin to forward file system events from the host to the guest
# Otherwise watching for file changes is not going to work
# See https://github.com/adrienkohlbecker/vagrant-fsnotify
config.vagrant.plugins = ["vagrant-fsnotify"]
# Expose port 9229 to allow debugging
config.vm.network :forwarded_port, guest: 9229, host: 9229
# Expose port 10000 as the default port for quartersbrief
config.vm.network :forwarded_port, guest: 10000, host: 10000
config.vm.provider "virtualbox" do |vb|
# Give the vm more memory than the standard 1024 because we will be handling
# large amounts of data
vb.memory = "2048"
vb.name = "myproject"
end
# Install NodeJS
config.vm.provision "shell", inline: <<-SHELL
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g grunt-cli
SHELL
# Set NODE_ENV to 'development' by default
config.vm.provision "shell", inline: <<-SHELL
echo "export NODE_ENV=development" > /etc/profile.d/node-env.sh
SHELL
# Share data directory as per XDG Base Directory Specification
# https://specifications.freedesktop.org/basedir-spec/latest/index.html
config.vm.synced_folder "data/", "/home/vagrant/.local/share/myproject
# Share config directory as per XDG Base Directory Specification
# https://specifications.freedesktop.org/basedir-spec/latest/index.html
config.vm.synced_folder "config/", "/home/vagrant/.config/myproject
config.vm.synced_folder "folder/", "/opt/A Folder", fsnotify: true
# cd to the /vagrant directory upon login
config.ssh.extra_args = ["-t", "cd /vagrant; bash --login"]
config.trigger.after :up do |t|
t.name = "vagrant fsnotify"
t.run = { inline: "vagrant fsnotify" }
end
end
Update:
I have eliminated fsnotify as the cause of the problem. Even after destroying the VM, deleting .vagrant folder and commenting out everything to do with fsnotify in the Vagrantfile, the problem remains: After one boot that goes fine, all subsequent vagrant ups error out with read-only file system.
Solution 1:[1]
This seems to be a bug in Vagrant that occurs when a synced folder's name on the guest machine contains spaces.
I have filed a bug report.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BadIdeaException |
