Harddisk toevoegen aan vagrant

Met het onderstaande stukje voeg je een nieuwe harddisk toe aan je Vagrant machine.

Het bestand disk.vdi zal aangemaakt worden als harddisk van 1GB (1* 1024).

Vagrant.configure("2") do |config|
  (...)

  file_to_disk = './disk.vdi'
  config.vm.provider "virtualbox" do | v |
    unless File.exist?(file_to_disk)
            v.customize ['createhd', '--filename', file_to_disk, '--size', 1 * 1024]
    end
    v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk]
  end

  (...)
end

In je Vagrant machine zul je deze nu zien als /dev/sdb

$ sudo fdisk -l

Disk /dev/sda: 10.6 GB, 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
Disk label type: dos
Disk identifier: 0x00095a8e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    20766719     9870336   8e  Linux LVM

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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/mapper/centos-root: 8996 MB, 8996782080 bytes, 17571840 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/mapper/centos-swap: 1065 MB, 1065353216 bytes, 2080768 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
[opt-in]

Click Here to Leave a Comment Below

Leave a Reply: