Procedure Manual: Importing a Virtual Machine to AWS Using VMware Workstation
Preparation Steps:
Prerequisites
-
Install the AWS CLI
- Follow the instructions here (opens in a new tab).
- Verify installation by running:
aws --version
-
Configure the AWS CLI
- Run the following command to configure:
aws configure
- Run the following command to configure:
-
Create an AWS Role for VM Importing
- Create a role with a trust policy. Add the following JSON code to
trust-policy.json
:{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "vmie.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "sts:ExternalId": "vmimport" } } } ] }
- Run the following command:
aws iam create-role --role-name vmimport --assume-role-policy-document "file://C:\Users\user\Desktop\AWS\json\trust-policy.json"
- Create a role with a trust policy. Add the following JSON code to
-
Attach a Policy to the AWS Role
- Create a policy document. Add the following JSON code to
role-policy.json
:{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::hwtechnet-import-export-bucket", "arn:aws:s3:::hwtechnet-import-export-bucket/*" ] }, { "Effect": "Allow", "Action": [ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket", "s3:PutObject", "s3:GetBucketAcl" ], "Resource": [ "arn:aws:s3:::amzn-s3-demo-export-bucket", "arn:aws:s3:::amzn-s3-demo-export-bucket/*" ] }, { "Effect": "Allow", "Action": [ "ec2:ModifySnapshotAttribute", "ec2:CopySnapshot", "ec2:RegisterImage", "ec2:Describe*" ], "Resource": "*" } ] }
- Run the following command:
aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document "file://C:\Users\user\Desktop\AWS\json\role-policy.json"
- Create a policy document. Add the following JSON code to
Important Steps
-
Export the Current VM to an OVA File
- In VMware Workstation, go to File > Export and save the file with the
.ova
extension.
- In VMware Workstation, go to File > Export and save the file with the
-
Create an S3 Bucket for Import-Export
- Create an S3 bucket named
hwtechnet-import-export-bucket
and upload the OVA file to the bucket.
- Create an S3 bucket named
-
Run the AWS Command to Create an Image
- Add the following JSON to
containers.json
:{ "ImportImageTasks": [ { "ImportTaskId": "import-ami-01234567890abcdef", "ImageId": "ami-1234567890EXAMPLE", "SnapshotDetails": [ { "DiskImageSize": 705638400.0, "Format": "ova", "SnapshotId": "snap-111222333444aaabb", "Status": "completed", "UserBucket": { "S3Bucket": "amzn-s3-demo-import-bucket", "S3Key": "vms/my-server-vm.ova" } } ], "Status": "completed" } ] }
- Run the following command:
aws ec2 import-image --description "My server VM" --disk-containers "file://C:\Users\user\Desktop\AWS\json\containers.json"
- After running the command, the task will be in a pending state. Keep the output for reference.
- Add the following JSON to
-
Monitor the Create Image Progress
- To monitor the progress of the import task, refer to the documentation Monitor and Import Image Task (opens in a new tab).
- Use the following command (replace
import-ami-1234567890abcdef0
with your actualImportTaskId
):aws ec2 describe-import-image-tasks --import-task-ids import-ami-1234567890abcdef0
Possible States:
active
— The import task is in progress.deleting
— The import task is being canceled.deleted
— The import task is canceled.updating
— Import status is updating.validating
— The imported image is being validated.validated
— The imported image was validated.converting
— The imported image is being converted into an AMI.completed
— The import task is completed and the AMI is ready to use.
-
Create an Instance from the Uploaded Image
- In the AWS Management Console, go to AMIs, select the created AMI, and proceed to launch an instance.
PNET Baremetal Manual
This guide walks you through installing and setting up Ubuntu 18.04 for PNET Lab on bare metal hardware, including installation, root access configuration, PNET Lab installation, and troubleshooting common issues.
Step 1: Download and Install Ubuntu 18.04
-
Download Ubuntu 18.04:
- Get the Ubuntu 18.04 ISO from the official site: Ubuntu 18.04 Download (opens in a new tab)
-
Install Ubuntu:
- Boot from the Ubuntu 18.04 ISO and follow the installation instructions.
- Important: During installation, make sure to select the option to install OpenSSH to enable remote management over SSH.
- When partitioning, allocate all available disk space to
ubuntu_lv
.
Step 2: Configure Root Access
-
Login as the user created during installation:
- Once the installation is complete, log in with the username and password you set during the Ubuntu installation.
-
Switch to the root user:
- Run the following command to gain root privileges:
sudo -i
- Run the following command to gain root privileges:
-
Set the root password:
- Set a password for the root account by executing:
passwd
- Set a password for the root account by executing:
-
Enable root login via SSH:
- Run the following command to allow root access over SSH:
sed -i -e "s/.*PermitRootLogin .*/PermitRootLogin yes/" /etc/ssh/sshd_config
- Restart the SSH service:
service sshd restart
- Run the following command to allow root access over SSH:
-
Delete the user created during installation:
- Log out and log back in using the root account. Then delete the original user account:
userdel [username]
- Log out and log back in using the root account. Then delete the original user account:
Step 3: Add the PNET Lab Repository
-
Open
/etc/apt/sources.list
:- Use a text editor to open the sources list file:
nano /etc/apt/sources.list
- Use a text editor to open the sources list file:
-
Add the following repository to the end of the file:
deb [trusted=yes] http://repo.pnetlab.com ./
-
Save and exit the text editor.
Step 4: Install PNET Lab
-
Ensure internet connectivity:
- Confirm that your server can access the internet by checking DNS configuration:
echo "nameserver 8.8.8.8" > /etc/resolv.conf
- Confirm that your server can access the internet by checking DNS configuration:
-
Update the package list:
- Run the following command to update the package lists:
apt-get update
- Run the following command to update the package lists:
-
Remove Netplan (if installed):
- PNET Lab doesn't support Netplan, so you need to remove it:
apt-get purge netplan.io
- PNET Lab doesn't support Netplan, so you need to remove it:
-
Install PNET Lab:
- Run the following command to install PNET Lab:
apt-get install pnetlab -y
- Run the following command to install PNET Lab:
-
Handle installation errors:
- If there is an error during installation, try running the commands again:
apt-get update apt-get install pnetlab -y
- If there is an error during installation, try running the commands again:
-
Reboot the system:
- After installation, reboot the server to apply all changes:
reboot
- After installation, reboot the server to apply all changes:
Step 5: Upgrade PNET Lab to the Latest Version
- Follow the upgrade guide:
- To ensure you are running the latest version of PNET Lab, follow the upgrade guide provided at the official documentation site: How to Upgrade PNET Lab (opens in a new tab)
Troubleshooting
If you encounter issues during installation or when trying to install PNET Lab, here are common errors and their solutions:
-
Error: 404 Not Found
E: Failed to fetch http://repo.pnetlab.com/./en_US 404 Not Found E: Failed to fetch http://repo.pnetlab.com/./en 404 Not Found
- Solution: Ensure that the repository URL in
/etc/apt/sources.list
is correct. It should be:deb [trusted=yes] http://repo.pnetlab.com ./
- After editing, run:
apt-get update
- Solution: Ensure that the repository URL in
-
Error: Unmet Dependencies
The following packages have unmet dependencies: pnetlab : Conflicts: netplan.io but 0.99-0ubuntu3~18.04.5 is to be installed E: Unable to correct problems, you have held broken packages.
- Solution: This error usually occurs if Netplan is still installed or conflicts exist. Ensure you run the following commands:
apt-get purge netplan.io apt-get install pnetlab -y
- If the error persists, you might need to fix broken packages:
apt-get install -f
- Solution: This error usually occurs if Netplan is still installed or conflicts exist. Ensure you run the following commands:
-
Error: Package Removal Warnings
dpkg: warning: while removing netplan.io, directory '/etc/netplan' not empty so not removed
- Solution: This is a warning rather than an error. If you want to remove the directory, you can do so manually:
rm -rf /etc/netplan
- Solution: This is a warning rather than an error. If you want to remove the directory, you can do so manually:
-
General Package Management Issues
- If you experience other issues with package management (e.g., held packages), you can try:
apt-get autoremove
- This command will remove unnecessary packages that may be causing conflicts.
- If you experience other issues with package management (e.g., held packages), you can try:
-
Check Network Connectivity
- If you encounter issues reaching the repository, verify your network configuration and ensure you have internet access by pinging an external server:
ping -c 4 google.com
- If you encounter issues reaching the repository, verify your network configuration and ensure you have internet access by pinging an external server:
Conclusion
You have now installed and configured Ubuntu 18.04 and PNET Lab on bare metal. Follow the upgrade instructions to keep PNET Lab up to date, and refer to the troubleshooting section for common issues that may arise during installation or operation. Your system will be ready for network simulation tasks.