VirtualBox Ubuntu: Difference between revisions
| Line 371: | Line 371: | ||
# Turn off the Oracle VM VirtualBox Manager. | # Turn off the Oracle VM VirtualBox Manager. | ||
# Using a file browser, navigate to the directory containing the VirtualBox VM images. For example: C:\Users\shh\VirtualBoxVMs. | # Using a file browser, navigate to the directory containing the VirtualBox VM images. For example: C:\Users\shh\VirtualBoxVMs. | ||
# Zip up the ubuntu-20.04 directory creating | # Zip up the ubuntu-20.04 directory creating ubuntu-20.04.zip. | ||
# Push this zip file to the Deos FTP/HTTP server at ftp://redhat5/Workstation/ubuntu-20210106/ | # Push this zip file to the Deos FTP/HTTP server at ftp://redhat5/Workstation/ubuntu-20210106/vmimages/ubuntu-20.04-ddci.zip | ||
<TBD> | <TBD> | ||
Revision as of 18:26, 9 February 2021
The following describes how to get an Ubuntu Linux distribution running in a VirtualBox virtual machine.
How To Use
Install VirtualBox
On a Windows Host
Download from https://www.virtualbox.org/wiki/Downloads
https://download.virtualbox.org/virtualbox/6.1.16/VirtualBox-6.1.16-140961-Win.exe f6f6a4e5aebca49e025ba76f9a41507a
Run the installer
Click through dialogs
Don't install USB
- start VirtualBox (e.g., from start menu)
- File, Preferences, General/Default Machine Folder; Remove space from "VirtualBox VMs" This may not be worth the hassle. Spaces and caps in unix filenames, the horror
Download an Ubuntu Image
Download a pre-built VirtualBox machine image.
Temporary
copy \\nx3000\Deos\VirtualBoxVMs\Ubuntu-20.04 to your home directory\VirtualBoxVMs directory
WARNING: If you are using Docker and have the Windows Hyper-V backend installed, you may have to uninstall it for VirtualBox to work.
In the VirtualBox VM
- Machine, then Add
- navigate to the VirtualBoxVMs\Ubuntu-20.04\Ubuntu-20.04.vbox
- Select Open
- "Start" the machine
- In the boot menu select Ubuntu
- click through the startup configuration. Use your host username as the Ubuntu username.
- In a terminal:
- docker run hello-world
Mounting drives
This needs to be done by the end user the first time they log in.
This mounts the C drive in the the guest user's home directory.
In the virtualbox manager, select the machine, and choose Settings, then:
- Shared Folders
- Mount C drive
- Machine Folders, then select the "folder+" (add) icon
- Folder Path: C:\
- Folder Name: C_DRIVE
- uncheck Auto-mount
- Mount point: this can be anything you like, including blank
- Make Permenent: checked
- Machine Folders, then select the "folder+" (add) icon
- Mount Home directory (optional)
- Folder Path: The host path to the home directory to be used for your virtual machines, e.g., c:\home\bcronk
- Folder Name: the host OS's user name, e.g., bcronk
- uncheck Auto-mount
- Mount point: this can be anything you like, including blank
- Make Permenent: checked
- Mount C drive
- Start the VM, and a terminal:
# Arrange to mount c drive: DO NOT use sudo -i here, the $HOME etc variables are user specific. mkdir ~/cdrive sudo bash -c "echo 'C_DRIVE $HOME/cdrive vboxsf uid=$UID,gid=$(id -g)' >> /etc/fstab" # Optional: Share VM home directory with host VM directory. Untested! YMMV. sudo bash -c "echo '$USER $HOME vboxsf uid=$UID,gid=$(id -g)' >> /etc/fstab" sudo mount -a
The above does what can also be done interactively using this command:
sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) C_DRIVE $HOME/cdrive
The above is based on many net searches including:
- https://askubuntu.com/questions/252853/how-to-mount-a-virtualbox-shared-folder-at-startup
- https://help.ubuntu.com/community/VirtualBox/SharedFolders
TODO: Might also want the above commands to specify modes and mask options.
Be A Maintainer
If the intent of the VM image is to develop DDCI components, then you need to add the DDS distribution specific server. The following ueses "jupiter" as an example.
Add the DDCI DDS distribution-specific ftp server directory as a new package repository. Untested as of 2021-02-01
Start a terminal window (mouse on "activities" type "terminal")
sudo -i
echo "deb [trusted=yes arch=amd64] ftp://redhat5.ddci.com/Workstation/ubuntu-ddci/ jupiter ddci" > \
/etc/apt/sources.list.d/ddci-dist-jupiter.list
# Adding the unreleased.list step is only required if you want to use unreleased components.
echo "deb [trusted=yes arch=amd64] ftp://redhat5.ddci.com/Workstation/ubuntu-ddci/ jupiter ddci-unreleased" > \
/etc/apt/sources.list.d/ddci-dist-jupiter-unreleased.list
apt-get update
apt-get upgrade
Steps To Build The VM Image
The following describes how to create the Ubuntu image described in #Download an Ubuntu Image above. In other words, you do not need to perform the below if you already performed the above.
Create a virtual machine
- Start VirtualBox from start menu
- File, Preferences, General/Default Machine Folder; Remove space from "VirtualBox VMs" This may not be worth the hassle. Spaces and caps in unix filenames, the horror
- Right hand window, select "New"
- At the bottom, select Expert Mode.
- Name: ubuntu-20.04
- Folder: your preference here
- Type: Linux
- Version: Ubuntu (64-bit)
- Increase Memory size, 50% of available memory
- Under "Hard disk", select "Create a virtual hard disk now".
- Click Create.
- In Create Virtual Hard Disk dialog:
- 25GB, VDI, Dynamically allocated Base image, without docker, takes up 9.3GB, but many apps could be deleted, e.g., rythmbox, office apps, etc.
- (Perhaps we should select a smaller disk for the "OS" disk, and have users create their own if needed, or just always depend on a mount.)
- 25GB, VDI, Dynamically allocated Base image, without docker, takes up 9.3GB, but many apps could be deleted, e.g., rythmbox, office apps, etc.
- Under "Hard disk file type", select "VDI(VirtualBox Disk Image)".
- Under "Storage on physical hard disk", select "Dynamically allocated".
- Click Create
- Make sure the new VM is selected in the left hand pane, Press Settings in right hand pane toolbar.
- General:
- Advanced Tab
- Shared Clipboard: Bidirectional
- Drag'n'Drop: Bidirectional
- Advanced Tab
- System
- Motherboard Tab
- Boot Order: (disable floppy)
- Processor Tab
- Select as many CPUs (not cores) as you have
- Motherboard Tab
- Display
- Screen Tab
- Video Memory 64MB (32 is insufficient to run large display windows and it doesn't fail gracefully)
- Screen Tab
- Network
- Adapter 1 Tab
- Uncheck "Enable Network Adapter". Ensure that All adapters are disabled.
- Adapter 1 Tab
- General:
Install Ubuntu
Download Installer image for Ubuntu 20.04 ftp://redhat5/Workstation/ubuntu-20210106/iso/ubuntu-20.04.1-desktop-amd64.iso
- Start virtual box
- In righthand pane toolbar, select Settings
- Storage
- In Controller: IDE, select the "CD Icon"
- Check the: Live CD/DVD checkbox.
- Choose the "CD Icon" to the far right, "Choose a Disk File", and point it at your Ubuntu installer image
- In Controller: IDE, select the "CD Icon"
- Click OK
- Storage
- In righthand pane toolbar, click Start. Be ready! The next few steps happen very quickly!
- Click Cancel on the "Select startup disk" popup dialog.
- As soon as the VirtualBox boot dialog appears, press F4.
- As soon as the Ubuntu screen appears, hit F4 again.
- Press Enter for English.
- Arrow down to "Install Ubuntu".
- Press F4 again and select "OEM install (for manufacturers)". (ref https://help.ubuntu.com/community/Ubuntu_OEM_Installer_Overview) Press Enter.
- Press Enter again.
- When the installer asks for the "Unique name for this batch of systems", enter ddci-ubuntu-20.04
- Select language.
- Click Continue.
- Keyboard Layout: Pick your preference.
- Click Continue.
- In "Updates and other software" screen, choose "Minimal installation", uncheck "Download updates while installing Ubuntu", and uncheck "Install third party software for graphics and Wi-Fi hardware and additional media formats".
- Click Continue.
- In "Installation type", choose "Erase disk and install Ubuntu".
- Click Install Now.
- "Write the changes to disks?" popup dialog: Click Continue.
- "Where are you?" Pick a place.
- Click Continue.
- In "Who are you?" dialog, enter "ddci" for password and confirm it.
- Click Continue.
- Wait...
- "Installation Complete" dialog: Click Restart Now (Like you have a choice!).
- "Please remove the installation media. Then press enter:" screen: Go to Main Menu->Machine->Settings->Storage:
- In Controller: IDE, select the "CD Icon"
- Uncheck the: Live CD/DVD checkbox.
- Choose the "CD Icon" to the far right, "Remove Disk from Virtual Drive".
- Click OK
- In Controller: IDE, select the "CD Icon"
- "Please remove the installation media. Then press enter:" screen: Press Enter.
- Wait for the system to reboot...
- In the VirtualBox Ubuntu VM main menu, select "Devices", "Insert Guest Additions CD Image...".
- "VBox_GAs_6.1.16" contains software intended to..." dialog: Click Run.
- "Authentication Required" dialog: Enter OEM password (ddci).
- Click Authenticate.
- Let the process run to conclusion... NOTE: There will be a message about "This system is currently not set up to build kernel modules." Ignore it for now.
- Press Enter to close this window when prompted.
- Go to Main Menu->Machine->Settings->Storage:
- In Controller: IDE, select the "CD Icon"
- Choose the "CD Icon" to the far right, "Remove Disk from Virtual Drive".
- Click OK
- In Controller: IDE, select the "CD Icon"
- Reboot This seems necessary to get cut/paste working, which is most helpful for the next steps.
- Click Power button (upper right middle), select "Power Off/Log Out", select "Power Off...", then click Restart.
Remove packages not on DDCI package mirror
It is very important that the following steps, up through changing the apt/sources.list, be performed in an environment where the Ubuntu system doesn't automatically start downloading and installing updated packages from the internet. If that happens the repeatability of this process cannot be ensured. Updating packages to versions newer than are on the DDCI mirror also can leave the system in a state where it is impossible to perform an "apt-get install" because of package version skew. When running in the OEM install mode with the network disabled, the system doesn't do package updates.
You will need to open a terminal for the following steps. Right click on the desktop and select "Open in Terminal".
Enter administrator mode.
sudo -i [sudo] password for oem: <Enter "ddci" without the quotes.>
Remove packages not on DDCI package mirror
# The ddci mirror is not complete. Some packages require files to be downloaded # as part of "apt-get update" that are not on the DDCI server. The files to be # so downloaded are controlled by configuration files in /etc/apt/apt.conf.d # If a configuration file requests a file not present in the mirror the error is: # E: Some index files failed to download. They have been ignored, or old ones used instead. # The configuration files that are known to be problematic (as of Ubuntu 20.04) # are: # 50appstream # 50command-not-found # The associated packages must be removed: apt-get purge appstream command-not-found rm -rf /var/lib/apt/lists/*
Switch Package Server
Switch the package server to the DDCI private repository:
sed --in-place --regexp-extended \
-e '/^[^#].*-backports/s/^/#/' \
-e '/^(deb http:\/\/)(.*archive|.*security)(.ubuntu.com.*$)/s;;#\1\2\3\ndeb [trusted=yes arch=amd64] http://redhat5.ddci.com/Workstation/ubuntu-20210106/mirror/archive\3;' \
/etc/apt/sources.list
Enable DNS Through VPN
Enable the VM to use the host OS VPN by adding the following lines to /etc/systemd/resolved.conf
mkdir -p /etc/systemd/resolved.conf.d echo 'DNS=10.0.1.200' > /etc/systemd/resolved.conf.d/ddci.conf echo 'FallbackDNS=10.0.1.199' >> /etc/systemd/resolved.conf.d/ddci.conf echo 'Domains=ddci.com' >> /etc/systemd/resolved.conf.d/ddci.conf
Enable the VirtualBox Ubuntu VM Network
- Shutdown the Ubuntu VM:
- Click Power button (upper right middle), select "Power Off/Log Out", select "Power Off...", then click Power Off.
- In the Oracle VirtualBox Manager, press Settings in right hand pane toolbar.
- Network
- Adapter 1 Tab
- Check "Enable Network Adapter" then click OK.
- Adapter 1 Tab
- Network
- Restart the Ubuntu VM by clicking on the Start icon. Wait...
Install Guest Additions Dependencies
You will need to open a terminal for the following steps. Right click on the desktop and select "Open in Terminal".
Enter administrator mode.
sudo -i [sudo] password for oem: <Enter "ddci" without the quotes.>
The virtualbox guest additions CD image requires the following programs so that it can build kernel modules:
apt-get update && apt-get install --yes --no-install-recommends gcc make perl
- In the VirtualBox Ubuntu VM main menu, select "Devices", "Insert Guest Additions CD Image...".
- "VBox_GAs_6.1.16" contains software intended to..." dialog: Click Run.
- "Authentication Required" dialog: Enter OEM password (ddci).
- Click Authenticate.
- Let the process run to conclusion...
- Press Enter to close this window when prompted.
- Go to Main Menu->Machine->Settings->Storage:
- In Controller: IDE, select the "CD Icon"
- Choose the "CD Icon" to the far right, "Remove Disk from Virtual Drive".
- Click OK
- In Controller: IDE, select the "CD Icon"
- Reboot This seems necessary to get cut/paste working, which is most helpful for the next steps.
- Click Power button (upper right middle), select "Power Off/Log Out", select "Power Off...", then click Restart.
Ensure new Users are in Required Groups
The following ensures that new users will be in the vboxsf and docker groups by modifying /etc/adduser.conf. The vboxsf group is required to access virtual box mounted shares, and the docker group is required for DDCI's use of docker.
You will need to open a terminal for the following steps. Right click on the desktop and select "Open in Terminal".
Enter administrator mode.
sudo -i [sudo] password for oem: <Enter "ddci" without the quotes.>
Copy (through EOF) and paste the all of these commands into the terminal window.
sed --in-place -E '/^EXTRA_GROUPS/d' /etc/adduser.conf sed --in-place -E '/^ADD_EXTRA_GROUPS/d' /etc/adduser.conf ed /etc/adduser.conf <<EOF /^#EXTRA_GROUPS=/ a EXTRA_GROUPS="adm cdrom sudo dip plgdev lpadmin lxd sambashare vboxsf docker" . /^#ADD_EXTRA_GROUPS/ a ADD_EXTRA_GROUPS=1 . w q EOF
NOTE: Doing the above in the OEM install is effectively the same as interactively adding the groups to a user via:
usermod -a -G docker,vboxsf $USER
NOTE: To run in final VM image:
docker image ls # this shouldn't require sudo access.
Install Docker
Here is how to install from the DDCI repository:
apt-get update && apt-get install --yes --no-install-recommends docker docker.io containerd runc
Freeze image/Create Snapshot
- Exit the terminal session but typing exit twice.
- On the desktop, double click the "Prepare for shipping to end user" icon.
- "Authentication Required" dialog: Enter "ddci" without the quotes. Click Authenticate.
- oem-config-pre... dialog: Click OK.
- Shutdown the Ubuntu VM:
- Click Power button (upper right middle), select "Power Off/Log Out", select "Power Off...", then click Power Off.
- Oracle VirtualBox VM Manager: Go to Main Menu->Machine->Tools->Snapshots
- Click Take.
- "Take Snapshot of Virtual Machine" dialog:
- "Snapshot Name" field: Enter: ubuntu-20.04-ddci
- "Snapshot Description" field: Enter: DDC-I's base ubuntu-20.04 VM.
- Click OK.
Publish Results to the FTP/HTTP server
- Turn off the Oracle VM VirtualBox Manager.
- Using a file browser, navigate to the directory containing the VirtualBox VM images. For example: C:\Users\shh\VirtualBoxVMs.
- Zip up the ubuntu-20.04 directory creating ubuntu-20.04.zip.
- Push this zip file to the Deos FTP/HTTP server at ftp://redhat5/Workstation/ubuntu-20210106/vmimages/ubuntu-20.04-ddci.zip
<TBD>
Random thoughts by Aaron
It would be nice if the following was integrated into the image as well.
I suggest making a snapshot (power off!) before playing with this, at least until we can verify it all works.
It is important to verify that after installing docker that installs of the DDS components still work. Lisa and Aaron have seen issues where installing new versions of software from ubuntu servers makes it impossible to do something like: apt-get install desk-ppc
Using the (frozen in time) DDCI package repository with "latest from net" packages is not likely to mix well.
Do the docker stuff from below.
Haven't investigated these, but likely something should be done:
* sudo snap run canonical-livepatch disable may not be necessar # Disable auto updates? * Turn off screen saver? ## settings / Power / Blank Screen = Never Or perhaps https://askubuntu.com/questions/109120/how-do-i-turn-off-the-screen-saver-using-the-command-line
Publish Results
upload virtual disk image for which ever snapshots above make sense.