10

ボックスのディスク容量を増やしたいのですが。次のように、vagrantfile を使用してこれを実行しようとしています。

Vagrant::Config.run do |config|
    # ..
    config.vm.customize ["modifyvm", :id, "--memory", 1024]
    config.vm.customize ["modifyhd", :id, "--resize", 4096]
end

これは私にエラーを与えます:

A customization command failed:
["modifyhd", "e87d8786-88be-4805-9c2a-45e88b8e0e56", "--resize", "4096"]

The following error was experienced:

VBoxManage: error: The given path 'e87d8786-88be-4805-9c2a-45e88b8e0e56' is not fully qualified
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Medium, interface IMedium, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 178 of file VBoxManageDisk.cpp


Please fix this customization and try again.

http://docs.vagrantup.com/v1/docs/config/vm/customize.html http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdiから情報をつなぎ合わせようとしています

4

6 に答える 6

6

VDIのUUIDを期待している間に、VMのUUID(vagrantによって提供される)をmodifyhdに送信しています。実際の VDI ファイルまたはその UUID への絶対パスを使用する必要があります。次のコマンドを使用して、VDI の UUID を取得できます: VBoxManage showhdinfo <filename>( virtualbox - how to check what is the uuid of a vdi? を参照)

于 2013-02-17T20:47:48.677 に答える
3

新しいディスクを作成し、古いディスクを追加して拡張しました。

私のVagrantfile:

Vagrant.configure(2) do |config|
config.vm.box = "bseller/oracle-standard"
config.vm.define :oracle do |oracle| 
  oracle.vm.hostname = 'oraclebox'
  oracle.vm.synced_folder ".", "/vagrant", owner: "oracle", group: "oinstall" 
  oracle.vm.network :private_network, ip: '192.168.33.13'
  oracle.vm.network :forwarded_port, guest: 1521, host: 1521
  oracle.vm.provider :virtualbox do |vb|
     vb.customize ["modifyvm", :id, "--memory", "4096"]
     vb.customize ["modifyvm", :id, "--name", "oraclebox"]
     if !File.exist?("disk/oracle.vdi")
       vb.customize [
            'createhd', 
            '--filename', 'disk/oracle', 
            '--format', 'VDI', 
            '--size', 60200
            ] 
       vb.customize [
            'storageattach', :id, 
            '--storagectl', "SATA", 
            '--port', 1, '--device', 0, 
            '--type', 'hdd', '--medium', 'disk/oracle.vdi'
            ]
     end     
  end
  oracle.vm.provision "shell", path: "shell/add-oracle-disk.sh"
  oracle.vm.provision "shell", path: "shell/provision.sh"
end
end

これにより、新しいディスクが作成されます

disk
    |-- oracle.vdi
shell
    |-- provision.sh
Vagrantfile

ボックスに追加します。新しいディスクは 60GB です My shellprovision.sh

set -e
set -x

if [ -f /etc/disk_added_date ] ; then
   echo "disk already added so exiting."
   exit 0
fi

sudo fdisk -u /dev/sdb <<EOF
n
p
1


t
8e
w
EOF

sudo pvcreate /dev/sdb1
sudo vgextend VolGroup /dev/sdb1
sudo lvextend -L50GB /dev/VolGroup/lv_root
sudo resize2fs /dev/VolGroup/lv_root
date > /etc/disk_added_date

このスクリプトは、SHCからボックスbseller/oracle-standardに変更されました。完全なコードについては、GitHubの私のプロジェクトoracleboxを参照してください

于 2015-03-19T20:43:11.517 に答える
2

私はこれを見てきましたが、実際にこれを直接行う方法は見つかりませんでした。ただし、 Ansibleをプロビジョナーとして使用して効果を得ることができます。まず第一に、Vagrant を使用して 2 番目のディスクを作成して追加することは間違いなく可能です。このディスクは、Ansible を使用して任意の方法で追加およびマウントできます。

ただし、Ansible には (ホスト上で) ローカル コマンドを実行する機能もあります。これはAnsibleのlocal_action機能です。ここでは、カーネルのアップグレード後に Vagrant VM を再起動し、ホストが再起動するまで待機するように指示するために使用しましたが、コマンドまたはシェル アクションでこれを使用して、HD 識別子を見つけ、VM をシャットダウンし、ハードディスクを構成できます。 、再起動します。少なくとも理論上は。

于 2014-08-28T14:19:26.790 に答える
2

質問は古いですが、回答が受け入れられていません。

The given path 'e87d8786-88be-4805-9c2a-45e88b8e0e56' is not fully qualifiede87d8...UUIDは VirtualBox vm UUID であり、SATA ストレージ ディスク デバイスの UUID ではない ため、表示されます。でストレージ デバイスの UUID を見つけますVBoxManage showvminfo e87d8786-88be-4805-9c2a-45e88b8e0e56|grep vdi:idVagrantfile modifyhd 行の SATA ストレージ UUID に置き換えます。

それは私の問題を解決しました。

于 2015-04-01T18:36:52.537 に答える
0

わかりました...解決しました...

VBoxManage.exe は私のパスにないので、私が行ったことは次のとおりです (そのパスに移動する必要があります)。

C:\Program Files\Oracle\VirtualBox

次に、コマンドを使用しました:

VBoxManage.exe modifyhd "C:\Users\MyUser\VirtualBox VMs\MachineName\HDName.vdi" --resize 20480

20 GB サイズの場合、HD

これは機能しません: "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd "C:\Users\MyUser\VirtualBox VMs\MachineName\HDName.vdi " --resize 20480

次のパスにいる必要があります: C:\Program Files\Oracle\VirtualBox

于 2015-07-13T14:46:04.750 に答える
0

代わりに新しいディスクを追加できます。最初に仮想ボックス GUI を使用して、別の仮想ディスクを追加します

ここに画像の説明を入力

次に、fdisk を使用してプライマリ ディスク パーティションを作成します。

root@linux-dev:/# fdisk -l

Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 9.9 GiB, 10632560640 bytes, 20766720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x83312a2b

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048 19816447 19814400  9.5G 83 Linux
/dev/sda2       19818494 20764671   946178  462M  5 Extended
/dev/sda5       19818496 20764671   946176  462M 82 Linux swap / Solaris

root@linux-dev:/# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x5eb328b9.

Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

Command (m for help): p

Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5eb328b9


Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039):

Created a new partition 1 of type 'Linux' and of size 20 GiB.

Command (m for help): p
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5eb328b9

Device     Boot Start      End  Sectors Size Id Type
/dev/sdb1        2048 41943039 41940992  20G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

新しく作成したディスク パーティションを ext4 ファイルシステムにする

root@linux-dev:/# mkfs.ext4 /dev/sdb1 
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 5242624 4k blocks and 1310720 inodes
Filesystem UUID: 0301b56a-1d80-42de-9334-cc49e4eaf7b2
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

ディスク パーティションをディレクトリにマウントする

root@linux-dev:/# mount -t ext4 /dev/sdb1 /home/chenchun
root@linux-dev:/# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       9.2G  3.3G  5.5G  38% /
udev             10M     0   10M   0% /dev
tmpfs            74M  4.4M   70M   6% /run
tmpfs           185M     0  185M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           185M     0  185M   0% /sys/fs/cgroup
none            372G  240G  133G  65% /vagrant
/dev/sdb1        20G   44M   19G   1% /home/chenchun
于 2015-11-06T06:23:30.030 に答える