Skip to content

Commit c483959

Browse files
authored
New vm creation method vagrant optional (#659)
* Move optional steps for testing VMs out of README.md file This may help avoid new users being confused that they must follow those instructions. Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu> * Many changes to vm-ubuntu-24.04 install scripts. The resulting Ubuntu VM will use the Ubuntu default GNOME desktop, instead of the smaller, but harder to find documentation for, Lubuntu desktop formerly installed by the install scripts. Signed-off-by: Andy Fingerhut <andy.fingerhut@gmail.com> * Fix a typo Signed-off-by: Andy Fingerhut <andy.fingerhut@gmail.com> * Use specific versions of p4lang repositories for installation Also add the user to sudoers earlier during the install. Signed-off-by: Andy Fingerhut <andy.fingerhut@gmail.com> --------- Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu> Signed-off-by: Andy Fingerhut <andy.fingerhut@gmail.com>
1 parent 9a350e0 commit c483959

24 files changed

Lines changed: 2034 additions & 602 deletions

README.md

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -110,38 +110,13 @@ machine to those on your system.
110110

111111
### To build a virtual machine with the P4 development tools.
112112

113-
#### Requirements
114-
115-
- [Vagrant](https://vagrantup.com)
116-
- [VirtualBox](https://virtualbox.org)
117-
- At least 12 GB of free disk space, otherwise the installation can fail in unpredictable ways.
118-
119-
#### Installation Steps
120-
121-
1. Install Vagrant and VirtualBox on your system.
122-
2. Clone the repository
123-
```
124-
git clone https://github.com/p4lang/tutorials.git
125-
```
126-
3. Navigate to the cloned directory :
127-
```
128-
cd vm-ubuntu-24.04
129-
```
130-
4. Start the virtual machine using Vagrant:
131-
```
132-
vagrant up dev
133-
```
134-
*Note* : The time for this step depends on your computer and Internet speed. On a 2019 Intel MacBook Pro with a 1 Gbps download speed, it took approximately 2 hours. Ensure a stable Internet connection throughout the process.
113+
See the instructions [here](vm-ubuntu-24.04/README.md).
135114

136115
### Accessing the VM
137116

138-
- There are two user accounts:
139-
- Username: vagrant | Password: vagrant (This is the default account)
140-
- Username: p4 | Password: p4 (Usage of this account is expected)
141-
142-
*Note*: Before running the `vagrant up` command, make sure you have enabled virtualization in your environment; otherwise you may get a "VT-x is disabled in the BIOS for both all CPU modes" error. Check [this](https://stackoverflow.com/questions/33304393/vt-x-is-disabled-in-the-bios-for-both-all-cpu-modes-verr-vmx-msr-all-vmx-disabl) for enabling it in virtualbox and/or BIOS for different system configurations.
143-
144-
You will need the script to execute to completion before you can see the `p4` login on your virtual machine's GUI. In some cases, the `vagrant up` command brings up only the default `vagrant` login with the password `vagrant`. Dependencies may or may not have been installed for you to proceed with running P4 programs. Please refer the [existing issues](https://github.com/p4lang/tutorials/issues) to help fix your problem or create a new one if your specific problem isn't addressed there.
117+
+ There are two user accounts:
118+
+ Username: p4 | Password: p4 (Usage of this account is expected)
119+
+ Username: vagrant | Password: vagrant (There is no need to use this account)
145120

146121
### To install P4 development tools on an existing system
147122

utils/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ endif
3333
all: run
3434

3535
run: build
36-
sudo python3 $(RUN_SCRIPT) -t $(TOPO) $(run_args)
36+
sudo PATH=$(PATH) ${P4_EXTRA_SUDO_OPTS} python3 $(RUN_SCRIPT) -t $(TOPO) $(run_args)
3737

3838
stop:
39-
sudo mn -c
39+
sudo PATH=$(PATH) `which mn` -c
4040

4141
build: dirs $(compiled_json)
4242

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Creating a VM using VirtualBox and an ISO disk image with an Ubuntu Desktop Linux 24.04 installer
2+
3+
In the initial boot menu, the default choice "Try or Install Ubuntu"
4+
should be highlighted. Press return to continue.
5+
6+
Choose your language. Click Next button.
7+
8+
In "Accessibility", I usually do not change any of the defaults. You
9+
might want to. Click Next button when ready to continue.
10+
11+
Select your keyboard layout. Click Next button.
12+
13+
In "Internet connection" screen, you will likely see the default
14+
choice as "Use wired connection", and there is a greyed-out
15+
unselectable choice "No Wi-Fi devices connected". This is the case
16+
even if the host system has no wired network connection, only Wi-Fi.
17+
The reason you see these choices is that as far as the VM is
18+
concerned, it detects only a virtual wired Ethernet adapter, created
19+
by VirtualBox, and does not see the host system's physical Wi-Fi
20+
device. This is normal. Click the Next button to proceed.
21+
22+
In "Try or Install Ubuntu", select "Install Ubuntu". Click the Next
23+
button.
24+
25+
In "Type of installation", select "Interactive Installation". At
26+
least, that is what these instructions are written for. If you want
27+
to try an Automated installation, feel free to do so, but don't expect
28+
the steps to be documented here. Click the Next button.
29+
30+
In "Applications" window, select "Default selection", and click Next.
31+
32+
In "Optimise your computer" window, I leave the boxes unchecked, and
33+
click Next.
34+
35+
In "Disk setup" window, select "Erase disk and install Ubuntu", and
36+
click Next.
37+
38+
In "Create your account" window, enter your full name, desired system
39+
name, user name, and password. I prefer to uncheck the box next to
40+
"Require my password to log in", as my host system is intended to keep
41+
the computer secure with requiring a password to log in, with screen
42+
lock after a timeout if you desire. Repeating that for the guest OS
43+
is just annoying to me. Click Next button to continue.
44+
45+
In "Select your timezone" window, click on the map your approximate
46+
location, or edit the contents of the text boxes labeled "Location" or
47+
"Timezone". Click Next to continue.
48+
49+
In "Ready to install" window, click "Install" button.
50+
51+
Installation can take several minutes. Be patient. Eventually you
52+
should see a window titled "Installation complete". Click the
53+
"Restart now" button.
54+
55+
If in a boot screen you see the message "Please remove this
56+
installation medium, then press ENTER:", just press return to
57+
continue.
58+
59+
Proceed to the section titled [Installing open source P4 development
60+
tools on the
61+
VM](README.md#installing-open-source-p4-development-tools-on-the-vm).
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Creating a VM using VirtualBox and an ISO disk image with an Ubuntu Server Linux 24.04 installer
2+
3+
In the initial boot menu, the default choice "Try or Install Ubuntu"
4+
should be highlighted. Press return to continue.
5+
6+
Choose language. See on-screen instructions for moving the choice
7+
around.
8+
9+
Choose keyboard language.
10+
11+
On the page "Choose the type of installation", I leave the default
12+
choice "Ubuntu Server" selected with an "X" as is. I press return for
13+
selecting "Done" at the bottom of the screen.
14+
15+
Network Configuration: press return for Done.
16+
17+
Proxy address: I do not need one for my home network, so press return
18+
for Done.
19+
20+
Ubuntu archive mirror configuration: Wait a few seconds for it to test
21+
access to the default mirror archive. Press return for Done, assuming
22+
that it successfully finds a mirror system to connect to.
23+
24+
Guided storage configuration: This can be nerve-wracking for a new
25+
user if you are installing multiple OS's on a physical system, but
26+
here we have created a new virtual disk just for this guest OS's full
27+
use, so we want to allocate all of that virtual disk for this OS's
28+
purposes. Leave the default "X" checked on "Use an entire disk".
29+
30+
I usually press tab until the cursor is on the "X" next to "Set up
31+
this disk as an LLVM group", and press the space key to uncheck that
32+
box. Press tab a couple more times to select "Done" near bottom of
33+
screen, then return to proceed.
34+
35+
Storage configuration: Look over the info on the screen if you are
36+
curious, but I just press return to proceed.
37+
38+
A "Confirm destructive action" "window" pops up. Again, this is where
39+
I get nervious if I am ever installing Linux on a physical system
40+
where I want another OS to remain on a different disk partition, but
41+
VirtualBox is restricting this VM so that it can only see the virtual
42+
disk(s) that VirtualBox created it, and nothing else in the host OS
43+
file system, so confidently proceed by pressing tab to highlight the
44+
"Continue" choice, and press return.
45+
46+
Enter your full name, desired system name, user name, password,
47+
etc. pressing tab to advance through the different boxes. When ready,
48+
press tab until "Done" is highlighted at the bottom, then press
49+
return.
50+
51+
Here you might see an "Upgrade to Ubuntu Pro" configuration page. I
52+
always continue without upgrading to Ubuntu Pro.
53+
54+
SSH Configuration: I do not install an openSSH server, tab to
55+
highlight Done, and press return to continue.
56+
57+
Featured server snaps: I press tab until "Done" is highlighted at the
58+
bottom, then return to proceed, as none of the snaps presented are
59+
things I typically want to install. Any of them can be installed
60+
later after the base OS is installed, with appropriate install
61+
commands.
62+
63+
Updating system: This can take many minutes to complete. Grab a cup
64+
of coffee. Work on something else. Check back occasionally. You can
65+
tell this step is done when the top of the screen says "Installation
66+
complete!". Press tab to highlight "Reboot Now" near bottom of screen
67+
and press return to proceed.
68+
69+
If the screen says "Please remove the installation medium, then press
70+
ENTER:", just press return/enter key to proceed.
71+
72+
You will see many boot progress messages appear, and hopefully in
73+
under 1 minute you will see a login prompt that looks like:
74+
75+
```
76+
<your-system-name> login:
77+
```
78+
79+
Enter your user name and password to log in.
80+
81+
Update any of the base OS packages that have newer versions available
82+
with these commands:
83+
84+
```bash
85+
sudo apt update
86+
sudo apt upgrade
87+
```
88+
89+
Press return if prompted to confirm the installation of new packages.
90+
91+
If you want to install the default Ubuntu GUI desktop:
92+
93+
```bash
94+
sudo apt-get install ubuntu-desktop-minimal
95+
```
96+
97+
That downloads hundreds of MBytes of packages and installs them. When
98+
it is complete, enter the following command to reboot the system:
99+
100+
```bash
101+
sudo reboot
102+
```
103+
104+
It might "pause" during the boot messages for several minutes, before
105+
you see a GUI login window. The first command below disables a
106+
redundant network system service, one that significantly slows down
107+
the system boot process if you leave it enabled.
108+
109+
```bash
110+
sudo systemctl disable systemd-networkd.service
111+
sudo apt-get install git
112+
```
113+
114+
Proceed to the section titled [Installing open source P4 development
115+
tools on the
116+
VM](README.md#installing-open-source-p4-development-tools-on-the-vm).
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Create VM using ISO installer
2+
3+
## Finding the Linux installer image you want
4+
5+
Download the `.iso` file that installs the version of Linux that you
6+
are interested in. An Internet search for terms like these works for
7+
me. Use "amd64" for a host system with 64-bit Intel/AMD CPU, or
8+
"arm64" for an Apple Silicon Mac.
9+
10+
Example search terms:
11+
12+
+ If your system has a 64-bit Intel or AMD CPU
13+
+ Ubuntu 24.04 amd64
14+
+ If you have an Apple Silicon Mac:
15+
+ Ubuntu 24.04 arm64
16+
17+
An installer for Desktop Linux leads to fewer steps you need to do in
18+
order to get a GUI Desktop. As of 2024, I have only been able to find
19+
Server Linux installers for arm64 systems. It is not difficult to
20+
install that, and then later install the GUI Desktop.
21+
22+
23+
## Creating a new VM
24+
25+
Start VirtualBox. While there are command line ways to do all of this
26+
with VirtualBox (I believe), I have never used those. The VirtualBox
27+
GUI takes a few minutes to use when creating a new VM, and installing
28+
the VM takes the computer a while longer. I estimate around 30 to 45
29+
minutes total time to create a new VM where you install Linux from an
30+
`.iso` file.
31+
32+
A nice thing about VirtualBox is that once you create a VM for the
33+
operating system you want, if you have enough free disk space to keep
34+
around that original VM, it is very quick (30 seconds or less) to
35+
create a copy of that VM, and then install a bunch of software on that
36+
copy. As long as you leave the original VM there, it will not change,
37+
and you can create copies of it whenever you want to try experimenting
38+
with it. Did you accidentally mess up the state of that VM's
39+
system-wide configuration files, or install some weird combination of
40+
software that seems to conflict with each other? You can abandon that
41+
VM image, deleting it whenever you no longer find its contents useful,
42+
and create more clones of the original base OS for further
43+
experiments.
44+
45+
In the VirtualBox GUI window:
46+
47+
+ Click the button "New"
48+
+ In the window that appears, give a unique name to your VM,
49+
e.g. "Ubuntu 24.04 base OS".
50+
+ Select the location of the `.iso` installer file that you
51+
downloaded.
52+
+ I prefer to check the box "Skip Unattended Installation", and these
53+
instructions will assume you are doing so, too.
54+
+ Under "Hardware" choose the amount of RAM, number of virtual CPUs,
55+
and hard disk space you want.
56+
+ In 2024, I rarely want to create a VM with less than 4 GBytes
57+
(4096 MBytes) of RAM. I typically select 4 processors, and 60
58+
GBytes of disk space. I do _not_ click the "Pre-allocate Full
59+
Size" check box, since then it would immediately create a file
60+
that was 60 GBytes in size. If you do not check that box,
61+
VirtualBox creates a disk image file that is only as large as it
62+
needs to be to store the files currently existing within the VM's
63+
file system, not the full size it might grow to later.
64+
+ With VirtualBox, changing the RAM available to a VM after you
65+
create it is quick and easy, either increasing it, or decreasing
66+
it. Simply shut down the VM, select the VM in the GUI, click
67+
"Settings", change the RAM setting, and start the VM image again.
68+
As long as your host OS has enough free RAM, VirtualBox can use it
69+
for the running VM image. Thus, you do not need to think too hard
70+
when choosing the initial RAM size while creating the VM image.
71+
+ I believe it is possible to increase the disk space allocated to
72+
the VM later, but I have not personally done so, and you will not
73+
find instructions to do so here. It is definitely more steps than
74+
changing the RAM size later. It also might be possible to
75+
decrease it later, but only if you can find and run the proper
76+
utility programs in the guest VM to shrink its files into a subset
77+
of the available physical disk space. It is thus more important
78+
to think of the maximum disk space you expect to use within the
79+
VM, _or_ copy files out of it to another system to free up disk
80+
space during the lifetime of that VM. Fortunately you can pick a
81+
large size, and choose the option not to preallocate it all when
82+
the VM is created. It might be easier to create a new VM and copy
83+
files from the old one to the new one vs. increasing the disk
84+
space available to an old one.
85+
+ Click the "Finish" button. This closes the window you were working
86+
on, and a new VM image with the name you gave it has now been
87+
created. It does not have the OS installed yet.
88+
+ Select that new image and click on the button "Settings".
89+
+ Click "General".
90+
+ Under the "Advanced" tab, change "Shared Clipboard" to
91+
"Bidirectional".
92+
+ Click "Display".
93+
+ Under the "Screen" tab, change "Video Memory" from 16 MB to 32 MB.
94+
+ If you want to create a shared folder on your host OS that is
95+
readable and writable from the guest OS, too, click "Shared Folder".
96+
+ Click on the icon that looks like a folder with a "+" symbol on it.
97+
+ Change "Folder Path" to choose the host OS folder you want to share.
98+
+ Check the box for "Auto-mount".
99+
+ If you want the guest OS to only be able to read this folder, but
100+
not write to it, check the box for "Read-only".
101+
+ Click "OK" button.
102+
+ Back in the main settings window for the VM image, click the OK
103+
button.
104+
105+
106+
# Common steps for starting any VM image, including a new installer one
107+
108+
+ Select the VM image and click the "Start" button.
109+
+ If the text is uncomfortably small for reading, select the
110+
VirtualBox menu item View -> Virtual Screen 1 -> Scale to 200%.
111+
Adjust the scale choice to your reading comfort.
112+
113+
114+
# Creating a VM using VirtualBox and an ISO disk image with an Ubuntu Desktop Linux installer
115+
116+
Follow the steps
117+
[here](README-create-vm-using-iso-installer-for-ubuntu-desktop.md).
118+
119+
120+
# Creating a VM using VirtualBox and an ISO disk image with an Ubuntu Server Linux installer
121+
122+
Follow the steps
123+
[here](README-create-vm-using-iso-installer-for-ubuntu-server.md).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Creating the VM using VirtualBox and Vagrant
2+
3+
+ Install
4+
[Vagrant](https://developer.hashicorp.com/vagrant/docs/installation)
5+
on your system if it is not already installed.
6+
+ Create a clone of the https://github.com/p4lang/tutorials
7+
repository.
8+
+ In a terminal window, change to this `vm-ubuntu-24.04` directory
9+
inside the `tutorials` directory.
10+
+ Run the command below:
11+
12+
```bash
13+
vagrant up
14+
```
15+
16+
Proceed to the section titled [Installing open source P4 development
17+
tools on the
18+
VM](README.md#installing-open-source-p4-development-tools-on-the-vm).

0 commit comments

Comments
 (0)