Skip to content

poflynn/AMZN2Vagrant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Amazon Linux 2 Vagrant Image for VirtualBox

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages