Shrink an Oracle linux VM

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
Desert Rat
Posts: 5
Joined: 21. Oct 2016, 20:38

Shrink an Oracle linux VM

Post by Desert Rat »

I am struggling, as I am not a linux person, but I am running an Oracle linux VM on VirtualBox on Mac OS X, and there was a run-away process that generated a huge log file that caused a volume (var/) to expand such that it consumed all remaining disk space on my Mac. I need to shrink the VM back down to a manageable size and am having trouble figuring out how to do that, after spending considerable time searching on the web. I am currently backing up my 400GB VM in hopes of getting started on shrinking it down so that by Monday I'll be back up and running again.

My VM image is a .vmdk file, if that helps.

Thanks for any help!!
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Shrink an Oracle linux VM

Post by socratis »

Desert Rat wrote:caused a volume (var/) to expand such that it consumed all remaining disk space on my Mac
For the VM to consume the host's hard disk, you must have declared the VM's hard disk so big that it was more than the available space in your host. For example, you had 200 GB free HD space on your host and you created the VM with a HD of 300 GB. Is that the case?

Generally speaking, you cannot downsize a virtual HD, because of the inherit danger of deleting data. First of all you should clean up the VM from its excess garbage. Then, take a look at Ch. 8.23 VBoxManage modifymedium and the "compact" option. That will give you back your free space.

But the problem is going to come back and hit you again at some point, if you've set it up with a large HD. You could look at some partition shrinking software such as GParted.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Shrink an Oracle linux VM

Post by mpack »

I'm afraid that VBoxManage compaction only works on VDIs. It doesn't work on VMDK.

I would say that your best options are :-
  1. Back up your VMDK, plus the rest of that VM's folder.
  2. In the guest, delete all unwanted files, then run a guest partition manager (e.g. GParted) to reduce the guest main partition to something reasonable, say 40GB.
  3. On the host, install one of the Wine packages from the Apple store.
  4. Run CloneVDI under Wine.
  5. Use CloneVDI to clone the partition adjusted VMDK to VDI format. Make sure that the "Compact" and "Keep UUID" options are enabled. You can clone to a secondary drive if you like. Note that since you haven't mentioned snapshots I'm assuming you haven't used them, as they would make the procedure rather different.
  6. Unregister then delete the VMDK (don't worry, you made a backup in step 1).
  7. Move the clone VDI into the VM folder, then use the VM's Storage panel to mount it.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Shrink an Oracle linux VM

Post by socratis »

Desert Rat wrote:My VM image is a .vmdk file, if that helps.
mpack wrote:I'm afraid that VBoxManage compaction only works on VDIs. It doesn't work on VMDK.
Damn, I missed that part. And it even occupied its one-line paragraph! Imagine if it was buried somewhere... ;)
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Desert Rat
Posts: 5
Joined: 21. Oct 2016, 20:38

Re: Shrink an Oracle linux VM

Post by Desert Rat »

Thanks for the info. I do not know how the VM was created, I just know it didn't used to have a 343.04 GB hard drive like it is showing now. It expanded with the runaway log file, so I don't know how that works.

If I can get a copy of the original VM, is it possible to copy all of my files from the current one into that one?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Shrink an Oracle linux VM

Post by socratis »

If the VM is set up to have a dynamic VDI, and a large one from what it seems, you're still going to run into the same problem in the future. So, follow our advice and shrink the partition, after you've cleaned it up and used CloneVDI.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Shrink an Oracle linux VM

Post by mpack »

@Desert Rat: I'm taking it as read that you'll be turning off the log feature in that "runaway app", updating the app if the behaviour was a bug, or deleting the app entirely. Obviously, as in every other sphere of life, if you don't fix the underlying cause of a problem then the problem will keep happening. Hacks to limit the effects shouldn't really be necessary, but may be sensible.
Desert Rat
Posts: 5
Joined: 21. Oct 2016, 20:38

Re: Shrink an Oracle linux VM

Post by Desert Rat »

mpack wrote:@Desert Rat: I'm taking it as read that you'll be turning off the log feature in that "runaway app", updating the app if the behaviour was a bug, or deleting the app entirely.
Nope. Can't do that. It's the system that's paying my bills. I just need to remember to shut it down when I disconnect from the network or close VPN so it doesn't run in a loop all night (or all weekend), logging complaints about how it cannot find its network resources.
Desert Rat
Posts: 5
Joined: 21. Oct 2016, 20:38

Re: Shrink an Oracle linux VM

Post by Desert Rat »

What I wound up doing was re-importing the original VM and copying my files from the old VM into the rebuilt one. It was working fine until after I installed the VBOXADDITIONS and restarted. Now I get an error in Oracle Linux
INIT: Id "X" respawning too fast: disabled for 5 minutes
Apparently, the X Windows is having some problem, but I can find no errors in the log, and not sure where else to look.

Is there some way to re-install the X Windows or figure out what the problem is? It took a long time to get to this point, so I don't want to start over if I don't have to.

Thanks
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Shrink an Oracle linux VM

Post by mpack »

One issue per topic please. Please create a new topic if you have a new question.
Post Reply