# How to Install Ubuntu Server 24.04

### Overview

This article will teach us how to:

* Install Ubuntu Server 24.04 on a laptop from scratch
    
* Install Ubuntu server by using [Vagrant](https://www.vagrantup.com/) tool with ISO image
    

Prerequisites:

1. A laptop without any OS installed;
    
2. A virtualization software Virtualbox that Vagrant uses to create virtual machines.
    
3. Vagrant which automates the setup and provisioning of virtual machines.
    

### Installing Ubuntu Server on Laptop

Installing Ubuntu Server on a laptop is a straightforward process, though it involves several steps:

1. Go to the [Ubuntu Server Download Page](https://ubuntu.com/download/server) and click the download link to get the ISO file. In this hands-on, Ubuntu Server 24.04.1 LTS version was downloaded and used as a base image.
    
2. Download a [*balenaEtcher*](https://etcher.balena.io/)*,* a USB creation tool that allows you to create bootable media.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728315509258/3cb320b4-e16b-4d96-93cf-70475cfeab2b.png align="center")
    
3. Now, when *balenaEtcher* is downloaded as a `.zip` file, extract it with the `unzip` command:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728315718145/018ea82d-96f6-4844-9207-d309da22e60f.png align="center")
    
    After extraction, you will find an executable file with `.AppImage` extension.
    
4. Insert your USB drive with at least 4 GB of space into your computer.
    
5. Run the balenaEtcher, select the downloaded Ubuntu Server ISO, choose the USB drive, and start the flashing process:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728316080031/3a34d492-e1eb-4018-90d7-c63f082f72b0.png align="center")
    
    <div data-node-type="callout">
    <div data-node-type="callout-emoji">💡</div>
    <div data-node-type="callout-text">This process will erase all data on the USB drive, so make sure to back up any important files.</div>
    </div>
    
6. Insert the bootable USB drive into your laptop, restart your laptop, and enter the boot menu (usually by pressing `F12` on the Dell laptop).
    
    <div data-node-type="callout">
    <div data-node-type="callout-emoji">💡</div>
    <div data-node-type="callout-text">If you have any important data on your laptop, back it up as the installation process may erase the entire disk.</div>
    </div>
    
7. Select the USB drive from the boot options and press `Enter`.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728373084387/004d3b8b-2d68-426b-9ad8-1fd3f6681a82.png align="center")
    
8. Choose the language you want to use for the installation process.
    
9. Select your preferred keyboard layout.
    
10. Choose the type of installation.
    
11. Configure Network:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728373347039/4389e80d-ca7b-48a2-b2a1-676cc8c53f34.png align="center")
    
    If your network is not found among other networks, you can continue without a network and later configure the network at your own pace.
    
12. If your system requires a proxy to connect to the Internet, configure your Proxy.
    
13. If you use an alternative mirror for Ubuntu, enter the Mirror address details.
    
14. Set Up the Storage:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728373975425/19bb29f1-477d-4911-8d5c-b873cba9fda9.png align="center")
    
    <div data-node-type="callout">
    <div data-node-type="callout-emoji">💡</div>
    <div data-node-type="callout-text">In this hands-on, an entire disk was chosen for the Ubuntu Server OS, however choosing the entire disk is not recommended since it will erase all data on the disk, making it unsuitable if you need to preserve existing data or partitions.</div>
    </div>
    
15. Create a user account by entering your name, the server name, and a username and password for the system.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728378622626/a3d09f9e-f7a2-4870-bfcb-8f2ab9ed87c2.png align="center")
    
16. If you plan to access your server remotely, choose to install the OpenSSH server.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728378838614/00cf7558-1cd1-4f00-9325-72646dc4ee05.png align="center")
    
17. Confirm the installation details and start the process. The installer will copy the files and configure the system. This may take some time.
    
18. Once the installation is complete, remove the installation media and press `Enter` to reboot.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728378993735/c99dbda0-e63a-4011-9e71-9f2ad9f15e6c.png align="center")
    
19. Log in with the username and password you created during the installation.
    
    Your Ubuntu Server installation is now complete. You can start using it as a server or install additional services as needed.
    

### Install Ubuntu Server via Vagrant

To install Ubuntu Server manually using a Vagrant machine with a downloaded ISO file, follow these steps:

1. Edit the `Vagrantfile` to configure the virtual machine and specify that it should boot from the ISO file:
    
    ```bash
     Vagrant.configure("2") do |config|
      config.vm.box = "bento/ubuntu-20.04"
      config.vm.provider "virtualbox" do |vb|  
          vb.gui = true 
          # Ensure the boot order prioritizes booting from the virtual DVD drive
          vb.customize ["modifyvm", :id, "--boot1", "dvd", "--boot2", "disk"]
          # Attach the ISO file to the VM as a virtual DVD drive to the existing SATA controller
          vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", "0", "--device", "0", "--type", "dvddrive", "--medium", "path/to/your/ubuntu-24.04.1-live-server-amd64.iso"]
          
          # Create and attach a virtual hard disk to the SATA controller for installation
         vb.customize ["createhd", "--filename", "ubuntu-server-disk.vdi", "--size", 20000]  # creates a 20 GB virtual hard disk that the Ubuntu Server can be installed on.
         vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", "1", "--device", "0", "--type", "hdd", "--medium", "ubuntu-server-disk.vdi"] #the new virtual hard disk is attached to the SATA controller
    
          # Optionally increase VM resources (like memory or CPU)
          vb.memory = "4096"
          vb.cpus = 2
      end
      # Configure a bridged network
      config.vm.network "public_network", bridge: "wlo1: Wi-Fi (Home)"
      #This configuration forwards requests made to port 2222 on your host machine to port 22 on the Vagrant guest machine
      config.vm.network "forwarded_port", guest: 22, host: 2222, auto_correct: true
    end
    ```
    
    Replace `"path/to/your/ubuntu-server.iso"` with the actual path to the Ubuntu Server ISO file on your system.
    
2. Once your `Vagrantfile` is ready, you can boot the machine:
    
    ```bash
    vagrant up
    ```
    
    This will start the virtual machine and boot from the ISO file to install Ubuntu Server on the virtual hard disk.
    
3. Since the ISO is loaded, the Ubuntu Server installation screen will appear. You should now be able to install Ubuntu Server as if you were on physical hardware. Proceed with the standard Ubuntu Server installation steps within the VM.
    
4. After installation is complete, you may see an error “`Failed unmounting crdom.mount /cdrom`“, which means that the installation medium (ISO image) is still mounted in the virtual machine's virtual CD-ROM drive. Power off the VM to make sure that the ISO file is detached from the virtual machine so that the system can reboot from the newly installed Ubuntu Server operating system on the virtual hard disk.
    
5. Now edit the Vagrantfile to change the boot order to boot directly from the virtual hard disk (where the OS was already installed).
    
    ```bash
    # Ensure the boot order prioritizes booting from the virtual DVD drive
    vb.customize ["modifyvm", :id, "--boot1", "dvd", "--boot2", "disk"]
    ```
    
    <div data-node-type="callout">
    <div data-node-type="callout-emoji">💡</div>
    <div data-node-type="callout-text">The <strong>default boot order</strong> typically prioritizes the hard disk once an operating system is installed.</div>
    </div>
    
6. To access your Ubuntu Server installed via VirtualBox with `vagrant ssh`, you need to ensure that the VM is configured to allow SSH access. Power on the server through VirtualBox again and install SSH to be able to interact with the Ubuntu Server directly via the terminal:
    
    ```bash
    sudo apt install openssh-server 
    sudo systemctl enable ssh #to start the service at boot
    sudo systemctl start ssh
    sudo systemctl status ssh
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729555894819/a5bfcb43-6061-49b2-b994-a9cb5b26814c.png align="center")
    
7. Now that SSH is running on your Ubuntu Server, we need to update the `Vagrantfile` to handle SSH connections correctly:
    
    ```bash
    Vagrant.configure("2") do |config|
      # Use the existing box or manually installed Ubuntu Server
      config.vm.box = "bento/ubuntu-20.04"
      config.vm.provider "virtualbox" do |vb|
        # Ensure the boot order prioritizes the hard disk
        vb.customize ["modifyvm", :id, "--boot1", "disk", "--boot2", "dvd"]
        # Optionally increase VM resources
        vb.memory = 4096
        vb.cpus = 2
      end
      # SSH Configurations
      #config.vm.network "public_network", bridge: "wlo1: Wi-Fi (Home)"  # Adjust to your network interface
      config.vm.network "forwarded_port", guest: 22, host: 2222, auto_correct: true  # Forward SSH port
      # Use vagrant's default insecure key (no need for password)
      config.ssh.username = "vagrant"  # Ensure this matches the username created during Ubuntu installation
      config.ssh.private_key_path = "~/.vagrant.d/insecure_private_key" # Ensure key matches
    end
    ```
    
8. If Ubuntu Server was installed manually and a `vagrant` user was not created, create one now. Vagrant expects to use a user `vagrant` with passwordless SSH access.
    
    ```bash
    sudo adduser vagrant
    sudo usermod -aG sudo vagrant
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729736127643/3d43ad83-f010-40f3-9188-b8cdc9fd2054.png align="center")
    
9. **Add Vagrant’s Public Key**: The **default Vagrant SSH key** needs to be added to the `vagrant` user’s `authorized_keys`. Copy Vagrant's default insecure public key to the `vagrant` user’s SSH directory to allow passwordless SSH access.
    
    ```bash
    sudo mkdir /home/vagrant/.ssh
    sudo curl -Lo /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub
    sudo chown -R vagrant:vagrant /home/vagrant/.ssh
    sudo chmod 700 /home/vagrant/.ssh
    sudo chmod 600 /home/vagrant/.ssh/authorized_keys
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729823525653/95d5351e-4970-45cf-8146-c97f36b4d56b.png align="center")
    
    * Adding the Vagrant public key ensures Vagrant can authenticate using the default key and configuring `authorized_keys` and permissions resolves any SSH authentication issues.
        
10. Now that the `Vagrantfile` was updated and the `vagrant` user was set up, reload the Vagrant configuration:
    
    ```bash
    vagrant reload
    ```
    
    <div data-node-type="callout">
    <div data-node-type="callout-emoji">💡</div>
    <div data-node-type="callout-text">If you encounter “Warning. Authentication failure. Retrying…“ you can ignore it by pressing Ctrl+C</div>
    </div>
    
11. At this point, the VM should be up and running. On the host machine, run the following:
    
    ```bash
    ssh -i ~/.vagrant.d/insecure_private_key -p 2222 vagrant@localhost
    ```
    
    If you can successfully SSH into the server, it confirms that the SSH configuration is correct. Enter the password of your Ubuntu Server if needed.
    
12. You can also run the following:
    
    ```bash
    vagrant ssh
    ```
    

## References

1. [How to Deploy Ubuntu Server 24.04 LTS: Step-by-Step Installation Overview](https://www.youtube.com/watch?v=pln-tglFxwg)
    
2. [Create An Ubuntu 20.04 Server Using Vagrant](https://dev.to/vumdao/create-an-ubuntu-20-04-server-using-vagrant-3d2i)
    
3. [How to Install, Deploy, and Uninstall Vagrant on Ubuntu 22.04](https://phoenixnap.com/kb/how-to-install-vagrant-on-ubuntu)
