Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

  1. #1
    Join Date
    Mar 2007
    Beans
    671

    HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    Edit: I have updated how-to for newer version of Ubuntu and VirtualBox.

    Instructions for:
    - Sun xVM Virtual Box 2.2.4
    - Windows XP SP3 as VM_host
    - Ubuntu 9.04 as VM_guest

    1. Install zerofree program:
    Code:
    sudo apt-get install zerofree
    2. Reboot Ubuntu.

    3. Press <Esc> to enter grub menu.

    4. From grub menu select "recovery mode".

    5. Select "root" from Recovery Menu.

    6. Check to see disk names:
    Code:
    df
    7. From previous command in left corner there are /dev/... devices in my case /dev/sda1. Mount this disk as read only:
    Code:
    mount -n -o remount,ro -t ext2 /dev/sda1 /
    8. Make zeros:
    Code:
    zerofree /dev/sda1
    9. Shutdown Ubuntu:
    Code:
    halt
    10. From Windows host execute:
    Code:
    "C:\Program Files\Sun\xVM VirtualBox\VBoxManage" modifyhd vdi_file.vdi compact
    Regards,
    Abcuser
    Last edited by abcuser; August 8th, 2009 at 08:05 AM.

  2. #2
    Join Date
    Apr 2009
    Beans
    1

    Re: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    You can just use the zerofree package. ( In ubuntu 8.10 intrepid ibex )

    Replace instruction 1 to 6 by

    Code:
    sudo apt-get install zerofree
    zerofree - zero free blocks from ext2/3 file-systems

    Regards,
    Chowette

  3. #3
    Join Date
    Mar 2007
    Beans
    671

    Re: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    chowette, thanks for update for Ubuntu 8.10. By the way this how-to was written for Ubuntu 8.04 and Virtual Box 1.6.4. Beginning VirtualBox 2.1.x and now 2.2.x compacting VDI image is temporally disabled by developers. Sun has also acquired Innotech in the mean time, so default install host (Windows in case of this tutorial) directories have changed.

    The work-around for compacting images is to compact VDI file using command:
    "C:\Program Files\Sun\xVM VirtualBox\VBoxManage" clonehd original_file.vdi cloned_file.vdi

    Then registering cloned vdi in Virtual Media Manager in VirtualBox GUI.

  4. #4
    Join Date
    Mar 2007
    Beans
    671

    Re: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    Hi,
    compact functionality is back in Virtualbox version 2.2.4. So I updated how-to to reflect the newest version of Ubuntu and VirtualBox.
    Regards

  5. #5
    Join Date
    Apr 2007
    Beans
    45

    Re: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    Dear ABCUSER,

    I tried your mini "How To" and got:

    mount: / is busy

    Now, it is notable that my root partition is EXT4, I do not have a separate boot partition, nor a separate swap partition, is this an imperative to using zerofree such that it impels the forgoing described dysfunctional state to become occurring?

    I am running "9.10" or karma whatever silly name they called it, and its entirely installed on one partition in a VMware style virtual disk.


    Thanks,

    Stuart

  6. #6
    Join Date
    Mar 2007
    Beans
    671

    Re: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    Hi,
    I have the same problem. I have been asking around on VirtualBox forum and the only known working work aroud solution is to use CloneVDI tool.

    Read more: http://forums.virtualbox.org/viewtopic.php?f=6&t=24025
    Hope this helps

  7. #7
    Join Date
    Apr 2007
    Beans
    45

    Re: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    Quote Originally Posted by abcuser View Post
    Hi,
    I have the same problem. I have been asking around on VirtualBox forum and the only known working work aroud solution is to use CloneVDI tool.

    Read more: http://forums.virtualbox.org/viewtopic.php?f=6&t=24025
    Hope this helps
    I certainly appreciate your most expeditious reply, though it seems perfectly apparent that this is a windows tool, it does me no good. I am testing virtual box under MacOS.

    Is there a MacOS or Linux based implementation of it?

    Similar misbehaviour seemed to be evident when trying Ubuntu under VMware 3.0, as well, even in single user mode the mount command was dysfunctional.


    Thanks,

    Stuart

  8. #8
    Join Date
    Mar 2007
    Beans
    671

    Re: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    Quote Originally Posted by stuartbh View Post
    Is there a MacOS or Linux based implementation of it?
    It should run under WINE it is pure 32-bit Windows application.

  9. #9
    Join Date
    Apr 2007
    Beans
    45

    Re: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    Quote Originally Posted by abcuser View Post
    It should run under WINE it is pure 32-bit Windows application.
    Since you seem to have opted out of answering my query directly, I shall presume that you are inferring there is no Linux port of the utility in the instant case. Although, it seems quite common when you ask a question in the forums that people ignore it and answer the question they prefer to answer. I am not saying you did that, I am just saying you never get a direct answer on forums.

    I have attempted to use WINE for different things, many times, and my experiences have been it brings the instability of Windows into the Linux environment. No thank you, I pass entirely. Not to mention that WINE has been alpha or beta or whatever for like 10 years, forget it.

    Is there any chance that there is a native utility not unlike this utility for Linux?

    How difficult would it be to port it?

    Are there plans to port it?


    Stuart

  10. #10
    Join Date
    Mar 2007
    Beans
    671

    Re: HOWTO: Reduce the size of a dynamic VDI file in VirtualBox

    Quote Originally Posted by stuartbh View Post
    Is there any chance that there is a native utility not unlike this utility for Linux?

    How difficult would it be to port it?

    Are there plans to port it?
    CloneVDI utility is only available on Windows. This utility was written by mpack (forums users name) and he did it in his spare time. He is not Sun's employee.

    It is probably not hard to port it to Linux, but he wrote on VirtualBox forum, that he doesn't have enough skills and time to do this. But there is source code published if someone is capable of doing.

    Back to main topic:
    This problem (mounting disk as read only) is new in Ubuntu 9.10 it looks multiple of applications are using disk in such a way that they lock files. So it is impossible to remount disk in read only mode. The work around would be do kill all processes that are locking disk files and then remount. But I don't know what happens if you kill some important process.

    So the only work-around ("ugly") solution to run CloneVDI tool inside Linux host is to run CloneVDI inside WINE. You could also copy VDI file to Windows box (if you have it) and do the cloning and then copy back to Linux host - sorry no other better solution.
    Last edited by abcuser; November 28th, 2009 at 09:15 AM.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •