4

I have Vagrant running Ubuntu as a guest OS, on top of a Windows 7 host. When working on the shared folder between guest and host, if a file is read-only it can't be deleted. For example:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/temp$ touch testfile
vagrant@vagrant-ubuntu-trusty-64:/vagrant/temp$ chmod 555 testfile
vagrant@vagrant-ubuntu-trusty-64:/vagrant/temp$ ls -lA
total 0
-r-xr-xr-x 1 vagrant vagrant 0 Aug 22 11:36 testfile
vagrant@vagrant-ubuntu-trusty-64:/vagrant/temp$ rm testfile
rm: remove write-protected regular empty file ‘testfile’? y
rm: cannot remove ‘testfile’: Operation not permitted
vagrant@vagrant-ubuntu-trusty-64:/vagrant/temp$

I also tried with root without success.If I change the read-only attribute (by running 'attrib -R testfile' in Windows) then it can be deleted:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/temp$ ls -lA
total 0
-rwxrwxrwx 1 vagrant vagrant 0 Aug 22 11:42 testfile
vagrant@vagrant-ubuntu-trusty-64:/vagrant/temp$ rm testfile
vagrant@vagrant-ubuntu-trusty-64:/vagrant/temp$

Makes sense, the file is writable now. If the folder where the read-only file resides is not shared, I'm able to delete it:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/temp$ cd /tmp
vagrant@vagrant-ubuntu-trusty-64:/tmp$ touch testfile2
vagrant@vagrant-ubuntu-trusty-64:/tmp$ chmod 555 testfile2
vagrant@vagrant-ubuntu-trusty-64:/tmp$ ls -l testfile2
-r-xr-xr-x 1 vagrant vagrant 0 Aug 22 11:44 testfile2
vagrant@vagrant-ubuntu-trusty-64:/tmp$ rm testfile2
rm: remove write-protected regular empty file ‘testfile2’? y
vagrant@vagrant-ubuntu-trusty-64:/tmp$

I'm assuming in the first case Windows doesn't allow the VirtualBox process to remove a read-only file. Is there a way to tell Windows to allow the deletion? Maybe setting up some permission. BTW, I'm running the VirtualBox process with elevated privileges because I needed to be able to create symlinks (I followed this procedure)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.