VirtualBox Ubuntu/Build The VM Image

From DDCIDeos
Jump to navigationJump to search

The following are the steps needed to create the Virtual Box Ubuntu image described in VirtualBox_Ubuntu#Download an Ubuntu Image.

This proedure is typically only needed when a new mirror of the Ubuntu packages is created, e.g., every two years or so.

Create a virtual machine

  1. Start VirtualBox from start menu
  2. 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
  3. Right hand window, select "New"
  4. At the bottom, select Expert Mode.
    Name: ubuntu-20.04-ddci
    Folder: your preference here
    Type: Linux
    Version: Ubuntu (64-bit)
  5. Increase Memory size, 50% of available memory
  6. Under "Hard disk", select "Create a virtual hard disk now".
  7. Click Create.
  8. 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.)
  9. Under "Hard disk file type", select "VDI(VirtualBox Disk Image)".
  10. Under "Storage on physical hard disk", select "Dynamically allocated".
  11. Click Create
  12. 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
    • System
      • Motherboard Tab
        Boot Order: (disable floppy)
      • Processor Tab
        Select as many CPUs (not cores) as you have
    • Display
      • Screen Tab
        Video Memory 64MB (32 is insufficient to run large display windows and it doesn't fail gracefully)
    • Network
      • Adapter 1 Tab
        Uncheck "Enable Network Adapter". Ensure that All adapters are disabled.

Install Ubuntu

Download Installer image for Ubuntu 20.04 ftp://redhat5/Workstation/ubuntu-20210106/iso/ubuntu-20.04.1-desktop-amd64.iso

  1. Start the Oracle VM VirtualBox Manager
  2. 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
    • Click OK
  3. In righthand pane toolbar, click Start. Be ready! The next few steps happen very quickly!
  4. Click Cancel on the "Select startup disk" popup dialog.
  5. As soon as the VirtualBox boot dialog appears, press F4.
  6. As soon as the Ubuntu screen appears, hit F4 again.
  7. Press Enter for English.
  8. Arrow down to "Install Ubuntu".
  9. Press F4 again and select "OEM install (for manufacturers)". (ref https://help.ubuntu.com/community/Ubuntu_OEM_Installer_Overview) Press Enter.
  10. Press Enter again.
  11. When the installer asks for the "Unique name for this batch of systems", enter ddci-ubuntu-20.04
  12. Select language.
  13. Click Continue.
  14. Keyboard Layout: Pick your preference.
  15. Click Continue.
  16. 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".
  17. Click Continue.
  18. In "Installation type", choose "Erase disk and install Ubuntu".
  19. Click Install Now.
  20. "Write the changes to disks?" popup dialog: Click Continue.
  21. "Where are you?" Pick a place.
  22. Click Continue.
  23. In "Who are you?" dialog, enter "ddci" for password and confirm it.
  24. Click Continue.
  25. Wait...
  26. "Installation Complete" dialog: Click Restart Now (Like you have a choice!).
  27. "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
  28. "Please remove the installation media. Then press enter:" screen: Press Enter.
  29. Wait for the system to reboot...
  30. In the VirtualBox Ubuntu VM main menu, select "Devices", "Insert Guest Additions CD Image...".
  31. "VBox_GAs_6.1.16" contains software intended to..." dialog: Click Run.
  32. "Authentication Required" dialog: Enter OEM password (ddci).
  33. Click Authenticate.
  34. 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.
  35. Press Enter to close this window when prompted.
  36. 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
  37. 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

  1. Shutdown the Ubuntu VM:
    • Click Power button (upper right middle), select "Power Off/Log Out", select "Power Off...", then click Power Off.
  2. In the Oracle VirtualBox Manager, press Settings in right hand pane toolbar.
    • Network
      • Adapter 1 Tab
        Check "Enable Network Adapter" then click OK.
  3. 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
rm -rf /var/lib/apt/lists/*
  1. In the VirtualBox Ubuntu VM main menu, select "Devices", "Insert Guest Additions CD Image...".
  2. "VBox_GAs_6.1.16" contains software intended to..." dialog: Click Run.
  3. "Authentication Required" dialog: Enter OEM password (ddci).
  4. Click Authenticate.
  5. Let the process run to conclusion...
  6. Press Enter to close this window when prompted.
  7. IMPORTANT! 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
  8. 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-buildx docker.io
 rm -rf /var/lib/apt/lists/*

Upgrade all the packages

 apt-get update && apt-get upgrade --with-new-pkgs --yes --no-install-recommends
 rm -rf /var/lib/apt/lists/*

Freeze image/Create Snapshot

  1. Reboot the VM.
    • Click Power button (upper right middle), select "Power Off/Log Out", select "Power Off...", then click Restart.
  2. Wait...
  3. On the desktop, double click the "Prepare for shipping to end user" icon.
  4. "Authentication Required" dialog: Enter "ddci" without the quotes. Click Authenticate.
  5. oem-config-pre... dialog: Click OK.
  6. Shutdown the Ubuntu VM:
    • Click Power button (upper right middle), select "Power Off/Log Out", select "Power Off...", then click Power Off.
  7. Oracle VirtualBox VM Manager: Go to Main Menu->Machine->Tools->Snapshots
  8. Click Take.
  9. "Take Snapshot of Virtual Machine" dialog:
    • "Snapshot Name" field: Enter: ubuntu-20.04-ddci-base
    • "Snapshot Description" field: Enter: DDC-I's base ubuntu-20.04 VM.
  10. Click OK.

Publish Results to the FTP/HTTP server

  1. Turn off the Oracle VM VirtualBox Manager.
  2. Using a file browser, navigate to the directory containing the VirtualBox VM images. For example: C:\Users\shh\VirtualBoxVMs.
  3. Zip up the ubuntu-20.04-ddci directory creating ubuntu-20.04-ddci.zip.
  4. Push this zip file to the Deos FTP/HTTP server at ftp://redhat5/Workstation/ubuntu-20210106/vmimages/ubuntu-20.04-ddci.zip

Random thoughts by Aaron

It would be nice if the following was integrated into the image as well.

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.

Haven't investigated these, but likely something should be done:

* 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