Score:0

Install Ubuntu 20.04 desktop with separate LVM partitions on UEFI BIOS hardware

fr flag

I want to install Ubuntu 20.04 desktop with LVM on a laptop with UEFI BIOS. My problem is that the default installer allocates the whole disk (bar the UEFI boot partition and a swap partition) to ONE root partition. I prefer to have separate partitions for root, /home, /var, /tmp, etc., and no swap partition.

I have seen other attempts to solve this problem, but they either use RAID or resizes the LVM root partition afterwards, which is fine if you only want to migrate /home to its own partition, but I feel uneasy to do with, e.g., /var. Other attempts, e.g., this one, use the server installer followed by apt install ubuntu-desktop, but I haven't found what server-only packages I should remove afterwards.

Is there another way to install Ubuntu 20.04 desktop and set up separate LVM partitions for root, /home, /var, /tmp, etc.? Or would it be safe to follow the second route and resize the partitions afterwards? If so, how?

Score:0
fr flag

I was able to clean up this RAID+LVM-solution to work for LVM only. The solution involves setting up the partitions manually before running the installer. The detailed instructions are found below.

1. Download the installer and boot into Ubuntu Live

1.1 Download

1.2 Boot Ubuntu Live

  • Boot onto the media from step 1.1.
  • Select Try Ubuntu.
  • Start a terminal by pressing Ctrl-Alt-T. The commands below should be entered in that terminal.

2. Partition drive and set up LVM

2.0 Install ssh server

If you do not want to type all the commands below, you may want to log in via ssh and cut-and-paste the commands.

  • Install

    sudo apt install openssh-server

  • Set a password to enable external login

    passwd

  • If you are testing this inside a virtual machine, you will probably want to forward a suitable port. Select Settings, Network, Advanced, Port forwarding, and the plus sign. Enter, e.g., 3022 as the Host Port and 22 as the Guest Port and press OK. Or from the command line of your host system (replace VMNAME with the name of your virtual machine):

    VBoxManage modifyvm VMNAME --natpf1 "ssh,tcp,,3022,,22"
    VBoxManage showvminfo VMNAME | grep 'Rule'
    

Now, you should be able to log onto your Ubuntu Live session from an outside computer using

ssh <hostname> -l ubuntu

or

ssh localhost -l ubuntu -p 3022

and the password you set above.

2.1 Create partitions on the physical disk

  • Zero the partition tables with

    sudo sgdisk -Z /dev/sda
    
  • Create two partitions; one for EFI and one for LVM.

    sudo sgdisk -n 1:0:+512M -t 1:ef00 -c 1:"EFI System" /dev/sda
    sudo sgdisk -n 2:0:0 -t 2:E6D6D379-F507-44C2-A23C-238F2A3DF928 -c 2:"Linux LVM" /dev/sda
    
  • Create a FAT32 system for the EFI partition.

    sudo mkfs.fat -F 32 /dev/sda1
    

2.3 Create LVM devices

  • Create a physical volume on the LVM partition

    sudo pvcreate /dev/sda2

  • Create a volume group on the physical volume

    sudo vgcreate vg0 /dev/sda2

  • Create logical volumes (partitions) on the new volume group. The sizes and names below are my choices. You may decide differently.

    sudo lvcreate -Z y -L 35GB --name root vg0
    sudo lvcreate -Z y -L 10GB --name tmp vg0
    sudo lvcreate -Z y -L 5GB --name var vg0
    sudo lvcreate -Z y -L 10GB --name varlib vg0
    sudo lvcreate -Z y -L 200GB --name home vg0
    

Now, the partitions are ready for the Ubuntu installer.

3. Run the installer

  • Double-click on the Install Ubuntu 20.04.3 LTS icon on the desktop of the new computer. (Do NOT start the installer via any ssh connection!)
  • Answer the language and keyboard questions.
  • On the Installation type page, select Something else. (This is the important part.) This will present you with a list of partitions called /dev/mapper/vg0-home, etc.
  • Double-click on each partition starting with /dev/mapper/vg0-. Select Use as: Ext4, check the Format the partition box, and choose the appropriate mount point (/ for vg0-root, /home for vg0-home, etc., /var/lib for vg0-varlib).
  • Select the first device /dev/sda for the boot loader.
  • Press Install Now and continue the installation.
  • When the installation is finished, select Continue Testing.

Done!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.