Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Background

After a recent HDD crash I did a clean install of Linux Mint 15 on a new disk. Seeing the potential problems with having backups of my documents and eclipse workspace, I realized that a smarter backup solution would be to take the entire home folder. Thus I partitioned my new HDD with /, /home, and /opt as separate partitions. My intention with this scheme was to use / for the system, /home for documents etc that will be backed up, and /opt for stuff that are sort of self-contained and do not require a backup, such as Virtual Windows installations that sometimes need.

Questions:

I noticed today when I was setting up the VM that it uses a folder in /home to store the vdi files, by default. When I changed the location of that folder to /opt I came to realize and remember that /opt has 755 permissions.

  • Does it make sense to put a folder e.g. /opt/vm and try to put the vdi files there? I assume that Virtualbox will run with my normal user permissions and thus won't be able to write there anyways.

  • Does giving such a folder 777 permissions solve the problem? My feeling is that the writing bit would be OK, but I am worried that this might cause more trouble later on.

  • If the above scheme is really error-prone, what options do I have? It would be a pity to leave /opt as is (120 GB) only to create another partition. I could,in theory, resize /opt/ and create another partition /vm, right?

share|improve this question
    
If you want to partition like that, why don't you have a partition and have it mounted under /home/<user>/vm for instance? On the other hand, you can create the folder under /opt and assign the user and group to your own user so only you have access to it (assuming the system is not shareable) –  BitsOfNix Jun 12 '13 at 11:47
    
@AlexandreAlves just to make it clear, are you suggesting creating a folder as root under /opt/ and changing ownership of this folder to my user account? –  posdef Jun 12 '13 at 11:56
    
Exactly so you would have 755 root/root for /opt and 700 user/user_group for /opt/vm. I believe this should work out if I understood correctly what you need. and the VM would only be readable by you –  BitsOfNix Jun 12 '13 at 12:02

2 Answers 2

up vote 3 down vote accepted

I will try to answer you question one by one:

Does it make sense to put a folder e.g. /opt/vm and try to put the vdi files there? I assume that Virtualbox will run with my normal user permissions and thus won't be able to write there anyways.

I would say it makes more sense to put the virtual machines in your home folder, since the virtual machine is data that is associated with your user, and configure your backup program to exclude that directory. But there is no problem in setting up some other directory, such as /opt/vm and set your user as the owner of that directory. Only thing I can think of if SELinux or something like that would try to interfere, but that seems really unlikely.

Does giving such a folder 777 permissions solve the problem? My feeling is that the writing bit would be OK, but I am worried that this might cause more trouble later on.

A better solution would be to change the owner of that directory:

posdef@linux$ sudo mkdir -p /opt/vm
posdef@linux$ sudo chown -R posdef:posdef /opt/vm

But /opt is more meant for applications and so on, so I think it would make more sense to create a folder such as /data/vm/ and use that instead. But this is entirely aesthetics.

If the above scheme is really error-prone, what options do I have? It would be a pity to leave /opt as is (120 GB) only to create another partition. I could,in theory, resize /opt/ and create another partition /vm, right?

There is not any real problem with your setup, more than it might be a bit unusual. I think that a better solution would be to configure your backup program to exclude some folders that you know contain a lot of data. So this seems a bit like a complicated solution to a not that complicated problem. And there is no need to create new partitions, you can just change the mount point of your partition from /opt/vm to something else. /opt is not the partition, it is only the mount point. You can configure this in either /etc/fstab or perhaps in some GUI application (I haven't used mint myself).

share|improve this answer

Create a directory under /opt (or somewhere else) and chown it to your username:

sudo mkdir /opt/virtualbox
sudo chown $USER.$USER /opt/virtualbox

Now make sure to set default machine folder to this new directory. In VirtualBox Manager press Ctrl+G: enter image description here

All new machines will now be created under /opt/virtualbox

share|improve this answer
    
Does this approach have any undesired side effects I should be aware of? –  posdef Jun 12 '13 at 12:50
    
No, it is the exact same setup I have had for the last four years. –  Anthon Jun 12 '13 at 15:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.