Can a virtual machine (VM) overwrite a host disk, a host or guest disk, or a guest another guest disk?


Question 42

This question stems from "Is it safe to answer "wipe the disk and install Ubuntu" on a virtual machine? ".

Guest space from host:

It happens when the disk space becomes larger than the unused disk space (probably not at the beginning), but later, when the usage increases to 40 out of 50 GB and the main drive only has 40 GB left What? In other words, will the VM overwrite the data, or will it report this data? I just want to be sure, I don't think the VM will overwrite the host's data.

Host space for the guest:

Conversely, if the host disk were to use the space guaranteed for the guest, is there any chance it could damage the guest in some way, and is it possible? Will the host tell you that the host space is limited by that VM?

Guest space:

Just an example from Oracle VirtualBox or any similar VM software, i.e. using "thin provisioning" to install a Linux Mint guest on a Windows 10 host. After selecting the "Clean" option, the installer directly tells me:

"If you continue, the changes listed below will be written to disk. Otherwise, you will be able to make further changes manually. Changed the partition table for the following devices: SCSI3(0,0,0) (sda) will format the following partitions : Partition #1 of SCSI3(0,0,0) (sda) as ext4."

I chose "Continue" and nothing bad happened. Probably the popup message because I already have another VM installed. It seems that this VM can take space from another VM, is this possible?


This problem is not limited to Oracle VirtualBox usage. This question is a general question about VMS, certainly not excluding answers on VirtualBox.

mink

Guest space

On Linux Mint, using VirtualBox, the installer tells me directly after selecting the "erase" option:

If you continue, the changes listed below will be written to disk. Otherwise, you will be able to make further changes manually. Changed the partition table for the following device: SCSI3(0,0,0)(sda) will format the following partition: Partition #1 of SCSI3(0,0,0)(sda) as ext4.

I chose "Continue" and nothing bad happened. Probably the popup message because I already have another VM installed. I don't think the VM will overwrite the host's data. However, it seems like one VM might be taking the space of another VM?

Virtual machines are completely self-contained. They are (broadly speaking) indistinguishable from physical computers, and they won't know about each other unless you connect them in some way - just like physical computers.

The message is not caused by the presence of another VM. This is a "sanity check" type dialog. It requires you to double-check that the installer's automatic selection matches your intent.

I have confirmed experimentally that this message appears when installing Ubuntu 18.04 and 20.04 to an empty, unpartitioned drive.

Host space for guests

From the inside, the VM looks like a normal computer, while from the outside (ie, from the host's point of view) it's just a bunch of files. Typically, you will have a file that describes the hardware configuration of the virtual machine, and a file for each virtual disk attached to that virtual machine. So in most use cases the VM contains two files: one for configuration and one for disk.

Disk files can be preallocated or dynamically allocated. A preallocated disk is created from the beginning to occupy space equal to its capacity. It can slightly improve performance at the cost of taking up host disk space in unused disk areas. If there is not enough disk space to do this, the process will fail when the VM is created, but not yet run.

A dynamically allocated virtual disk file grows when a guest tries to write to its previously unused area. The technical term is sparse file . In this case, the host may actually run out of disk space when the guest tries to write to its virtual disk. Nothing will be overwritten, as this is just a typical case of a program trying to create a file that is too large to fit on disk (the program is your VM software - a hypervisor). The fact that it's a virtual disk attached to a running VM doesn't matter, because from the host's perspective, the file is no different from any other file. The operating system's filesystem driver will simply deny writes to the file. How the hypervisor handles this is up to its implementation.

host's guest space

Again, to the host, a virtual disk is just a file, and it's subject to the same rules as any other file. Any process that is allowed to write to the file can make any modifications to it, unless the file is currently locked for exclusive writing by another process.

Related


Free up disk space on the guest, reduce free space on the host

Vinayak Garg I am using vmplayer with guest os = Ubuntu 12.04 on Windows 7 I've had this happen before, so this time I paid careful attention. Here's what happens: I emptied the trash in Ubuntu. Free space on ubuntu jumped from 11.7 GB to 13.4 GB. I switched t

Free up disk space on the guest, reduce free space on the host

Vinayak Garg I am using vmplayer with guest os = Ubuntu 12.04 on Windows 7 I've had this happen before, so this time I paid careful attention. Here's what happens: I emptied the trash in Ubuntu. Free space on ubuntu jumped from 11.7 GB to 13.4 GB. I switched t

Enable VirtualBox guest disk growth

learn forever I'm running VirtualBox (version 5.0.24) with the Windows 10guest Ubuntu 16.04 LTS. In the storage settings, the "Virtual Size" is 32 GB, and the "Actual Size" is 30.2 GB. Use dynamically allocated storage. Also (not sure if relevant) LVMis used i

Enable VirtualBox guest disk growth

learn forever I'm running VirtualBox (version 5.0.24) with the Windows 10guest Ubuntu 16.04 LTS. In the storage settings, the "Virtual Size" is 32 GB, and the "Actual Size" is 30.2 GB. Use dynamically allocated storage. Also (not sure if relevant) LVMis used i

Enable VirtualBox guest disk growth

learn forever I'm running VirtualBox (version 5.0.24) with the Windows 10guest Ubuntu 16.04 LTS. In the storage settings, the "Virtual Size" is 32 GB, and the "Actual Size" is 30.2 GB. Use dynamically allocated storage. Also (not sure if relevant) LVMis used i

The host cannot SSH the guest, but the guest can

Samaras This is a follow-up question from: Getting virtualbox to get a different IP address than my laptop . I ended up using these files /etc/hostson both my laptop (host) running Ubuntu 14.04 and my virtual machine (guest) running Ubuntu 14.04 : 127.0.0.1

The host cannot SSH the guest, but the guest can

Samaras This is a follow-up question from: Getting virtualbox to get a different IP address than my laptop . I ended up using these files /etc/hostson both my laptop (host) running Ubuntu 14.04 and my virtual machine (guest) running Ubuntu 14.04 : 127.0.0.1

Debian 8 KVM Guest - loading initial virtual disk

Compiler I have updated the KVM management script for Ubuntu 14.04 KVM host to support debian 8 guests. After manual installation (the script is not yet available), on startup I get the following message: During installation, I: Select only the ssh server and

Debian 8 KVM Guest - loading initial virtual disk

Compiler I have updated the KVM management script for Ubuntu 14.04 KVM host to support debian 8 guests. After manual installation (the script is not yet available), on startup I get the following message: During installation, I: Select only the ssh server and

Unable to ping between guest machine virtual machine MacOS host

jslamz I have two virtual machines, one Windows XP SP3 and one Kali Linux2020. I can set up both computers on NAT and connect to the internet normally, but I can't use the other or ping one of them from the host. I tried setting them up on a bridged network (e

Shared host folder with Virtual machine guest issue (centos 6.5)

username I have installed centos 6.5 kvm. Then I created a virtual machine and tried to share the host folder (eg /mnt) with the virtual machine using 9p_virtio. ( follow this guide : http://www.linux-kvm.org/page/9p_virtio ) However, in virt-manager. It shows

Shared host folder with Virtual machine guest issue (centos 6.5)

username I have installed centos 6.5 kvm. Then I created a virtual machine and tried to share the host folder (eg /mnt) with the virtual machine using 9p_virtio. ( follow this guide : http://www.linux-kvm.org/page/9p_virtio ) However, in virt-manager. It shows

Extend Disk Capacity on Root Partition on Ubuntu Guest

Chokosato I want to increase the disk capacity on a virtual machine. I went ahead and expanded the free 8GB from the settings. Now I can see that section as free space on the Ubuntu guest. I now want to use this free space to expand my root partition. I am fol

Partition my disk to install Windows as a guest OS?

Tim I have never used a virtual machine before. I plan to partition the hard drive (250GB) on a Thinkpad T400 laptop (8GB main memory) and install Ubuntu 14.04 as my main OS and host OS. In the future, when I have to use some Windows software (eg Adobe Acrobat