- Disk Diet Recover Disk Space 5 4 105
- Disk Diet Recover Disk Space 5 4 106
- Disk Diet Recover Disk Space 5 4 100
- Disk Diet Recover Disk Space 5 4 103
The question of reclaiming space on NFS based VMDKs popped up while at the Toronto VMUG User Conference. I thought it’d be worth a revisit to this topic – not just from a technical “how to” perspective, but also to discuss exactly what the question is all about, why it happens, and then how to fix it.
I’m most familiar with the vendor plug-in model, such as NetApp’s VSC, and have used that to shrink VMDK sprawl, but not everyone has access to tools like that. Thus, I’ll go over the tried and true method for reclaiming space from virtual machines that use NFS for storage.
Displaying Disk Space Statistics (df)Use the df command to show the amount of free disk space on each mounted disk. The usable disk space that is reported by df reflects only 90 percent of full capacity, as the reporting statistics allows for 10 percent above the total available space. This head room normally stays empty for better performance. The percentage of disk space actually reported. Then type in list disk and press Enter key to show all hard disk drive available. Select the disk that contains the partition you want to remove. Normally, with just 1 hard disk, it will be disk 0. So the command will be: Select disk 0. Finish by Enter key. Typically, that means booting from a manufacturer-supplied recovery disc, system disc, or USB stick, or restoring the backed-up system from the previous step to perform a recovery. Merging the freed-up space can be as simple as using Windows’ own built-in disk manager, or it may require a partition-management tool to combine the freed-up space. Okay, I am so tired of receiving Low Disk Space on recovery (D). I have done everything it asked. Empty Recycle Bin which is EMPTY. I am not a computer wizard but it seems unfair that I have pay over $150.00 year to correct this problem once a year. I have checked a lot of places and it just keeps t. The automatic mode is quick and easy, finding and recovering all the deleted partitions on a basic disk. In the Recovery mode window, choose Automatic. You’ll then go to the Searching for deleted volumes window. The tool scans all the basic disks for deleted volumes. The first step will check for unallocated space.
[symple_box color=”yellow” text_align=”left” width=”100%” float=”none”]
Keep in mind that a storage array that’s able to compress and/or deduplicate the underlying NFS volumes will make this effort largely irrelevant for most situations.
[/symple_box]
Keep in mind that a storage array that’s able to compress and/or deduplicate the underlying NFS volumes will make this effort largely irrelevant for most situations.
[/symple_box]
Let’s first talk about how NFS disks grow. vSphere’s default behavior is to use thin provisioning for all VMDKs that sit on NFS storage. Without the aid of VAAI (vSphere APIs for Array Integration) and either an API call or storage array vendor plug-in, there’s no way you can change that. Specifically, you’d have to invoke the Reserve Space primitive on the storage array – if it supports this.
[symple_box color=”yellow” text_align=”left” width=”100%” float=”none”]
New to VAAI? Check out a list of block storage primitives and their meanings here.
[/symple_box]
New to VAAI? Check out a list of block storage primitives and their meanings here.
[/symple_box]
But that’s OK – we’re here to reclaim space, which means you’re running a thin disk on NFS anyway. And as the guest operating system writes data to the VMDK files, the size of the disk grows while the provisioned size stays static. For example, if you gave a 5 GB VMDK disk on NFS to a virtual machine, the initial size would be a few dozen MB and the provisioned size would be 5 GB. I’ve done exactly this below on the W: drive of my View Composer server:
Then some annoying user comes along and writes several GB of files to the W: drive. ?
Now, the operating system is reporting that space is used on the disk. This makes sense, right? We just saw that annoying user copy several GB of data to the drive. In fact, 3.65 GB of data to be specific.
But that’s just the guest operating system’s perspective on the disk usage. Let’s see what vSphere sees:
The guest and vSphere numbers are pretty close to one another. Both the guest operating system and vSphere agree that data is on the disk. But what about when I delete the files from the guest operating system? Let’s compare the numbers after I wipe all the files off the W: drive.
As you can see, the guest operating system shows a nearly empty disk, while the vSphere size is still about 3.65 GB in size. The thin disk has grown to accommodate the files that were previously placed on it. It does not, however, shrink back down to size when files are deleted within the guest.
Have no fear, this problem can be solved. Using the SDelete tool can help clean out the cobwebs on your virtual disk and free up the formerly used space. SDelete is a free command line tool that has the ability to clean and zero out free space. Kudos to Matt Liebowitz’s post on the topic that I have leveraged in the past. ?
A few things about SDelete:
- I commonly push out this tool to the C:WindowsSystem32 folder on my Windows servers using a Group Policy Object (GPO)
- When running the tool from the Command Prompt (CMD), make sure you have it running as Administrator. Otherwise you will get permission errors.
[symple_box color=”red” text_align=”left” width=”100%” float=”none”]
Using SDelete will cause the virtual disk size to inflate all the way up to the provisioned size. Be sure that you have space for that or stagger your cleanups among small batches of VMs.
[/symple_box]
Using SDelete will cause the virtual disk size to inflate all the way up to the provisioned size. Be sure that you have space for that or stagger your cleanups among small batches of VMs.
[/symple_box]
The specific command and arguments to use is:
Where “-c” will clean and “-z” will zero. Older versions have this switched, so I just run both arguments to avoid hassle. Here’s a screenshot of me running SDelete inside of the guest operating system and the resulting file size after it has finished “zapping” my W drive:
Inflation of the VMDK file is a temporary thing and is caused by the way SDelete does its magic. The next step will reclaim all of that unused space.
vSphere has no native ability to offload a hot Storage vMotion to the NFS storage array without some sort of storage array vendor trickery. The NFS file must be read in and written out over the network. As such, you can use a Storage vMotion to reclaim unused space. In my case, I triggered a datastore migration for just the 5 GB VMDK file on my server to a new NFS datastore. This is because I have no need to move around my primary disk, which is 30 GB.
Let’s look under the covers at the network IO during the Storage vMotion. My ESX2 host is busy reading in the used data on the VMDK and simultaneously writing it out to its new home using vmk3 – this is my NFS interface.
Once the Storage vMotion is complete – and it should go rather quickly for an empty virtual disk – the results are superb. The VMDK file now uses a mere 30 MB on disk.
Don’t forget to Storage vMotion the virtual disk back to where it came from, if you desire. Fsmonitor 1 123movies.
How To Use DiskPart Command To Recover Missing Or Unallocated Space On A USB Drive
The other day I was trying to burn an Image on a USB drive and ran into a strange problem.
After using a freeware image burner to burn a portable Operating system on my 4GB removable drive, I found that my USB drive has lost all it’s space. I opened Windows Explorer, right clicked the USB drive icon, selected properties and found that the available space shown was only 250 MB.
More than 3 Gigabytes of free space was lost in thin air !
I thought that since I have burned all the files of a portable os on the USB drive, it might have rewritten the partition on the USB drive. I performed a quick format and then a complete clean format of the removable pen drive but the lost space was not recovered. The USB drive was showing the same space status e.g “ Free space available: 30 MB”, Used Space: 3.5 GB”.
The fact of the matter is that the USB drive was completely accessible and I can easily copy or move files and folders from my computer to the removable drive. But anything more than 250 MB was not accepted as the USB drive has lost all space after trying to burn some files on to it.
Next I tried a disk wipe utility to completely delete the USB partition, formatted it again but the problem was not fixed. Again, I tried some free programs to recover hard drive space in Windows but none of them worked.
Finally, I was able to recover lost space on the USB drive using DiskPart command built right within Windows.
Recover Lost Space On a USB Partition: Reuse Unallocated Space
If you are going through a similar situation and want to get back the lost space on a USB partition or rewrite the unallocated USB partition, here are the steps you should follow:
1. First back up all the data from your USB drive to another location.
2. Click Windows start menu, type disk management in the search box and click on “Create and format hard disk partitions”
3. On the disk management window, you should see your computer’s hard drive listed under the “Disk 0” pane. All removable drives including the USB drive or any removable hard disk which you might be using shall be listed under the “Disk 1” pane.
Supreme league of patriots e1 e2 e3. Note: Be very careful while working over the disk management console window. If you don’t know what you’re doing, please consult an expert who has the knowledge of formatting hard disk partitions. In case your hard drive has crashed and the OS isn’t booting at all, please read our guide on recovering all the data from a hard drive in case of system failure
3. If you have lost space on the USB drive or any removable storage, you should see a large amount of unallocated space under “Disk 1” pane.
If you see that a good amount of unallocated space is shown in the Drive 1 pane, calm down. Your USB drive is perfectly fine and it is very much possible to allocate the lost space and recover it on the USB partition. The hardware is OK and neither you need to go to your computer vendor and install any firmware on it.
The Problem with Unallocated space on USB drives
The problem here is that the freeware image burner completely changed the system partition on the USB drive and after the image was burned, all the unused space has been automatically unallocated. [ Some operating systems e.g Chrome OS requires that the source disk should not have any free space available and I am very sure that the Chrome OS image is the actual culprit which unallocated all the free space on my USB drive. ]
Now all you have to do is delete the existing partitions on the USB drive and recreate a new partition from Windows Disk management console.
While there are a lot of open source and free disk management utilities available, there is no need t use any of them. You can recreate the fresh partition using any of the following two ways:
- Use Windows Disk Management console to delete the existing partition, create a new partition and allocate the unallocated space
- Use Windows DiskPart command to delete all partitions in the removable drive and allocate all the unavailable space to a new parition.
I would follow the second method because it’s more easy and takes only half a minute.
4. Click Windows start menu, type “Diskpart” and click the result to open the DiskPart command prompt window.
5. In the command prompt window, type list disk and hit Enter.
6. This will show the current hard drive as well as removable drive status of your computer. The removable USB drive or hard disk will be shown under Disk 1, as shown below:
![Diet Diet](https://www.diskpart.com/screenshot/en/pro/allocate-free-space/allocate-free-space-from-c-to-d/allocate-free-space.png)
7. Next, type in the following commands one by one:
select disk 1
Clean
create partition primary
Disk Diet Recover Disk Space 5 4 105
8. The first command selects your removable USB drive while the Clean command deletes all the current partitions present on the USB drive. Next, the “Create primary partition” creates a fresh partition and allocates all the unallocated space on this fresh partition.
9. When you are done, type Exit to close the command prompt window.
Disk Diet Recover Disk Space 5 4 106
10. Done !
Disk Diet Recover Disk Space 5 4 100
Unplug your USB drive and plug it back again. You should now see that the entire unallocated space on the USB drive has been recovered. Here are a couple of more articles which are worth a read:
Disk Diet Recover Disk Space 5 4 103
Did you accidentally deleted your USB partition ever? How did you fix the problem? Let us know your thoughts in the comments section.