Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Help about MediaWiki
FUTO
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Introduction to a Self Managed Life: a 13 hour & 28 minute presentation by FUTO software
(section)
Main Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Preparing Ubuntu Server for Virtual Machine Management = Next, let’s set up Ubuntu Server for use with virtual machines using '''Virtual Machine Manager''' (virt-manager). We’ll cover everything from preparing the ISO file to configuring the virtual machine with a static IP address, including the installation of a lightweight GUI for easier management. <span id="step-1-prepare-the-ubuntu-server-iso"></span> == Step 1: Prepare the Ubuntu Server ISO == Before creating the virtual machine, you need to place the Ubuntu Server ISO file in the correct directory and set the proper permissions. <ol style="list-style-type: decimal;"> <li><p>Place the ISO file you used to create your installable Ubuntu USB onto your server. You can do this by attaching a disk to it, using SSH FTP and a program like filezilla to transfer it over. Or, if you’re an animal, you can download it again by going to ubuntu.com and downloading the LTS version of Ubuntu server again.</p></li> <li><p>Move the ISO file to <code>/var/lib/libvirt/images/</code>, obviously changing the source location & filename to whatever yours is. As long as the file ends up in <code>/var/lib/libvirt/images/</code> we’re good:</p> <pre>sudo mv ~/Downloads/ubuntu-server.iso /var/lib/libvirt/images/</pre></li> <li><p>Change the ownership and group of the ISO file:</p> <pre>sudo chown libvirt-qemu:libvirt /var/lib/libvirt/images/ubuntu-server.iso</pre></li> <li><p>Set the correct permissions:</p> <pre>sudo chmod 0640 /var/lib/libvirt/images/ubuntu-server.iso</pre></li> <li><p>To apply these settings to all ISO files in the directory:</p> <pre>sudo chown libvirt-qemu:libvirt /var/lib/libvirt/images/*.iso sudo chmod 0640 /var/lib/libvirt/images/*.iso</pre></li></ol> <blockquote>'''Note''': These settings make sure that the <code>libvirt-qemu</code> user, which runs the QEMU processes, can read and write the file, while members of the <code>libvirt</code> group can read it. Other users will have no access, so <code>virsh</code> & related tools can access the ISO files but others can’t. </blockquote> <span id="step-2-update-your-system"></span> == Step 2: Update Your System == Make sure your system is up to date: <pre>sudo apt update ; sudo apt upgrade -y</pre> ''Note:'' Some GNU/Linux distributions update during installation, but it’s always good to check. <span id="step-3-install-openbox-and-virtual-machine-manager"></span> == Step 3: Install Openbox and Virtual Machine Manager == We’ll install a lightweight desktop environment (Openbox) and Virtual Machine Manager: <pre>sudo apt install --no-install-recommends xorg openbox xorg xinit virtualbox virtinst qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager</pre> The <code>--no-install-recommends</code> flag makes sure only the core components are installed without any additional unnecessary packages. <span id="step-4-enable-and-start-libvirt"></span> == Step 4: Enable and Start Libvirt == Enable libvirt to start on boot and start it immediately: <pre>sudo systemctl enable libvirtd sudo systemctl start libvirtd</pre> <span id="step-5-add-your-user-to-necessary-groups"></span> == Step 5: Add Your User to Necessary Groups == To allow your user to configure virtual machines, add yourself to the required groups: <pre>sudo usermod -aG libvirt,kvm $USER</pre> <blockquote>'''NOTE:''' Adding your user to the <code>libvirt</code> & <code>kvm</code> groups is useful so you do not have to become superuser/sudo for <code>virt-manager</code>(virtual machine manager GUI) or<code>virsh</code> to work right. Log out & log back in to make sure you’re in the user group after doing this. </blockquote> <span id="step-6-start-the-gui"></span> == Step 6: Start the GUI == To start the graphical interface, use the following command: <pre>startx</pre> <blockquote>'''Note:''' We will be using the GUI for Virtual Machine Manager. Any time you are NOT using this, exit the GUI (right click the desktop & log out), then type <code>exit</code> from the command line terminal so your machine is not logged in. Even if someone breaks into your house, they’ll have physical access to your computer; but that doesn’t mean they have easy access to your encrypted data. </blockquote> <span id="optional-remote-desktop-access-with-x11vnc-and-tigervnc"></span> ==== 6.1(OPTIONAL): Remote Desktop Access with x11vnc and TigerVNC ==== x11vnc is like teamviewer if teamviewer were open source and 50x slower. x11vnc allows you to connect to your server’s GUI for remote access, as if you were right in front of the computer, without having to be in the room with your computer. Up until now, we have been SSHing into the machine in order to enter terminal commands, but normal SSH won’t work if we want to use the graphical user interface, see a mouse cursor, etc. <blockquote>'''Note:''' If you are ok with sitting in front of your server computer with a keyboard, mouse, & monitor plugged into it when using virtual machine manager, this step is ''unnecessary'' and you can feel free to skip it. </blockquote> This will walk you through setting up remote desktop access to your Ubuntu Server using x11vnc and TigerVNC. I like using '''virtual machine manager''' GUI to install virtual machines on the main server. Since we keep going to the GUI to install virtual machines & use '''virtual machine manager''' via the GUI, we’re stuck sitting in front of the server, which sucks if it’s in a closet or garage. Here’s how you can connect to it to view what is on its screen from another computer. <span id="installing-x11vnc-on-ubuntu-server"></span> ==== 6.2 Installing x11vnc on Ubuntu Server ==== To install x11vnc, run the following command in your terminal: <pre>sudo apt update && sudo apt install x11vnc</pre> This will install the x11vnc package and its dependencies on your server. <span id="set-a-password-for-vnc-authentication"></span> ==== 6.3 Set a Password for VNC Authentication ==== x11vnc uses a password for authentication, and you can set this password as follows: <pre>x11vnc -storepasswd</pre> You will be prompted to enter a password. This password will be saved in the default location <code>~/.vnc/passwd</code>. <span id="set-x11vnc-to-listen-on-all-interfaces-on-port-5920"></span> ==== 6.4 Set x11vnc to Listen on All Interfaces on Port 5920 ==== Open a terminal and run the following: <pre>x11vnc -rfbport 5920 -usepw -auth ~/.Xauthority -display :0 -forever -norc -noxdamage -shared</pre> Here is why this helps clients like Remmina connect: '''1. <code>-rfbport 5920</code>''' This sets the '''port''' on which the VNC server will listen for connections. VNC defaults to port <code>5900</code>, but I like to use a non-standard one because I am strange. '''2. <code>-usepw</code>''' This option enables '''password authentication''' for VNC clients. It requires you to set a password using <code>x11vnc -storepasswd</code> beforehand. Use this to set a VNC password. * Password authentication is standard for VNC clients like Remmina. Without this, some clients might reject the connection for security reasons. And it’s just good practice. '''3. <code>-auth ~/.Xauthority</code>''' The <code>-auth</code> option tells <code>x11vnc</code> which '''authentication file''' to use to access your X session. The file path <code>/run/user/$(id -u)/gdm/Xauthority</code> refers to authorization for the user running the current display session managed by GDM (your display manager). If you’re using LightDM or another manager, the path might differ. * '''Why it helps''': Instead of relying on <code>-auth guess</code> (which might not always find the right file), specifying the correct <code>Xauthority</code> file guarantees that <code>x11vnc</code> can properly access the graphical session. If <code>x11vnc</code> can’t authenticate the display, no client can connect. '''4. <code>-display :0</code>''' This option specifies which '''X display''' to serve via VNC. The display <code>:0</code> is typically the primary display for your desktop session (the one you see on your monitor). It makes sure <code>x11vnc</code> is connecting to the right graphics session. If it were set to the wrong display, you’d either get a black screen or your client wouldn’t connect at all. '''5. <code>-forever</code> ''' Normally, <code>x11vnc</code> stops running after the client disconnects. The <code>-forever</code> flag keeps it running indefinitely. If you disconnect & reconnect it would suck to have to log back in each time. Without this, <code>x11vnc</code> would stop after Remmina disconnects, and you’d have to restart it manually for every new connection. I like stopping <code>x11vnc</code> once I am done manually. '''6. <code>-norc</code> ''' This option tells <code>x11vnc</code> '''not to load a configuration file''' (which might contain unwanted settings), we are only using the settings in this command line. '''7. <code>-noxdamage</code>''' The <code>Xdamage</code> extension tracks changes to the screen, but sometimes it can cause display corruption or update issues in VNC clients. The <code>-noxdamage</code> flag disables this extension to avoid those problems. Some VNC clients who shall not be named sometimes fk up refreshing the screen when properly when <code>Xdamage</code> is enabled. Disabling it keeps artifacts/stuck screen issues. '''8. <code>-shared</code>''' This option allows '''multiple clients to connect simultaneously''' to the VNC server. If this option isn’t set, only one client can connect at a time, and additional connection attempts (such as from Remmina) would fail. Enabling <code>-shared</code> makes sure that you can connect with multiple devices or clients without being disconnected when another connects. <span id="installing-tigervnc-viewer-on-the-client"></span> ==== 6.5 Installing TigerVNC Viewer on the Client ==== To connect to the VNC server from a client machine, you need a VNC viewer. The following steps will install TigerVNC Viewer (also known as <code>vncviewer</code>) on the client (your GNU/Linux computer you are reading this on): <ol style="list-style-type: decimal;"> <li><p>Update the package list and install TigerVNC Viewer:</p> <pre>sudo apt update && sudo apt install tigervnc-viewer -y</pre></li> <li><p>Once installed, you can use <code>vncviewer</code> to connect to the server.</p></li> <li><p>If you use Windows or a Mac, you’re on your own, my friend. Find a VNC client that doesn’t suck.</p></li></ol> <span id="connecting-to-the-vnc-server"></span> ==== 6.6 Connecting to the VNC Server ==== Now that everything is set up, you can connect to your server. <ol style="list-style-type: decimal;"> <li><p>On your local machine, use the following command:</p> <pre>vncviewer 192.168.5.2:5920 -SecurityTypes VncAuth</pre></li> <li><p>''Note'': Replace <code>192.168.5.2</code> with your server’s actual IP address. In our case, we can also use the domain <code>happycloud.home.arpa</code> since we set up a static mapping earlier for our server in '''pfSense'''.</p></li> <li><p>When prompted, enter the VNC password you set earlier.</p></li></ol> '''You should now have a remote desktop connection to your Ubuntu Server. Remember to start <code>x11vnc</code> after you have logged in & typed <code>startx</code> to start Openbox so it works.''' <span id="step-7-using-openbox"></span> == Step 7: Using Openbox == <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_a05cc5c9.png </gallery> Once you’ve installed Openbox and typed <code>startx</code>, Openbox starts: # Right-click on the desktop to open the application menu. # Navigate to '''System > Virtual Machine Manager'''; This is what we are going to be using to create virtual machines. At this point, we have our dependencies set up for virtual machine management, and bridge networking configured so that our virtual machines can go online. We’re ready to set up our first virtual machine! <span id="creating-a-virtual-machine"></span>
Summary:
Please note that all contributions to FUTO may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
FUTO:Copyrights
for details).
Do not submit copyrighted work without permission!
To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:
Cancel
Editing help
(opens in new window)