Git Product home page Git Product logo

amzn2vagrant's Introduction

How to make a VirtualBox-based Vagrant Amazon 2 Linux Base Box

Improvements or suggestions towards this document are welcome.

Linux:
genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
Mac:
brew install cdrtools
mkisofs -output seed.iso -volid cidata -joliet -rock user-data meta-data

Creating VM in VirtualBox

  • Create new VM with the following criteria
    • name: AMZN
    • type: linux
    • version: Other Linux 64bit
  • Select the .vdi image downloaded earlier as the Hard Disk (option might state something like "Use an existing virtual hard disk file")
  • Add the seed.iso file generated above to the virtual CD drive
  • Start the Amazon Linux 2 virtual machine

Installing VirtualBox Guest Additions

  • Remove the cloud-init ISO (seed.iso)image from VirtualBox settings
  • Log in to the virtual machine (this can be done in the virtual box terminal window)
    • user: root
    • password: vagrant
  • From the VirtualBox menu select Devices->Insert Guest Additions CD Image
  • Inside the terminal, we must now mount the inserted CD (I manually typed these commands into the VirtualBox terminal, suggestions of a better approach are welcome)
sudo yum -y update

# next line suggested at https://stackoverflow.com/a/37706087/1241791
# to solve shared folder issue later on
sudo yum -y install kernel-headers kernel-devel

#mount the inserted guest additions CD
mount -r -t iso9660 /dev/cdrom /media

cd /media
./VBoxLinuxAdditions.run
systemctl enable vboxadd.service

Ignore tainted kernel message

Post processing

#Delete Bash command history
export HISTSIZE=0

#Delete cache of yum
yum clean all
rm -rf /var/cache/yum

#Optimize the area of the virtual hard disk
dd if=/dev/zero of=/ZERO bs=1M
rm -f /ZERO
shutdown -h now

Create Base Box from virtual machine

These commands to be executed on the host machine

vagrant init
vagrant package --base AMZN --output amazonlinux2.box

The output amazonlinux2.box is the file of Base Box

Notes:

The ssh key in the user-data file is the usual Vagrant insecure keypair from here

References:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html

https://qiita.com/aibax/items/7fd9a874cb7e88f95488

https://superuser.com/questions/1048091/can-i-install-ec2-amazon-linux-os-locally-on-virtual-machine

Contributors

Paul O'Flynn Original Author

Sam Anthony

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.