Installing Ubuntu 22 On Dell Xps15 (2022)

[ ]

Ubuntu works pretty well out of the box but there are one or two niggles and, as usual, hibernate hates you. Getting hibernate working was further complicated in this case because I wanted to use full-disk encryption.

Initial setup

Install Ubuntu using a standard desktop ISO, selecting the following non-default options:

Resizing the swap partition

This is required for enabling hibernation. The default swap partition size is far too small and there is no easy way of changing it prior to installation. Begin by rebooting using the bootable ISO used for installation.

Use lsblk or sudo blkid to identify the encrypted partition. The following commands assume it is /dev/nvme0n1p3. Change as required.

cryptsetup open nvme0n1p3 crypt

Enter the passphrase used to unlock the laptop on boot when asked. Use lsblk again to see the names of the unencrypted logical volumes. THe output will look something like:

└─nvme0n1p3           259:3    0 951.7G  0 part  
  └─nvme0n1p3_crypt   253:0    0 951.7G  0 crypt 
    ├─vgubuntu-root   253:1    0 889.4G  0 lvm   /var/snap/firefox/common/host-hunspell
    │                                            /
    └─vgubuntu-swap_1 253:2    0  41.9G  0 lvm   [SWAP]

Reduce the size of the main partition by 40Gb:

lvresize --verbose --resizefs -L -40G /dev/mapper/vgubuntu-root

Note: Various online sources suggest specifying the volumes using the format /dev/vgubuntu/root. I found this made the root partition unbootable.

You can check the integrity of the resized partition with:

e2fsck -f /dev/mapper/vgubuntu-root

Enlarge the swap partition with:

lvresize --verbose -L +40G /dev/mapper/vgubuntu-swap_1

You can now reboot. It may be necessary to re-initialise the swap partition in order to get Ubuntu to use its full size. Run:

swapon --show

If the reported size is not a little over 40Gb, run the following commands, assuming the device reported by the command above is /dev/dm-2:

swapoff -v /dev/dm-2
mkswap /dev/dm-2
sudo swapon /dev/dm-2

The swapon --show command should now show the full size being used.

Install Ubuntu-provided packages

We need ‘curl’ before adding some of the repos.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install curl pcmanfm build-essential git zsh curl tree menulibre pavucontrol pmutils ca-certificates gnupg libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev autoconf bison libyaml-dev libgdbm-dev

Run apt-cache search to find the latest version of the nvidia-driver-XXX package. At the time of writing it was ‘530’:

sudo apt install nvidia-driver-530

Add other repositories

sudo add-apt-repository ppa:linrunner/tlp
wget -qO - https://regolith-desktop.org/regolith.key | gpg --dearmor | sudo tee /usr/share/keyrings/regolith-archive-keyring.gpg > /dev/null
echo deb "[arch=amd64 signed-by=/usr/share/keyrings/regolith-archive-keyring.gpg] \
https://regolith-desktop.org/release-ubuntu-jammy-amd64 jammy main" | sudo tee /etc/apt/sources.list.d/regolith.list
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg

Add the following line to /etc/apt/sources.list:

deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian jammy contrib

Install other packages

sudo apt update

The following are needed when installing natively or in a VM:

sudo apt install regolith-desktop regolith-compositor-picom-glx regolith-look-* i3xrocks-focused-window-name i3xrocks-rofication i3xrocks-info i3xrocks-app-launcher i3xrocks-memory i3xrocks-battery virtualbox-7.0 sublime-text tlp docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 

Install WINE

sudo dpkg --add-architecture i386
wget -nc https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
sudo mv winehq-jammy.sources /etc/apt/sources.list.d/
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key

Install non-repo software

Download the x64 .deb files from here:

VS Code

Google Chrome

Then:

sudo apt install ~/Downloads/*.deb

Make changes requiring logout/login

chsh -s $(which zsh)

Enter your password when asked.

sudo usermod -aG docker [username]

Now logout and login again. At the point where you enter your password, choose ‘Regolith’ instead of the default desktop by clicking on the cog icon in the bottom right hand corner.

Start tlp power management

sudo tlp start
sudo systemctl enable tlp.service

Ensure closing lid triggers suspend

If the laptop does not automatically suspend when the lid is closed, this can be changed in one of two ways:

Edit logind.conf

sudo cp /etc/systemd/logind.conf  /etc/systemd/logind.conf.bak
sudo subl /etc/systemd/logind.conf

Uncomment the following line:

#HandleLidSwitch=suspend

Use Gnome Tweaks

Install with:

sudo apt install gnome-tweaks

Launch ‘Tweaks’ from the application menu and ensure that ‘Suspend when laptop lid is closed’ is set under the ‘General’ tab.

Oh-my-zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Replace the line in .zshrc beginning ZSH_THEME with:

ZSH_THEME="powerlevel10k/powerlevel10k"

Run exec $SHELL to enter the powerlevel10k first-run menu.

Install version managers

Pyenv

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv

Paste the following at the end you your .zshrc file:

export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

Run exec $SHELL.

NVM

Check whether there is a more recent version of NVM.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

The installation command suggests lines to add to .zshrc but check these haven’t been added automatically.

Rbenv

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'eval "$(~/.rbenv/bin/rbenv init - zsh)"' >> ~/.zshrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Install Interpreters

List Node versions and install one:

nvm ls-remote
nvm install XX.YY.Z

Set the default (global) version of Node with:

nvm alias default XX.YY.Z

List Python versions and install one:

pyenv install -l
pyenv install X.YY.ZZ

Set the global python version with:

pyenv global X.YY.ZZ

List rbenv versions and install one:

rbenv install -l
rbenv install X.Y.Z

Set the global version of Ruby with:

rbenv global X.Y.Z

Create ssh key pair

ssh-keygen -t ed25519 -C "email@host.com"

Set a passphrase.

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Add identity to git config

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

Cleanup

sudo apt clean && \
  sudo apt autoclean && \
  sudo apt autoremove

References