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!
= Creating a Virtual Machine = Our first virtual machine will be for '''mailcow''' and '''bitwarden'''. These provide the following: '''Mailcow''': - Self managed email server for sending & receiving mail - Integrated spam management & web interface - Calendar & contacts syncing with mobile devices - A lovely, ''“just works”'' mashup of - Postfix for sending mail - Dovecot for receiving mail - rspamd for killing spam - SoGo for webmail/calendar/contacts '''Bitwarden''': - Password management across devices, browsers, phones, computers, etc. - Alerts when your passwords have been found in a breach <blockquote>'''Note:''' These instructions will carry over into many other virtual machine installs we will be doing. I will ask you to refer back to this section. Often, the only thing you will be doing is changing the RAM amount and CPU cores allotted to the VM, and the IP address you choose as you install. </blockquote> <span id="options-for-virtual-machine-creation"></span> === Options for Virtual Machine Creation === When you start creating a new virtual machine, you’ll see several options. We’re going to use “local install media” because we’re working with the ISO image of the Ubuntu server we downloaded. But before getting into that, let me explain the “import existing disk image” option, which is pretty cool :) <span id="import-existing-disk-image"></span> ==== Import Existing Disk Image ==== Imagine you’ve got a bunch of old laptops lying around, each running different servers. Maybe you’ve got a Dell Latitude D620 from 2006 or a [https://www.youtube.com/watch?v=X86F1j5gCQs&pp=ygUcZnJlZXBieCByb3NzbWFubmdyb3VwIGxlbm92bw%3D%3D piece of junk Lenovo with a dying northbridge] running your entire business phone system; not that I ever did that. But if you did, you could use a tool like <code>ddrescue</code> to make a disk image of each server. Then, you can import them into your virtual machine setup and keep them running without separate installations. It’s a useful method of consolidating everything onto one machine until you have time to set things up properly! <span id="local-install-media"></span> ==== Local Install Media ==== This option expects us to choose a disk image (whether for a CD-ROM or a USB stick) that we will use to make a fresh installation onto our computer. This option is for when we want to create our own virtual machine from scratch, and is what we are going to be using. <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_a05cc5c9.png </gallery> <span id="step-1-setting-up-virtual-machine-manager-virsh"></span> == Step 1: Setting up Virtual Machine Manager (virsh) == <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_b51c10bd.png </gallery> <span id="create-new-virtual-machine"></span> ==== 1.0 Create new virtual machine ==== In '''Virtual Machine Manager''', click “Create a new virtual machine” (usually the first icon on the toolbar or select '''File > New Virtual Machine''' from the menu). <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_151745e3.png File:lu55028jxckj_tmp_9a251511.png File:lu55028jxckj_tmp_8bf9cc92.png </gallery> <span id="choose-installation-media"></span> ==== 1.1 Choose Installation Media ==== * Select '''“Local install media (ISO image or CDROM)”''' and click '''Forward'''. * Click '''Browse''' to select your Ubuntu Server ISO. * Choose the ISO file you prepared earlier (e.g., <code>/var/lib/libvirt/images/ubuntu-server.iso</code>) and click '''Forward'''. <span id="choose-operating-system-version"></span> ==== 1.2 Choose Operating System Version ==== * '''Virtual Machine Manager''' may automatically detect the OS. If not, search for <code>ubuntu</code> and choose what is closest to your version. When in total doubt, <code>linux generic 2022</code> works. Click '''Forward'''. <span id="configure-memory-and-cpu"></span> ==== 1.3 Configure Memory and CPU ==== * Allocate the resources for your VM: ** '''Set RAM:''' (e.g., 4096 MB). ** '''Set vCPUs:''' (e.g., 2 CPUs max for what we are doing here). * Click '''Forward'''. <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_52d81284.png </gallery> <span id="configure-storage"></span> ==== 1.4 Configure Storage ==== * Select “Create a disk image for the virtual machine”. * Allocate an initial disk size that is whatever you think the maximum amount of storage you will need for email, contacts, and calendar is (e.g., 25 GB). You’ll be able to resize this disk later, so make sure it’s large enough for your initial installation but leave room for growth. * Make sure the disk image format is '''QCOW2'''. This format supports resizing, and other cool features. * Click '''Forward'''. <blockquote>'''NOTE:''' QCOW2 format has a lot of useful features. It supports snapshots, which we aren’t using for our virtual machine backups, but it’s nice to have if you choose to use that. More importantly, qcow2 supports “sparse file allocation.” aka, it only uses physical disk space as it needs. Just because you say a virtual machine has access to 300 gigabytes, doesn’t mean it creates an image that actually takes up 300 gigabytes. </blockquote> <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_a84796b3.png </gallery> <span id="set-up-networking-with-the-bridge-interface"></span> ==== 1.5 Set Up Networking with the Bridge Interface ==== * Choose '''“Bridge device”''' under '''“Network Selection”'''. * In the Device Name field, type '''br0''' (or whatever name you have given your bridge interface). * This will allow the VM to grab a static IP from the same network as your host machine, making sure it acts like an independent hardware device. * Click '''“Finish”'''. <blockquote>'''NOTE:''' Choosing “bridge device” allows the virtual machine to appear like a unique hardware device on your network. That’s the idea, for each of our virtual machines to seem like Pinnocchio; a real machine :) </blockquote> <div class="figure"> <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_bcbe1ce7.png </gallery> </div> <span id="finish-customize-before-installing"></span> ==== 1.6 Finish & Customize Before Installing ==== * Name your virtual machine (e.g., '''“mailserver”'''), whatever you think makes sense for a contacts/calendar/mail machine. * Click '''“Finish”'''. <div class="figure"> <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_f5a5b1fa.png </gallery> </div> <span id="step-2-install-ubuntu-server-as-a-virtual-machine"></span> == Step 2: Install Ubuntu Server as a Virtual Machine == <blockquote>'''Note:''' I will be blazing through the installing of Ubuntu here, since we already installed Ubuntu server once onto this physical server. </blockquote> '''Keep in mind the following:''' We are NOT using LUKS encryption here. There is no need since the image is going to be stored on an encrypted partition. We are NOT using RAID – this is a disk image that is being stored on a RAID array, so we are not doing that. We are configuring networking the same as we did before, but we will be using a '''''different''''' IP address! <blockquote>'''NOTE:''' Setting a unique static IP address to each virtual machine is necessary. It’s like having 5 businesses in the same building and expecting the postman to deliver laptops to the right address.. that’s never a problem that plagued me in new york city. If something else is using that IP address, you cannot use it again. You don’t want your packets ending up in Berwick Maine. </blockquote> <span id="start-the-installation-process-in-the-virtual-machine"></span> ==== 2.1 Start the installation process in the virtual machine ==== Choose your language and select '''“Try or install Ubuntu Server”'''. Follow the installation prompts. <div class="figure"> <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_a561e59a.png </gallery> </div> <span id="configure-static-ip-address"></span> ==== 2.2 Configure Static IP Address ==== * When you reach the Network configuration screen, select the network interface that corresponds to your network interface. * Choose the option '''“Configure network manually”'''. * Enter the following details: ** IP Address: '''192.168.5.3''' ** Subnet: '''192.168.5.0/24''' ** Gateway: '''192.168.5.1''' ** Nameserver: '''192.168.5.1''' * Make sure you enter all the details correctly to provide the virtual machine has the correct static IP configuration. <div class="figure"> <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_cd2383aa.png </gallery> </div> <div class="figure"> <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_1d3ec660.png </gallery> </div> <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_e896bdf7.png File:lu55028jxckj_tmp_b1313746.png File:lu55028jxckj_tmp_664e174.png File:lu55028jxckj_tmp_9a7daf09.png File:lu55028jxckj_tmp_cd86d6ef.png File:lu55028jxckj_tmp_9b21c766.png </gallery> <span id="partition-the-virtual-drive"></span> ==== 2.3 Partition the virtual “drive” ==== * When you reach the Filesystem setup section, select '''“Use an entire disk”''' and then choose the disk you want to install Ubuntu Server on. * Choose the option '''“Set up this disk as an LVM group”'''. * '''Important:''' At this stage, edit the partition sizes as Ubuntu’s installer usually allocates 2 GB for boot which is ridiculous and even worse it only uses half the available space for your LVM & root. The Ubuntu auto partitioner is horrible. * Reduce the boot partition to 512 MB. * Delete the old LVM & root partition. * Create a new LVM taking up the entire disk. * Create a logical volume for the root filesystem, using all available space. * '''Do not encrypt the volume''' (it’s unnecessary since the host drive is already encrypted, and it is not my intention for you to have these VMs running on other people’s servers). <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxckj_tmp_b4178b46.png File:lu55028jxckj_tmp_3d6c5298.png File:lu55028jxckj_tmp_751040c0.png </gallery> <span id="finalize-installation-do-not-install-docker"></span> ==== 2.4 Finalize installation & do not install docker ==== * Set up your username and password. * '''Choose to install OpenSSH server.''' <blockquote>'''NOTE:''' ''DO NOT CHOOSE TO INSTALL PACKAGES THROUGH THE PROMPTS AFTER THIS. THEY INSTALL VIA SNAP. DOCKER INSTALLED VIA SNAP IS CANCER. USING THE SNAP VERSION OF DOCKER WILL PROVIDE YOU WITH MANY AGGRAVATING HEADACHES. DON’T DO IT. IGNORE ME NOW? SUFFER LATER!'' </blockquote> * After configuring the partition sizes, proceed with the installation process as usual, following the prompts to set up any additional software you want to install. * Once the installation is complete, the system will automatically apply your network and partitioning settings. * When prompted, remove the installation media (ISO) from the virtual machine settings. * Restart the virtual machine. <span id="step-3-post-installation-tasks"></span> == Step 3: Post-Installation Tasks == <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxdhn_tmp_ce86cb27.png File:lu55028jxdhn_tmp_b291175e.png File:lu55028jxdhn_tmp_b1c36016.png </gallery> <span id="remove-the-cdrom"></span> ==== 3.1 Remove the CDROM ==== * Go to '''View —> details''' in virtual machine manager * Go to '''SATA CDROM''' on the left side. * Confirm that the '''source path''' is the Ubuntu ISO we downloaded for installing Ubuntu server on this virtual machine * Click '''Remove''' in the lower right corner. * UNCHECK '''Delete associated storage files''' – we will use this image again later! * Click delete. * You may have to turn off the VM to do this. <gallery mode="packed-hover" heights=250 widths=400 perrow=2> File:lu55028jxdhn_tmp_fb68028c.png File:lu55028jxdhn_tmp_5504653d.png File:lu55028jxdhn_tmp_22a2f148.png File:lu55028jxdhn_tmp_75aac442.png </gallery> <span id="set-up-static-ip-mapping-in-pfsense-1"></span> ==== 3.2 Set Up Static IP Mapping in pfSense: ==== * Log into your '''pfSense''' router. * Go to '''Status > Diagnostics > ARP Table'''. * Find the MAC address associated with your server’s IP (e.g., '''192.168.5.3'''), copy it. * Go to '''Services > DHCP Server'''. * Scroll to the bottom and click '''“Add static mapping”'''. * Enter the MAC address and IP address of your server. * Give it a descriptive name (e.g., “'''mailserver static IP'''”). * Set the hostname to <code>mailserver</code> * Save and apply changes. ''Note:'' This makes sure that this IP address is reserved for this computer to connect to, so that no other device can take it (unless they are spoofing MAC addresses, but if someone does, that’s a different story). <span id="set-up-this-virtual-machine-to-start-at-boot"></span> ==== 3.3 Set up this virtual machine to start at boot: ==== <pre>virsh autostart mailserver</pre> * Check that this is set up properly by typing <code>virsh dominfo mailserver</code> and seeing if the autostart line is set to enable. * If you don’t do this, you will realize once it is too late & you’ve left your house after you have rebooted your server (for whatever reason) that none of your services are working. This will suck. * This command makes it so that the virtual machine starts each time we boot the computer. <span id="calendar-contacts-using-sogo-within-mailcow"></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)