How to configure virtualbox storage device on btrfs

I have Manjaro as a host and two virtual machines. Host has SSD btrfs disk (COW disabled for VMs)
First VM has virtual disk formatted to ext4.
Second VM has virtualdisk formatted to btrfs.

I didn't install them. Both images were downloaded as ova and imported to virtualbox.
After import, I checked. There is a SSD option in settings that is not turned on. Should I check it or it doesn't matter if my host has SSD option in fstab?

I checked fstab of both VM's
First VM with ext4 has only errors=remount-ro
Second with btrfs has: subvol=@,defaults,noatime,nodiratime,nodatacow,space_cache,autodefrag 0 1

should I change anything for VM with ext4?

As for the VM with btrfs.
Should I add sdd and remove autodefrag option form fstab of this VM?

If I disabled in my Manjaro host COW for virtualbox directory then does it matter if there is nodatacow in fstab in vm?

There is 0 1 for root and 0 2 for home in btrfs vm.
For btrfs should I change it to 0 0 or it doesn't matter what's there?

Guests systems are not Manjaro. I have Manjaro as a host on btrfs SSD as I mentioned above. I use virtualbox for fun so I don't want to exhaust my real SSD to much

moderator: clarified topic title

Guest disk drives - as in shared folder?

For btrfs

Virtual Box specific configuration of storage

Remove the autodefrag mount option for btrfs on an SSD. It only causes write amplification.

Thank you but after the lecture of virtualbox manual and btrfs documentation.
Both are for the standard use, so I know what to put to my fstab for my actual non virtual PC.

The "problem" is that I couldn't find an answer to the question. My English is far from perfect, so I'll try to write it differently.

Host is SSD.
Let's say that virtual machine was installed on HDD without SSD parameter set up in virtualbox config.
Is It a good solution to:
Enable SSD in virtualbox virtual disk config
Add SSD to fstab in guest and remove autodefrag.
I wasn't sure if that is necessary or will it change anything.

And for ext4
I read
mount(8)
and
ext4(5)
But I'm not sure if I should add noatime to errors=remount-ro

Thank you. I always do this for my physical linux installation but I wasn't sure if I should do this for virtual machine. But I's quite logical that autodefrag inside vm will generate disk usage.

1 Like

I run everything with noatime here, and I haven't run into any problems yet because of it. The only reason why you'd use relatime is if you use mutt, which is a character-mode email client, because mutt uses the atime field in the inode to detect whether an email was already read or not.

If you have an SSD and you don't use mutt, use noatime. :wink:

I have been lazy with regards to the SSD flag :bellhop_bell: now you made me research it :grin:

If I remember correct - the SSD flag is an internal VBox flag which means that virtualbox can tell the guest this is a SSD - but I honestly don't know what use it has now - but at some point SSD was not the norm and my guess is that it has become - kind of - obsolete - but I cannot say for sure.


Looking at some Oracle docs - if your guest os mounts using the --discard option (not recommended on Manjaro - using fstrim.timer instead) you would need to let the guest know the device is SSD. I can't state if this is important or not - given that SSD devices has evolved exponentially ever since the first disks were marketed - ( I remember the first SSD I bought - they were quite expensive)

https://docs.oracle.com/en/virtualization/virtualbox/6.0/user/vboxmanage-storageattach.html

--nonrotational
Enables you to enable the non-rotational flag for virtual hard disks. Some guests, such as Windows 7 or later, treat such disks like SSDs and do not perform disk fragmentation on such media.

--discard
Enables the auto-discard feature for a virtual hard disks. This specifies that a VDI image will be shrunk in response to the trim command from the guest OS. The following requirements must be met:

  • The disk format must be VDI.
  • The size of the cleared area must be at least 1 MB.
  • Oracle VM VirtualBox will only trim whole 1 MB blocks. The VDIs themselves are organized into 1 MB blocks, so this will only work if the space being trimmed is at least a 1 MB contiguous block at a 1 MB boundary. On Windows, occasional defragmentation with defrag.exe /D, or on Linux running btrfs filesystem defrag as a background cron job may be beneficial.

Note
The Guest OS must be configured to issue the trim command, and typically this means that the guest OS is made to see the disk as an SSD. Ext4 supports the -o discard mount flag. Mac OS X probably requires additional settings. Windows should automatically detect and support SSDs, at least in versions 7, 8, and 10. The Linux exFAT driver from Samsung supports the trim command.

It is unclear whether Microsoft's implementation of exFAT supports this feature, even though that file system was originally designed for flash.

Alternatively, there are other methods to issue trim. For example, the Linux fstrim command, part of the util-linux package. Earlier solutions required a user to zero out unused areas, using zerofree or similar, and to compact the disk. This is only possible when the VM is offline.

No, it's a filesystem mount option that tells the kernel this is a filesystem on an SSD, and then it will use some SSD-specific optimizations.

Not all filesystems support it, but I know btrfs does, and I believe ext4 and XFS do too.

I use btrfs with SSD but it seems (based at ext4(5) ) that there is no SSD option so for ext4 it probably has to be discard.

Well, don't use discard. Use the systemd-provided fstrim.timer instead. :wink:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by