VMware Cloud Community
Dell82
Contributor
Contributor
Jump to solution

Swap file and C drive space

This is going to be a long post but I don't want to miss any details that might help someone help me.

Let me start off by saying I am extremely new to VMWare and virtual machines in general.  I have built a few small machines but I wasn't completely sure what I was doing and was just following the instructions I was given.

My manager is currently out but in his absence I was tasked with creating a few new machines.  I couldn't figure out why I always had to set the size of the provision to be less than the total size available on the datastore until I read about the swap file.  I understand now that a swap file will take up the same amount of space as the amount of RAM you specify for the machine unless you reserve memory.

The problem I'm having is I was told to set up a 40GB drive with 32GB of RAM.  Since the Windows OS I'm installing is around 10GB there wasn't enough space to complete this.  To solve this issue I increased the size of the datastore by the amount of RAM.  So to have a 40GB C: drive but allow for 32GB of RAM I set the size of the datastore to ~72GB and provisioned 40GB.  The machine booted and installed the OS and I thought things were fine until I checked the size of the C: drive after installation and it told me there was only 1GB or so of space left.  I was expecting it to be around 30GB.  I rebooted the machine to update some unrelated settings and when the machine came back on I had 22GB of 40GB free on my C: drive.  This is still less than what i was expecting but I'm not sure exactly what happened to free up 21GB.

Below is the process I'm using to create this VM.  If someone could take some time to look at this and let me know what I'm missing I would really, really appreciate it.

1.)  Create a 74GB virtual disk on the SAN and present it to the ESXI host

2.)  Log into the host with vSphere Client

3.)  Configuration --> Add storage -->

     a.)  Disk/LUN

     b.)  VMFS-5

     c.)  Maximum available space

4.)  New virtual machine...

     b.)  Storage:  74GB datastore I created

     c.)  VM Version:  5

     d.)  Guest OS:  Windows Server 2008 R2 (64 bit)

     e.)  CPUs:  4 virtual sockets

     f.)  Memory: 32GB

     g.)  Network:  VMNetwork

     h.)  Create a disk:  Virtual disk size = 40GB, thick provisioned lazy zero

This lets the machine start and I'll install the OS but like I said, when it finished there was barely any space left on the C drive.  I'm sure there is something brutally obvious that I'm missing here but I appreciate any help.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
a_p_
Leadership
Leadership
Jump to solution

With that in mind, is the vm swap being stored in the  unprovisioned space like I originally thought?

Sorry for the confusion. Yes you are right, there's certainly also the virtual machine's swap file which is located on the VMFS datastore. In my first post I was only referring to the guest's pagefile, because I understood that the guest OS installation was your major issue.

André

View solution in original post

0 Kudos
9 Replies
a_p_
Leadership
Leadership
Jump to solution

Welcome to the Community,

Create a disk:  Virtual disk size = 40GB, thick provisioned lazy zero

With creating a 40GB virtual disk, that's what the guest OS will see. It cannot access the remaining space on the datastore. If you need more space for the guest OS you either need to create a larger virtual disk or add a second virtual disk to the guest. Keep in mind that you cannot easily decrease the size of a virtual disk. So if you only need the additional guest disk space for the swap file and want to get rid of this later, consider to add a second virtual disk which you can delete after you have reconfigured the guest.


André

Dell82
Contributor
Contributor
Jump to solution

Thank you for the prompt reply, I'm still confused though.

So the swap file is stored in the provisioned space?  When I start the machine and view the data stores it tells me that all but 700mb of my data store is being used.  I just assumed the swap file was being created in the non-provisioned area of the data store.  If it's actually stored in the provisioned area that would explain why all of my space on C is being eaten up.  Where is the rest of the space on my data store going though if it's almost all being used?  I notice that if I increase the size of the provision to say, 50GB, the machine will no longer power on and complains about being out of disk space.

Using the example you mentioned below.  I could use the data store and create two virtual disks off of it.  One for the OS or C drive on the machine with 40GB allocated and then another with 32GB allocated that I could use for the swap file?  Am I understanding that correctly?  Is that a simple option somewhere?

I might be confusing the issue, I apologize.  This has been a learning experience...

0 Kudos
Bill_Fleury
Enthusiast
Enthusiast
Jump to solution

Hi,

From the sounds of it you're provisioning a separate datastore for every VM that you provision.  Unless you have a very compelling reason to have a 1:1 VM to datastore ratio, I would suggest that you consider creating larger datastores and hosting multiple VM's on them.  Also, if managed properly thin provisioned disks have a plethora of advantages - just be sure not to overallocate and then overfill.

Back to your swap question - there are two types of swap involved here.  First, is the VM swap, which is stored by default with the VM (can be changed either by host or per vm to another location).  This is equal to the total memory allocated but not reserved for the VM.  This means, if you reserve all of the memory allocated to the VM, it won't take up space on the shared VMFS datastore with the swap file.  This is OK in certain situations, but prevents you from overcomitting memory on the host, or reclaiming any of the memory allocated to this VM that is not being used.

The other type of swap is the operating system's swap (or pagefile in Windows).  This is most likely the culprit of your free space inside of your virtual disk disappearing.  This is by default set to be managed by Windows.  I'm not sure how it determines the size for this, but I think it's a dynamic size that grows and shrinks as required by whatever magical equation MS has built into Windows.

For the love of everything VMWare, please go with more VM's per datastore 🙂

Dell82
Contributor
Contributor
Jump to solution

That's exactly what we're doing, we're even more granular than that and have a separate datastore for each virtual disk.  So on these machines I have a datastore for the OS (C) and a datastore for the "data" drive (E).

Back to the swap, the page file inside Windows does seem to make more sense now after reading your explanation.  As I originally said, when I first created this box I only had about 1GB left on the C drive after OS installation.  After a reboot though that magically grew by 20GB.  Still not the 30GB I expected but it did go up.  I'm pretty sure the swap file can't be resized without reserving memory as you said so this makes more sense.

With that in mind, is the vm swap being stored in the unprovisioned space like I originally thought?  If so then I at least know I'm going down the right path by expanding the datastore and that my issue is with Windows, not Vmware.

Thank you very much for your detailed explanation.  I think I'm getting closer here.  Like I said I'm very new to this so I really appreciate the help.

0 Kudos
a_p_
Leadership
Leadership
Jump to solution

With that in mind, is the vm swap being stored in the  unprovisioned space like I originally thought?

Sorry for the confusion. Yes you are right, there's certainly also the virtual machine's swap file which is located on the VMFS datastore. In my first post I was only referring to the guest's pagefile, because I understood that the guest OS installation was your major issue.

André

0 Kudos
Dell82
Contributor
Contributor
Jump to solution

Perfect.  Thank you very, very much!

0 Kudos
Bill_Fleury
Enthusiast
Enthusiast
Jump to solution

Also, I think I'd start warning them sooner than later that having a separate datastore per vmdk is a sure fire way to end up with a "bad experience" - they should talk to their VMWare reps if they don't believe you.  Best to nip it in the bud before your environment grows and it ends up a bigger problem than you already have! Smiley Happy

0 Kudos
rickardnobel
Champion
Champion
Jump to solution

Dell82 wrote:

That's exactly what we're doing, we're even more granular than that and have a separate datastore for each virtual disk.  So on these machines I have a datastore for the OS (C) and a datastore for the "data" drive (E). 

There might be another naming confusion here. A "datastore" in vSphere is not a single virtual disk, but a common space typically stored on a SAN, which could hold several virtual disks, called VMDKs.

When you are saying you are using a separate datastore for each virtual disk, you are likely referring to having a separate VMDK file for every virtual disk/partition? (Which could often make sense.)

My VMware blog: www.rickardnobel.se
0 Kudos
rickardnobel
Champion
Champion
Jump to solution

That is a somewhat unusual setup of course and not really flexible to allowe changes in both VMDK size as well as *.vswp.

My VMware blog: www.rickardnobel.se
0 Kudos