Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jj-meyer/a9d878b004542e825b47 to your computer and use it in GitHub Desktop.

Select an option

Save jj-meyer/a9d878b004542e825b47 to your computer and use it in GitHub Desktop.

Revisions

  1. jj-meyer revised this gist Aug 28, 2015. 1 changed file with 14 additions and 11 deletions.
    25 changes: 14 additions & 11 deletions Resize-vagrant-box-from-existing-base-box.md
    Original file line number Diff line number Diff line change
    @@ -30,19 +30,22 @@ sudo su -
    ```
    ```bash
    fdisk /dev/sda
    [ Press p to print the partition table to identify the number of partitions. By default there are two - sda1 and sda2.
    Press n to create a new primary partition.
    Press p for primary.
    Press 3 for the partition number, depending the output of the partition table print.
    Press Enter two times to accept the default First and Last cylinder.
    Press t to change the system's partition ID
    Press 3 to select the newly creation partition
    Type 8e to change the Hex Code of the partition for Linux LVM
    Press w to write the changes to the partition table. ]
    #[
    #Press p to print the partition table to identify the number of partitions. By default there are two - sda1 and sda2.
    #Press n to create a new primary partition.
    #Press p for primary.
    #Press 3 for the partition number, depending the output of the partition table print.
    #Press Enter two times to accept the default First and Last cylinder.
    #Press t to change the system's partition ID
    #Press 3 to select the newly creation partition
    #Type 8e to change the Hex Code of the partition for Linux LVM
    #Press w to write the changes to the partition table.
    #Press q to quit
    #]

    partprobe
    fdisk /dev/sda
    [ p ]
    #[ p q ]
    reboot
    ```

    @@ -51,7 +54,7 @@ vagrant ssh
    sudo su -

    fdisk /dev/sda
    [ p ]
    #[ p q ]
    ```

    ```bash
  2. jj-meyer revised this gist Aug 28, 2015. 1 changed file with 13 additions and 4 deletions.
    17 changes: 13 additions & 4 deletions Resize-vagrant-box-from-existing-base-box.md
    Original file line number Diff line number Diff line change
    @@ -8,23 +8,27 @@ vagrant box add homestead_100gb ../boxes/homestead.box
    cd ..
    mkdir homestead_100gb
    vagrant init # or copy VagrantFile from somewhere else and change config.vm.box to "homestead_100gb"
    vagrant up
    vagrant up # to confirm that it works
    vagrant destroy
    ```
    # Resize the .vmdk image
    ## Resize the .vmdk image
    ```bash
    cd ~/.vagrant.d/boxes/homestead_100gb/0/virtualbox
    VBoxManage clonehd "box-disk1.vmdk" "clone-disk1.vdi" --format vdi
    VBoxManage modifyhd "clone-disk1.vdi" --resize 102400
    VBoxManage showhdinfo "clone-disk1.vdi"
    VBoxManage clonehd "clone-disk1.vdi" "box-disk1.vmdk" --format vmdk
    mv box-disk2.vmdk box-disk1.vmdk
    rm clone-disk1.vdi
    ```

    # Resize the physical partitions on the virtual machine
    ## Resize the physical partitions on the virtual machine
    ```bash
    vagrant up
    vagrant ssh
    sudo su -

    ```
    ```bash
    fdisk /dev/sda
    [ Press p to print the partition table to identify the number of partitions. By default there are two - sda1 and sda2.
    Press n to create a new primary partition.
    @@ -40,13 +44,17 @@ partprobe
    fdisk /dev/sda
    [ p ]
    reboot
    ```
    ```bash
    vagrant ssh
    sudo su -
    fdisk /dev/sda
    [ p ]
    ```
    ```bash
    pvcreate /dev/sda3
    # confirm that the volume groups's name is vagrant--vg-root
    ls -al /dev/mapper/
    @@ -59,3 +67,4 @@ resize2fs /dev/mapper/vagrant--vg-root

    # confirm that the volume sizes are changed
    df -vh
    ```
  3. jj-meyer revised this gist Aug 28, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Resize-vagrant-box-from-existing-base-box.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    [Also see scotch.io] (https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one)

    ## Build vagrant box from an existing one
    `bash
    ```bash
    cd homestead
    vagrant package --output ../boxes/homestead.box
    vagrant box add homestead_100gb ../boxes/homestead.box
    @@ -10,7 +10,7 @@ mkdir homestead_100gb
    vagrant init # or copy VagrantFile from somewhere else and change config.vm.box to "homestead_100gb"
    vagrant up
    vagrant destroy
    `
    ```
    # Resize the .vmdk image
    cd ~/.vagrant.d/boxes/homestead_100gb/0/virtualbox
    VBoxManage clonehd "box-disk1.vmdk" "clone-disk1.vdi" --format vdi
  4. jj-meyer revised this gist Aug 28, 2015. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions Resize-vagrant-box-from-existing-base-box.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    # Also see: https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one
    [Also see scotch.io] (https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one)

    # Build vagrant box from an existing one
    ## Build vagrant box from an existing one
    `bash
    cd homestead
    vagrant package --output ../boxes/homestead.box
    vagrant box add homestead_100gb ../boxes/homestead.box
    @@ -9,7 +10,7 @@ mkdir homestead_100gb
    vagrant init # or copy VagrantFile from somewhere else and change config.vm.box to "homestead_100gb"
    vagrant up
    vagrant destroy

    `
    # Resize the .vmdk image
    cd ~/.vagrant.d/boxes/homestead_100gb/0/virtualbox
    VBoxManage clonehd "box-disk1.vmdk" "clone-disk1.vdi" --format vdi
  5. jj-meyer renamed this gist Aug 28, 2015. 1 changed file with 0 additions and 0 deletions.
  6. jj-meyer created this gist Aug 27, 2015.
    60 changes: 60 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    # Also see: https://scotch.io/tutorials/how-to-create-a-vagrant-base-box-from-an-existing-one

    # Build vagrant box from an existing one
    cd homestead
    vagrant package --output ../boxes/homestead.box
    vagrant box add homestead_100gb ../boxes/homestead.box
    cd ..
    mkdir homestead_100gb
    vagrant init # or copy VagrantFile from somewhere else and change config.vm.box to "homestead_100gb"
    vagrant up
    vagrant destroy

    # Resize the .vmdk image
    cd ~/.vagrant.d/boxes/homestead_100gb/0/virtualbox
    VBoxManage clonehd "box-disk1.vmdk" "clone-disk1.vdi" --format vdi
    VBoxManage modifyhd "clone-disk1.vdi" --resize 102400
    VBoxManage showhdinfo "clone-disk1.vdi"
    VBoxManage clonehd "clone-disk1.vdi" "box-disk1.vmdk" --format vmdk
    mv box-disk2.vmdk box-disk1.vmdk
    rm clone-disk1.vdi

    # Resize the physical partitions on the virtual machine
    vagrant up
    vagrant ssh
    sudo su -

    fdisk /dev/sda
    [ Press p to print the partition table to identify the number of partitions. By default there are two - sda1 and sda2.
    Press n to create a new primary partition.
    Press p for primary.
    Press 3 for the partition number, depending the output of the partition table print.
    Press Enter two times to accept the default First and Last cylinder.
    Press t to change the system's partition ID
    Press 3 to select the newly creation partition
    Type 8e to change the Hex Code of the partition for Linux LVM
    Press w to write the changes to the partition table. ]

    partprobe
    fdisk /dev/sda
    [ p ]
    reboot

    vagrant ssh
    sudo su -

    fdisk /dev/sda
    [ p ]

    pvcreate /dev/sda3
    # confirm that the volume groups's name is vagrant--vg-root
    ls -al /dev/mapper/
    vgdisplay

    # extend the physical and logical drives
    vgextend vagrant-vg /dev/sda3
    lvextend -l +100%FREE /dev/mapper/vagrant--vg-root
    resize2fs /dev/mapper/vagrant--vg-root

    # confirm that the volume sizes are changed
    df -vh