LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   Running Out of Win7 VirtualBox Guest Disk Space (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/running-out-of-win7-virtualbox-guest-disk-space-4175557122/)

tronayne 10-25-2015 10:48 AM

Running Out of Win7 VirtualBox Guest Disk Space
 
I've got a Win7 virtual machine that was originally sized at 40G and is running out of space (about 8G left plus or minus) periodically.

I have a second drive with two 74G partitions and I'd like to use one of those for Win7, just give it the whole partition and be done with removing stuff to make space. I really only use Win7 for Turbotax, Stamps.com and, rarely, FamilyTreeMaker but the darned thing gets nearly filled up.

I don't want to go back to dual booting, I want to continue to use VirtualBox and I really, really don't want to reinstall Win7 from disk in VirtualBox and sit though a couple of days of critical updates.

I'm looking for a nearly painless way of exporting or copying or whatever would work to transfer the existing Win7 to that second drive so that the virtual machine can use the entire partition space and I don't really know how to do that (like, do I create a new virtual machine then copy to it or what?). The existing virtual machine is at least five years old and has been though a lot of VirtualBox updates.

Any hope for doing something like that?

TobiSGD 10-25-2015 01:58 PM

It is actually quite easy, format the partition you want to use for that with a filesystem of your choice, copy the virtual disk image to that partition and configure your VM in Virtualbox to use that file instead. Then use this command
Code:

VBoxManage modifyhd $NEW_IMAGE.vdi --resize $NEW_SIZE_IN_MB
where you replace $NEWIMAGE with the path to the new disk image and $NEW_SIZE_IN_MB with the new size you want to use in MB.
Once you have done that, start the VM and use the Windows partition manager to extend the virtual Windows partition to the whole disk.
I don't think I have to tell you to keep the original disk image until you know that everything works fine with the new image, but I do it anyways. ;)

xode 10-25-2015 02:07 PM

Could you please give me additional information: for your PC hardware, how much RAM and how large is/are your hard drive(s)?; and what host OS are you using?

tronayne 10-25-2015 02:43 PM

Quote:

Originally Posted by xode (Post 5440057)
Could you please give me additional information: for your PC hardware, how much RAM and how large is/are your hard drive(s)?; and what host OS are you using?

The system is Slackware 64-bit 14.1 stable (probably should have mentioned that).

The existing Win7 VM is allocated 8G RAM (the other 8G is system RAM), the disk partition is 75G where it's going to go. There are two drives, the one where the Win7 VM lives now and a second 150G drive that's split in half, one 75G partition for back up and one 75G partition for the VM. The file systems on all drives are ext4.

The present partition where the VM lives (with a couple of other VMs that come and go) is 92G. I want to move Win7 to the second drive and give it the whole partition. The existing partition will remain where it is and be used for other VMs when I get in the mood.

Thanks for asking.

TobiSGD 10-25-2015 02:48 PM

ext4 will work fine for this purpose. Host distribution, size of RAM and size of partitions you use is irrelevant for this problem.

tronayne 10-25-2015 02:56 PM

Quote:

Originally Posted by TobiSGD (Post 5440053)
Once you have done that, start the VM and use the Windows partition manager to extend the virtual Windows partition to the whole disk.

You know, that using the Windows partition manager to extend... I once tried to increase the size of the Win7 VM and the partition manager refused for some reason I can't remember, something about a primary something or other. Hope that won't happen.
Quote:

Originally Posted by TobiSGD (Post 5440053)
I don't think I have to tell you to keep the original disk image until you know that everything works fine with the new image, but I do it anyways. ;)

Oh, yeah, the original stays in place for at least a month before I'll be confident enough. Been there, did that, regretted having done so, won't ever do it again.

Thanks.

xode 10-25-2015 03:45 PM

A couple of questions: (1) is it possible for you to acquire an additional 1000 GB or so hard drive for your PC?; your PC as a whole looks like it is starving for hard drive space; (2) is your Win7 VM under VirtualBox like the VMs I use under VMware as in the virtualized 40G hard drive that your Win7 VM sees is actually a hard drive image file on the actual hard drive?

tronayne 10-26-2015 06:40 AM

Hi, xode,

The system has two drives, sda and sdb. The second drive, sdb, is a 150G drive with two partitions, both 74G, that I use for doing some back ups and for stashing stuff temporarily. One of those two partitions is going to be the new home for the Win7 VM.

The other drive is partitioned the way I've done so for, well, decades; it looks like this:
Code:

df -h
Filesystem      Size  Used Avail Use Mounted on
/dev/sda1        15G  10G  3.9G  73% /
/dev/sda3        19G  6.0G  12G  35% /home
/dev/sda5        19G  5.7G  12G  34% /usr/local
/dev/sda6        19G  3.3G  15G  19% /opt
/dev/sda7        19G  663M  17G  4% /var/lib/mysql
/dev/sda8        92G  40G  47G  46% /var/lib/virtual
/dev/sda9        92G  12G  76G  14% /spares
/dev/sda10      173G  129M  164G  1% /var/lib/pgsql
/dev/sdb1        74G  3.6G  66G  6% /back01
/dev/sdb2        74G  52M  70G  1% /back02
tmpfs          3.9G    0  3.9G  0% /dev/shm

I do this so that I can do a fresh install of system software without wiping out a whole lot of stuff that's living on those partitions (you just don't format them as you add them to fstab during installation). I have four systems, all partitioned the same with varying partition sizes depending on what they're doing; e.g., the MariaDB/MySQL server has a huge data base partition but a small PostgreSQL partition and vice versa on the other. The only system that has VirtualBox on it is this one, the others have the mount point but pretty much no space allocated. The data base servers sit quietly in the closet mumbling to themselves and a laptop sits on a shelf until I need to lug it somewhere.

What are they? Well this one is a Dell Optiplex 780, the data base servers are Dell Dimension 8400 (about 10 years or more old, 32-bitters) and a laptop is a Dell Inspiron 1750. Everybody has Slackware 14.1 stable (64-bit and 32-bit appropriately) and are kept fully patched. This machine has been up for 123 days (had a power outage a while back), the Dimensions have been up for 275 days (their UPS has a bigger battery). The laptop is just off until needed.

When you set up a virtual machine you pick the OS you're installing and a size. I chose 40G for Win7 a long time ago simply because I really don't use it for anything (well, critical updates every couple of weeks). However, tax time is coming and that means that TurboTax is coming and I'm outta space for it and need to expand Win7 to that second drive with the 74G partition.

Just for grins, this is what the files look like:
Code:

ll /var/lib/virtual/Machines/Win7
total 41829512
drwxr-xr-x 3 trona users        4096 Oct 25 12:35 ./
drwxr-xr-x 3 trona users        4096 Mar  8  2014 ../
drwxr-xr-x 2 trona users        4096 Oct 25 12:12 Logs/
-rw------- 1 trona users      12517 Oct 25 12:35 Win7.vbox
-rw------- 1 trona users      12517 Oct 25 12:10 Win7.vbox-prev
-rw------- 1 trona users 42833367040 Oct 25 12:35 Win7.vdi

That vdi file is Win7 and I need to make it bigger.

Just for comparison, the root partition? 15G? 10G used? That's the entire Slackware Linux system. Wow.

I don't know diddly beans about VMware, tried it about 10 years ago or so, but I think it wants a partition all to itself that it formats? Something like that. VirtualBox doesn't, it uses a file.

I'm think that 74G ought to be enough for Win7 plus some software and today's the day to give it a shot following TobiSGD's guide. If there's no smoke and sparks flying out of the vent slots I'll be a happy camper.

Thanks for your interest.

xode 10-29-2015 12:58 AM

From what I see: your Win7 virtual machine is currently on /dev/sda8 (/var/lib/virtual) which is 92G in size, of which only 40G is used and 47G is free. Did I read things correctly?

tronayne 10-29-2015 06:36 AM

Quote:

Originally Posted by xode (Post 5441717)
From what I see: your Win7 virtual machine is currently on /dev/sda8 (/var/lib/virtual) which is 92G in size, of which only 40G is used and 47G is free. Did I read things correctly?

Yep, right you are, it's the only virtual machine currently.

I have tried to extend that with the Windows partition manager and it refuses to (right now I don't remember the error, something about primary, secondary, or some other thing), thus this question.

I'm going to give TobiSGD's method a shot when thing quiet down enough so I can devote an hour or three (wife's getting set up for chemo and there's a lot of long range driving just now).

If there's a simple, hey, just do this, I'll try anything at least once.

Thanks.

xode 10-29-2015 10:05 AM

My recommendations:

(1) make a copy your entire Win7 virtual machine as it stands now (i.e. /var/lib/virtual/Machines/Win7) and put that copy in /dev/sdb1 (/back01) so you still have the original Win7 virtual machine if anything goes wrong while you are trying to upgrade the original.

(2) use TobiSGD's suggestion of "VBoxManage modifyhd $NEW_IMAGE.vdi --resize $NEW_SIZE_IN_MB" to increase the size of hard drive image file in VirtualBox for your Win7 virtual machine in /var/lib/virtual/Machines/Win7. Then, start up that Win7 virtual machine and use the Windows partition manager to have that Win7 virtual machine recognize and use all of the increased hard drive image file.

(3) If the Windows partition manager won't cooperate, then delete the Win7 virtual machine in /var/lib/virtual/Machines/Win7 and restore your original Win7 virtual machine by copying it from /back01 to /var/lib/virtual/Machines/Win7. Then use VirtualBox to add another hard drive image file to your Win7 virtual machine in /var/lib/virtual/Machines/Win7. Then, start up that Win7 virtual machine and use the Windows partition manager to have that Win7 virtual machine recognize the additional new hard drive image file.


All times are GMT -5. The time now is 06:04 PM.