bacongravy / macinbox

Puts macOS in a Vagrant box
Other
663 stars 45 forks source link

/vagrant doesn't exist, read-only? #55

Open adamwolf opened 4 years ago

adamwolf commented 4 years ago

I created a 10.15.2 box the other day with this tool, and today I tried to setup rsync-based /vagrant sharing like I had with other tools on 10.14 et al.

I have the following in my Vagrantfile.

  config.vm.synced_folder ".", "/vagrant", type: "rsync"

At boot, I get

==> default: Rsyncing folder: /Users/wolf/tmp/catalinatest/kicad-mac-builder/ci/10.15/ => /vagrant
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir -p /vagrant

Stdout from the command:

Stderr from the command:

mkdir: /vagrant: Read-only file system

What's the right approach here? Disable SIP and create it and save? Should I use synthetic.conf?

adamwolf commented 4 years ago

I think that for NFS, we would want /etc/synthetic to just have

vagrant

For rsync, I did this

mkdir ~/vagrant_root
sudo su -c 'echo "vagrant\tUsers/vagrant/vagrant_root" >> /etc/synthetic.conf'
reboot

and it came up ok.

bacongravy commented 4 years ago

@adamwolf I don’t use a workflow that relies on /vagrant so I haven’t encountered this before. I believe it might be possible to create /vagrant as part of a macinbox user script that runs during box creation, but I’m not sure that newly created directory would be any more writable than / once the system booted. I don’t know how it would impact rsync, but another approach to try would be to create, in a user script during box creation, a symlink at /vagrant that points to a non-SIP-protected location.

adamwolf commented 3 years ago

It seems supported to me? man synthetic.conf on a 10.15 or higher machine.

On a pragmatic level, I created a directory in root's homedir and made a "synthetic firmlink" to it from /vagrant using synthetic.conf, and it's worked for me for few months so far.

yeahdongcn commented 3 years ago

/etc/synthetic.conf works well.

On macOS 10.15, you could use sudo mount -uw / to make / writable (doesn't work on Big Sur).

clusin commented 3 years ago

Deleted my previous post cuz I didn't read @adamwolf initial post carefully 😬

I followed the suggestions here and added my root directory name to /etc/synthetic.conf. My /etc/synthetic.conf file looks like: <foldername>

For the synced folder I went the NFS route. I I'm trying to keep my box slim on disk space and degraded performance of nfs mount is okay for me. Using VirtualBox as the provider my final Vagrantfile looks like:

  config.vm.network "private_network", ip: "192.168.10.100"
  config.vm.network "public_network", ip: "192.168.20.200", bridge: "en1: Wi-Fi (AirPort)"
  config.vm.synced_folder "./Deployment/dev/", "/<foldername>", type: "nfs"

VirtualBox needed a host-only network interface setup to get NFS mounts working. Some hero on Stack Overflow suggested picking random unoccupied private IP addresses for the two interfaces. This worked for me to get macinbox up and running w/ Virtual Box running Catalina.

Thank you all.

bacongravy commented 3 years ago

To support the default rsync case, perhaps we should update macinbox to create a synthetic.conf in the VM image and add an entry to it like this:

vagrant     var/root/vagrant
mcandre commented 3 years ago

This appears to work for me:

% sudo sh -c "echo \"vagrant\\tUsers/vagrant/vagrant_root\" >>/etc/synthetic.conf"
% mkdir -p /Users/vagrant/vagrant_root

Maybe the /var/root/vagrant version of this just needs a similar mkdir -p done during provisioning to work, I dunno. But I get an I/O error that way, which is really just hiding a permission error. At least with the kishikawakatsumi/macos-catalina-xcode12 box on Vagrant Cloud (one of the few, uncorrupt, boxes available with a sufficiently recent patch level of macOS to satisfy Xcode 12 requirements).