Outils pour utilisateurs

Outils du site


59:tuto_vboxmanage

Ceci est une ancienne révision du document !


It's a common problem: you run VirtualBox, create a virtual machine, probably with a dynamic disk, at your best guess at an adequate disk size, run it for a while, then find you're running out of space. You can easily expand the hard disk size in VirtualBox using the command: VBoxManage modifyhd –resize The –resize option allows you to change the capacity of an existing image; this adjusts the logical size of a virtual disk without affecting the physical size. It works only for expanding the capacity of VDI and VHD virtual disk formats, and only dynamically allocated, not fixed size disks. But this is a way to add more space to a virtual disk without needing to create a new image, attach and copy all the data across within a virtual machine. This is a command-line application, so you need to open a Terminal session in order to run the command, and change directory to the path where your virtual disk is stored.

C'est un problème courant: vous lancez VirtualBox, créez une machine virtuelle, sans doute avec un disque dynamique, à une taille disque suffisante selon votre meilleure estimation, vous l'exécutez pendant un certain temps, puis vous retrouvez à court d'espace.

Vous pouvez facilement agrandir la taille du disque dur dans VirtualBox en utilisant la commande:

VBoxManage modifyhd –resize

L'option –resize vous permet de modifier la capacité d'une image existante, ce qui ajuste la taille logique d'un disque virtuel sans affecter la taille physique. Il ne fonctionne que pour augmenter la capacité des disques virtuels aux formats VDI et VHD, et seulement ceux alloués dynamiquement, et pas les disques de taille fixe. Mais c'est une façon d'ajouter plus d'espace à un disque virtuel sans avoir à créer une nouvelle image, attacher et copier toutes les données dans la machine virtuelle.

C'est une application en ligne de commande, donc vous devez ouvrir une session Terminal pour lancer la commande, et changer de répertoire vers l'endroit où votre disque virtuel est stocké.

Two important notes: • Shutdown the running virtual machine before you mess with the disk! • Backup the existing disk image, or at least any volatile data, before you alter it! The command you need follows this pattern: VBoxManage modifyhd XP_newdisk.vdi –resize 10240 • VBoxManage is the utility suite that comes with VirtualBox: • modifyhd is the command to resize the virtualdisk • XP_new.vdi is my example disk name; you'll need to change it to match your disk name, and don't forget the .vdi suffix. Under Linux it's also case sensitive. • –resize 10240 Next is the desired new size for the virtual disk. That's two dashes before the word “resize” followed by a number in megabytes; 10240 being equivalent to 10GB. Also remember that you'll need to increase the size of your guest partition on the disk, or create an additional partition in the new space. In this respect, you'll need to do the work with disk utilities appropriate to your guest operating system just as if it were a real PC with real spinning rust (magnetic disks).

Deux remarques importantes: • Arrêtez le fonctionnement de la machine virtuelle avant de mettre la pagaille sur le disque! • Sauvegardez l'image disque existante, ou au moins toutes les données volatiles, avant de la modifier!


La commande dont vous avez besoin suit ce modèle:

VBoxManage modifyhd XP_newdisk.vdi - redimensionnement 10240

• VBoxManage est la suite utilitaire qui est livré avec VirtualBox: • modifyhd est la commande pour redimensionner la virtualDisk • XP_new.vdi est mon nom de disque par exemple, vous aurez besoin de le changer pour correspondre à votre nom du disque, et ne pas oublier le suffixe vdi.. Sous Linux, c'est aussi la casse. • - redimensionner 10240 Suivant la taille souhaitée nouvelle pour le disque virtuel. C'est deux tirets avant le mot “resize” suivi par un certain nombre de méga-octets; 10240 étant équivalente à 10Go. Souvenez-vous également que vous aurez besoin d'augmenter la taille de votre partition invité sur le disque, ou créer une partition supplémentaire dans le nouvel espace. À cet égard, vous aurez besoin pour faire le travail avec les utilitaires de disque appropriées à votre système d'exploitation invité comme s'il s'agissait d'un vrai PC avec le Real de filature rouille (disques magnétiques). Note:.vmdk disks cannot be expanded by modifyhd commands. Try this command line and you'll get the error: VBoxManage: error: Resize hard disk operation for this format is not implemented yet! You can find the manual for Oracle VirtualBox, indexed by each topic, on the website. VBoxManage is in Chapter 8: http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi where the full syntax of the command looks like this: VBoxManage modifyhd <uuid>|<filename> [–type normal|writethrough|immutable|shareable| readonly|multiattach] [–autoreset on|off] [–compact] [–resize <megabytes>|–resizebyte <bytes>]

The –compact option can be used to shrink disk images, that is, remove blocks of empty space (containing zeroes). This will shrink a dynamically allocated image by reducing the physical size of the image without affecting the logical size of the virtual disk. However, free space in the guest system must first be zeroed. For Windows guests, you can use the sdelete tool provided by Microsoft; running sdelete -c in the guest will zero the free disk space. Under Linux, the zerofree utility supports ext2/ext3 filesystems to do the same. You can then compact (compress) the virtual disk image. Note: instructions and links relate to the Oracle VirtualBox version and not to the VirtualBox OSE package contained in the official Ubuntu repositories.

59/tuto_vboxmanage.1335339815.txt.gz · Dernière modification : 2012/04/25 09:43 de frangi