Skip to content

datasage/AMZN2Vagrant

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Please excuse the sloppyish formatting. I did this quickly from memory. Feel free to submit improvements..

  • Download .VDI file from here

  • Build virtual CD that contains cloud-init data using the files in this directory

Linux:
genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
Mac:
hdiutil makehybrid -o seed.iso -hfs -joliet -iso -default-volume-name cidata seedconfig/
  • Create a new VM in VirtualBox, call it "AMZN"
  • Add the seed.iso file generated above to the virtual CD drive
  • Add the .VDI file downloaded above as the hard drive (i.e. do not create a new one)
  • Start the Amazon Linux 2 virtual machine

Installing VirtualBox Guest Additions

Remove the cloud-init ISO image from VirtualBox settings

Insert the CD image of VirtualBox Guest Additions from the menu

Log in to the virtual machine as root/vagrant

From the VirtualBox menu select Devices->Insert Guest Additions CD Image

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

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

About

Amazon Linux 2 Vagrant Image for VirtualBox

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages