Skip to content

Instantly share code, notes, and snippets.

@bogaotory
Last active February 2, 2024 17:01
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogaotory/1abf430d367f92e1b5964b59da9e7523 to your computer and use it in GitHub Desktop.
Save bogaotory/1abf430d367f92e1b5964b59da9e7523 to your computer and use it in GitHub Desktop.
Install Ubuntu 18.04 on Thinkpad X1 Carbon 6th Generation

Install Ubuntu 18.04 on Thinkpad X1 Carbon 6th Gen/2018

X1C6 Type: 20KG*

Bionic works out of the box on the new 2018 X1 Carbon. The X1C6 is a beautiful laptop, and Bionic is the best Ubuntu yet. Users of all levels of experties/experiences are recommended to try this combination. The purpose of this documentation is to improve the user's experience.

BIOS/UEFI Changes

Following changes are required by the DSDT patch:

  1. Turn off Secure Boot
  2. Enable Thunderbolt BIOS Assist Mode

Install from USB

I chose:

  1. Minimal Install
  2. LVM support
  3. Erase Disc

Issue 1: Slow boot (LVM swap wait)

Boot is slow (about 1 minute) $ systemd-analyze shows 30+ seconds spent in kernel

Solution (ref):

$ sudo sed -e 's/^RESUME=/#RESUME=/g' -i /etc/initramfs-tools/conf.d/resume
$ echo "RESUME=/dev/mapper/ubuntu--vg-swap_1" | sudo tee -a /etc/initramfs-tools/conf.d/resume
$ sudo update-initramfs -u
$ reboot

This solution reduces boot time to about 30 seconds, i.e. still room for improvements.

Issue 2: Battery Drain when suspended / No deep sleep mode

This is a serious issue not only because it "drains" the battery (as it provides the least amount of savings out of the four system sleep states), but also because it wakes from events such as a mouse (often wireless) click and heats up in your laptop bag / sleeve which could damage the hardware.

This issue is discussed on this thread on Lenovo's forum. A similar issue is also reported on the Dell XPS 13 9370 . But the Thinkpad's issue is much more serious because $ cat /sys/power/mem_sleep on the XPS13 would show "[s2idle] deep" whereas the X1 would only show "[s2idle]" meaning on the XPS13 it is a matter of choosing the right mode whereas on the X1 it is a matter of missing support for the right mode.

According to this, the issue comes out of Lenovo's preference to support Windows Modern Standby mode.

Solution (DSDT patch):

The original DSDT patch was given here by Delta Xi, which was then updated here by PombeirP. Both are good references, but the best step-by-step guide to apply this patch is given here by Jeremy Cheng. One issue with Jeremy Cheng's post is that a fix /boot/acpi_override instead of /acpi_override for the initrd line is mentioned at the end of the post, so you would run into troubles if you did not read to the end.

To summarise for future reference, following is an abstract of the actions/commands required to apply this patch:

In BIOS/UEFI: A. Turn off Secure Boot; B. Enable Thunerbolt BIOS Assist Mode

$ sudo apt install acpica-tools cpio
$ sudo su - root
$ mkdir -p /root/sleep
$ cd /root/sleep
$ cat /sys/firmware/acpi/tables/DSDT > dsdt.aml
$ iasl -d dsdt.aml
...
Disassembly completed
...

Download and apply PombeirP's patch

$ wget https://gist.githubusercontent.com/PombeirP/67a3e2b479b6a8a71b26f4b6ad624e1c/raw/c4bc3cce254f18b911e408b8bbee3429c64caed1/X1C6_S3_DSDT.patch
$ patch --verbose < X1C6_S3_DSDT.patch
...
Hunk #9 succeeded at 27513.
Hunk #10 succeeded at 34763.
done

If there is an error with Hunk #10, add an extra blank line at the end of X1C6_S3_DSDT.patch. Double check that line 21 of the patched dsdt.dsl file has 0x00000001 instead of 0x00000000. This is the first Hunk of the patch.

Next:

$ iasl -ve -tc dsdt.dsl
...
Compilation complete. ...

Any error with compilationi may be the result of an incorrect patch application.

Carry on:

$ mkdir -p kernel/firmware/acpi
$ cp dsdt.aml kernel/firmware/acpi/
$ find kernel | cpio -H newc --create > acpi_override
$ cp acpi_override /boot/

$ gedit /etc/grub.d/10_linux

Find initrd ${rel_dirname}/${initrd} and replace it with initrd /boot/acpi_override ${rel_dirname}/${initrd}, save and close file.

$ gedit /etc/default/grub

Find the definition of GRUB_CMDLINE_LINUX_DEFAULT and change its definition as GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem_sleep_default=deep acpi.ec_no_wakeup=1", save and close file.

Finally:

$ update-grub
$ reboot

After reboot, check:

  1. dmesg | grep ACPI | grep supports should now include S3 support;
  2. [deep] selected in cat /sys/power/mem_sleep
  3. Close the lid to put the laptop to suspend state, and open the lid. sudo journalctl | grep "PM: suspend" | tail -2 should now say ... suspend entry (deep) ...

Firmware Update via fwupd

While reading about the deep sleep issue on Lenovo's forum, I noticed a firmware update was available via the Linux Vendor Firmware Service which updates the X1C6's firmware to version 1.27 which includes security updates. The following commands executes this update via fwupd:

$ fwupdmgr get-devices
$ fwupdmgr get-updates
$ fwupdmgr update

A reboot is required at the end, and the update process took a while to complete (keep calm and carry on staring at that blank screen).

Additional Tweaks

###Minimise windows by clicking its icon

$ gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'

ref

###Add Empty Document option to right click

$ touch ~/Templates/Empty\ Document

ref

$ sudo apt install gnome-tweak-tool
$ sudo apt install faenza-icon-theme

Gnome Extensions

https://extensions.gnome.org/extension/7/removable-drive-menu/

https://extensions.gnome.org/extension/15/alternatetab/

https://extensions.gnome.org/extension/826/suspend-button/

@xiaoping378
Copy link

maybe issue 2 is needless... ref

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment