sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
sudo apt-get -y install gcc make linux-headers-$(uname -r) dkms ufw apt-transport-https ca-certificates curl software-properties-common
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list'
sudo apt-get update && apt-get -y install virtualbox-5.2
curl -O http://download.virtualbox.org/virtualbox/5.2.4/Oracle_VM_VirtualBox_Extension_Pack-5.2.4-119785.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.4-119785.vbox-extpack
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu -
uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo mv virtualbox /etc/default/virtualbox
sudo mv vbox.cfg /etc/vbox/vbox.cfg
Log out and back in again to refresh the permissions after this step. This will also allow you to use docker
sudo chgrp vboxusers /etc/vbox
sudo chmod 1775 /etc/vbox
sudo usermod -a -G vboxusers ${USER}
VBoxManage setproperty autostartdbpath /etc/vbox
sudo service vboxautostart-service restart
mkdir ~/images
wget https://dslbbkfzjw91h.cloudfront.net/AWS-Appliance.zip && unzip AWS-Appliance.zip
mv AWS-Appliance-2019-07-24-1563990364.ova ~/images/AWS-Appliance.ova
## .ova file might have a different name, use the correct name
vboxmanage import ~/images/AWS-Appliance.ova --vsys 0 --vmname storage_gateway
vboxmanage modifyvm storage_gateway --nic1 nat
vboxmanage modifyvm storage_gateway --natpf1 "nfs,tcp,,2049,,2049"
vboxmanage modifyvm storage_gateway --natpf2 "nfsudp,udp,,2049,,2049"
vboxmanage modifyvm storage_gateway --natpf3 "ntp,tcp,,8123,,123"
Ports below may not be required
vboxmanage modifyvm storage_gateway --natpf4 "dnstcp,tcp,,8053,,53"
vboxmanage modifyvm storage_gateway --natpf5 "dnsudp,udp,,8053,,53"
vboxmanage modifyvm storage_gateway --natpf6 "http,tcp,,8080,,80"
vboxmanage modifyvm storage_gateway --natpf7 "https,tcp,,8443,,443"
vboxmanage modifyvm storage_gateway --natpf1 "ssh_support,tcp,,2222,,22"
vboxmanage modifyvm storage_gateway --natpf1 "nfs2,tcp,,8111,,111"
vboxmanage modifyvm storage_gateway --natpf1 "nfs2udp,udp,,8111,,111"
Decide on a static IP to assign the appliance. 192.168.15.2 will do. Also, under a non root user, VirtualBox only forwards ports > 1024 (no privileged ports). Make sure all your ports are acceptable. Because we will need to connect to http port 80 on the host to activate the appliance, we will use a docker ha-proxy container to forward 80 to 8080.
VBoxManage natnetwork modify --netname default --port-forward-4 "http:tcp:[]:8080:[192.168.15.2]:80"
VBoxManage natnetwork modify --netname default --port-forward-4 "https:tcp:[]:8443:[192.168.15.2]:443"
VBoxManage natnetwork modify --netname default --port-forward-4 "dnstcp:tcp:[]:8053:[192.168.15.2]:53"
VBoxManage natnetwork modify --netname default --port-forward-4 "dnsudp:udp:[]:8053:[192.168.15.2]:53"
VBoxManage natnetwork modify --netname default --port-forward-4 "ssh_support:tcp:[]:2222:[192.168.15.2]:22"
VBoxManage natnetwork modify --netname default --port-forward-4 "ntp:udp:[]:8123:[192.168.15.2]:123"
VBoxManage natnetwork modify --netname default --port-forward-4 "nfs:tcp:[]:2049:[192.168.15.2]:2049"
VBoxManage natnetwork modify --netname default --port-forward-4 "nfsudp:udp:[]:2049:[192.168.15.2]:2049"
VBoxManage natnetwork modify --netname default --port-forward-4 "nfs2:tcp:[]:8111:[192.168.15.2]:111"
VBoxManage natnetwork modify --netname default --port-forward-4 "nfs2udp:udp:[]:8111:[192.168.15.2]:111"
sudo ufw allow 22/tcp && sudo ufw allow 2222/tcp
sudo ufw allow 80/tcp && sudo ufw allow 8080/tcp
sudo ufw allow 443/tcp && sudo ufw allow 8443/tcp
sudo ufw allow 53 && sudo ufw allow 8053
sudo ufw allow 123/ucp && sudo ufw allow 8123/udp
sudo ufw allow 2049 && sudo ufw allow 2049
sudo ufw allow 111
sudo ufw default deny
sudo ufw enable
docker-compose up -d
Modify the vm to use the new nat network and start at boot, and also create and attach a 250 GB disk for caching
vboxmanage modifyvm storage_gateway --nic1 natnetwork --nat-network1 default --autostart-enabled on
vboxmanage createhd --filename ~/disks/cache.vdi --size 262144
mkdir -p ~/disks
vboxmanage storageattach storage_gateway --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium ~/disks/cache.vdi
vboxmanage showvminfo storage_gateway
vboxmanage startvm storage_gateway --type headless
RDP server will be available on port 5961, which you can connect to using any RCP client. Likely, you've setup the VM on a linux server, so it has no GUI, and we've not allowed port 5961 on UFW. You will need to forward the port to your workstation via ssh tunnel, like so:
ssh -i ssh_key_file -L 5961:127.0.0.1:5961 -fN remoteuser@remotehost
You can now connect to the AWS appliance via an RDP client like Microsoft's Remote Desktop 10 The client will ask for credentials, but the RDP connection is not secured, so type anything and connect When you see the Appliance's login screen, login with user: admin / password: password combination
- Follow the AWS guide to setup your gateway: https://docs.amazonaws.cn/en_us/storagegateway/latest/userguide/manage-on-premises.html
- After that is done, follow the getting started guide here: https://docs.aws.amazon.com/storagegateway/latest/userguide/GettingStarted.html
vboxmanage controlvm storage_gateway pause|resume|reset|poweroff|savestate
After creating a share on the AWS Console, you can mount it with:
# Install NFS helper utils
sudo apt-get -y install nfs-common
# Mount Share
sudo mount -t nfs -o nolock,hard gateway_ip:/bucket/prefix MOUNTPATH