Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
Hachesse
Level 1
Level 1
Posts: 8
Joined: Sun Feb 11, 2018 1:57 pm

Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by Hachesse »

I purchased a new Zenbook 13" OLED (model UX325JA) with i5 proc and Win10 (inxi below), for personal business use. The mindset is to use Linux Mint as main OS with MATE desktop, and Win10 when really impossible to avoid -- eg. I have yet to find a way to activate PowerBI on native Linux. So that will be a dual-boot with Win10.

Code: Select all

System:    Host: <whatever> Kernel: 5.4.0-89-generic x86_64 bits: 64 Desktop: MATE 1.24.0 Distro: Linux Mint 20.2 Uma 
Machine:   Type: Laptop System: ASUSTeK product: ZenBook UX325JA_UX325JA v: 1.0 serial: <superuser/root required> 
           Mobo: ASUSTeK model: UX325JA v: 1.0 serial: <superuser/root required> UEFI: American Megatrends v: UX325JA.309 
           date: 04/26/2021 
Battery:   ID-1: BAT0 charge: 34.0 Wh condition: 67.8/67.1 Wh (101%) 
CPU:       Topology: Quad Core model: Intel Core i5-1035G1 bits: 64 type: MT MCP L2 cache: 6144 KiB 
           Speed: 1300 MHz min/max: 400/3600 MHz Core speeds (MHz): 1: 1300 2: 1300 3: 1300 4: 1261 5: 1300 6: 1300 7: 1300 
           8: 1300 
Graphics:  Device-1: Intel driver: i915 v: kernel 
           Display: x11 server: X.Org 1.20.11 driver: modesetting unloaded: fbdev,vesa resolution: 1920x1080~60Hz 
           OpenGL: renderer: Mesa Intel UHD Graphics (ICL GT1) v: 4.6 Mesa 21.0.3 
Audio:     Device-1: Intel Smart Sound Audio driver: snd_hda_intel 
           Sound Server: ALSA v: k5.4.0-89-generic 
Network:   Device-1: Intel Killer Wi-Fi 6 AX1650i 160MHz Wireless Network Adapter driver: iwlwifi 
           IF: wlo1 state: up mac: <whyareyouasking> 
Drives:    Local Storage: total: 238.47 GiB used: 48.30 GiB (20.3%) 
           ID-1: /dev/nvme0n1 vendor: Western Digital model: PC SN530 SDBPNPZ-256G-1002 size: 238.47 GiB 
Partition: ID-1: / size: 49.72 GiB used: 10.63 GiB (21.4%) fs: ext4 dev: /dev/nvme0n1p6 
           ID-2: /home size: 109.50 GiB used: 3.29 GiB (3.0%) fs: ext4 dev: /dev/nvme0n1p7 
Sensors:   System Temperatures: cpu: 49.0 C mobo: N/A 
           Fan Speeds (RPM): N/A 
Info:      Processes: 259 Uptime: 7h 16m Memory: 7.45 GiB used: 2.39 GiB (32.1%) Shell: bash inxi: 3.0.38 
My level in Linux is non-beginner, yet non-expert either, and I don't have much time to spend on deploying an OS. Hence the choice of Linux Mint, even though it was a bit less easy than expected: hence this record of install tips for other users that may be seduced by this quite adorable laptop in a similar setup adequate for professional usage.

Reaching the UEFI-BIOS to change the booting drive is achieved with F2.
Note: you may achieve this with F12 as well but it takes you through the WIN10 UEFI menus that are quite convoluted.

The step where you need to decide where to install your linux, I chose manual repartitioning. I reduced the main NTFS partition to 80Gb, and created a 50Gb root '/' ext4 and a 120 Gb '/home' ext4 partitions.
The install procedure was typical in that it went very smoothly through the 20.1 disk image install, then the full upgrade to 20.2.

Almost everything works out of the box, except a couple important topics:
- brightness control does not work at all. One alleged reason is that OLED screens don't have backlights, and the driver does not support adjusting that parameter. I have found a good-enough workaround (for single user), detailed below.
- suspend/hibernate results in the laptop hanging when waking up: again I have found a workaround, and it's not perfect.

I. Overcoming the brightness adjustment problem
Searching the web yields a couple results that seem to work (brightnessct, monitor-brightness), more or less adequate but not passing the test of time & failed as soon as de-hibernating. Instead, I'm using little bash scripts that implements a nice-but-a-bit-dangerous feature of xrandr.
The xrandr way of adjusting brightness is the --brightness option, followed by a float number between 0 and 1.
For example, to set brightness at 70% maximum, you'd do: xrandr --output eDP-1 --brightness 0.7
If you're trying this on another laptop model, please note you should make sure you get the output display right by looking at the result of xrandr | grep primary
The first few characters are the name of your primary screen, here eDP-1, by default defined as that attached to the laptop.

So here are the two bash scripts, one to up the brightness in fixed steps, while checking it does not go beyond limit (strange results on OLED):

Code: Select all

#!/bin/bash
# upbright increases screen brightness in fixed steps
B="$(echo $(xrandr --verbose | grep Brightness | grep -o '[[:digit:]]\+.\+'))"
if [ $(echo "$B < 1" | bc) -eq 1 ]
then
	B="$(echo "$B + 0.05" | bc)"
fi
xrandr --output eDP-1 --brightness $B
and one to tone it down while ensuring it does not go to zero (you may want to further reduce the minimum value, 0.05, at your own risk ; 0.01 is very dark even in a dark room):

Code: Select all

#!/bin/bash
# down the brightness in proportional steps
B="$(echo $(xrandr --verbose | grep Brightness | grep -o '[[:digit:]]\+.\+'))"
if [ $(echo "$B > 0.05" | bc) -eq 1 ]
then
	B="$(echo "$B * 0.9" | bc)"
fi
xrandr --output eDP-1 --brightness $B
Save each script in a separate file, with names such as 'upbright' and 'downbright', make them executable (via file manager or chmod +x).
The last step is to link them to a keyboard shortcut, such as 'Ctrl+down' and 'Ctrl+Up' with the dedicated desktop tool (search 'shortcut' in main menu, or launch mate-keybinding-properties). For safety, as I was testing the scripts, I found it useful to have an additional keyboard shortcut with the above xrandr instruction for 70% brightness.

II. The hell of ACPI: sleep and hibernation
Low-power management seems to be very complex and I have no understanding of it at all. It seems to follow a kind of standard named ACPI for Advanced Configuration and Power Interface, which behaves in a very conventional way as far as standards go: not everyone does it the same way.
There are various levels of de-activation of the laptop when it goes low-power, and that's negotiated between the OS and the BIOS. Now with this laptop's BIOS and Linux Mint 20.2, out-of-the-box, they seem to agree on how to go to sleep. The problem happens when they try to get up... it's a big hangover, and you'll have to hard-stop the laptop by pressing the power button for 15s before it does anything.
The workaround I found requires careful manipulation of a system file with a text editor in superuser mode.

Code: Select all

sudo nano /etc/default/grub
This will open the bootloader config file, and you'll search for the following line:

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
And add the following config parameter in the quotes: mem_sleep_default=deep so it looks :

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem_sleep_default=deep"
Now save and exit (Ctrl-o / y / Ctrl-x).
Before the config file is actually activated, you need to perform the following command:

Code: Select all

sudo update-grub
After reboot, you should no longer experience that dreaded freeze after closing the lid or pressing the power button to go low-power.

Now, if you read a bit about the deep state in ACPI, it is supposed to suspend to RAM, and the battery will discharge somewhat in that mode. As this suspend mode keeps the RAM refreshed and does not back it up to disk like hibernation usually means, to be on the safe side save your data ahead of closing the lid. At least you don't get a frozen PC like out-of-the-box suspend.

Hope this'll save some time to other people!
User avatar
SMG
Level 25
Level 25
Posts: 31988
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by SMG »

Hachesse wrote: Thu Nov 04, 2021 4:24 pm I purchased a new Zenbook 13" OLED (model UX325JA) with i5 proc
With a 10th-gen Intel cpu, the first thing which should be done is to upgrade to the 5.11 kernel. That alone may have addressed the brightness issue because that would give you a newer i915 driver. Ice Lake graphics needs to be using a kernel newer than the 5.4 LTS kernel.

Instructions for upgrading to the 5.11 kernel:
  • Open Update Manager.
  • Select View > Linux Kernels and click Continue.
  • Make sure 5.11 is selected on the left panel and then click the top-most option on the right panel. An "Install" button will appear.
  • Install the kernel and then reboot for it to become active.
If someone is using Cinnamon, they can just install the Linux Mint 20.2 "Uma" - Cinnamon (Edge, 64-bit) ISO which has the 5.11 kernel. Those using MATE and Xfce will need to upgrade.
Image
A woman typing on a laptop with LM20.3 Cinnamon.
Hachesse
Level 1
Level 1
Posts: 8
Joined: Sun Feb 11, 2018 1:57 pm

Re: Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by Hachesse »

Thank you for your response and instructions.

Unfortunately, after testing it, I can confirm 5.11 kernel brings no improvement on either glitch.

I'm reverting to 5.4, which has LTS, and works well enough for my needs with the above.
Stability is just as important as functionality to me, on a laptop for professional use. Others may have different priorities.

My next challenge is now to move the existing Win10 install into VirtualBox...
Hachesse
Level 1
Level 1
Posts: 8
Joined: Sun Feb 11, 2018 1:57 pm

Re: Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by Hachesse »

Happy to confirm that kernel 5.13 does fix the light-adjust issue on the zeenbook. Thanks to the developers.
Two caveats:
  • it does accept a zero-backlight setup, which may call for trouble, so the trick above may still be useful to you -- and on top of that, the above code comparatively offers very precise settings in lower lights;
  • it does not work after sleep mode was triggered (looks like the fn key gets locked, so no control possible), just as sound does not work either -- looks like a more general problem with sleep mode
Besides that, the other suspend-related problems don't seem to improve in any way.

PS: I lost patience with the Win10 install after trashing both the W10 install and restoration partitions, due to an apparent glitch while resizing a partition with gparted; so I pragmatically wiped out entirely the W10 partitions, downloaded the OS and reinstalled it from scratch within a Virtual box merely laying in a vdi file on the linux partition, and PowerBI's running like a charm.
Hachesse
Level 1
Level 1
Posts: 8
Joined: Sun Feb 11, 2018 1:57 pm

Re: Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by Hachesse »

An annoying mintmenu glitch appeared after creating a secondary user, where the applications menu would display a cryptic error message rather than displaying the apps icons and names. And no permissions update or so would improve the situation.
More specifically it was complaining about an error in mintmenu.py while executing 'PopulatePlugins' function, due to missing attribute 'width' on some obscure object...
Ultimately, a mere apt mintmenu reinstall with a sudo user + reboot was enough to fix the situation.
Hachesse
Level 1
Level 1
Posts: 8
Joined: Sun Feb 11, 2018 1:57 pm

Re: Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by Hachesse »

Okay, so here's some update about the issue of sound muted after resuming from 'deep' sleep mode.
The 'deep' sleep mode is not working too well overall, as the battery drains quite quickly anyway; so setting up the system to handle hibernation has ultimately proven more successful.

The following pages where very helpful in finding a solution:
https://weiguangcui.github.io/2019-03-1 ... anagement/
https://linuxpip.org/ubuntu-hibernate/

I will echo the steps needed for the specific case of the Zenbook:
1. If not created at installation, with gparted, you need to create a swap partition large enough to handle a copy of your entire RAM.
Note: having a swap file rather than a partition does not seem to be a working option

2. Make sure your swap partition is properly declared in /etc/fstab :
/dev/disk/by-uuid/52bba5ed-66d7-4a0d-b7f1-2e69636df677 /swap swap sw 0 0
52bba5ed-66d7-4a0d-b7f1-2e69636df677 here is the UUID of my swap partition, you need to replace that with yours.
The UUID of your swap partition can be found e.g. from the 'disks' application, or with lsblk -fs command line instruction.

3. Then according to linuxpip page above, you need to have pm-utils installed, which was already the case on my fresh install. So at that stage you should already be able to hibernate, with a sudo systemctl hibernate command. But the system will not yet be able to resume properly and will boot up instead. So the next two steps are really critical :

4. You need to edit /etc/default/grub, updating the GRUB_CMDLINE_LINUX_DEFAULT variable with the UUID of your swap partition to resume from hibernation : it should read
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem_sleep_default=deep resume=UUID=52bba5ed-66d7-4a0d-b7f1-2e69636df677"
Again, replace the string 52bba5ed-66d7-4a0d-b7f1-2e69636df677 with your own swap UUID.
sudo update-grub to enforce the changes.

5. Finally, initramfs needs to be updated as well, don't ask me why :
echo RESUME=UUID=52bba5ed-66d7-4a0d-b7f1-2e69636df677 | sudo tee /etc/initramfs-tools/conf.d/resume
sudo update-initramfs -c -k all


6. At that stage, hibernation should work well with the command line, but it's not yet available on the desktop, because by default it is disabled. In order to re-enable it, the following file needs a change : /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
So let's sudo nano /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla and find the following lines:

Code: Select all

[Disable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=no

[Disable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=no
Just change the ResultActive lines to be 'yes', and comment accordingly the headers:

Code: Select all

[Enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes
After a re-login, a new 'hibernate' button will now appear on the shutdown window.

7. As a very final stage, you can now modify the Energy Manager options to hibernate when closing the lid or pressing the power/sleep buttons.
Last edited by Hachesse on Sat Nov 27, 2021 6:10 pm, edited 1 time in total.
User avatar
SMG
Level 25
Level 25
Posts: 31988
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by SMG »

Hachesse wrote: Sat Nov 27, 2021 1:33 pm Okay, so here's some update about the issue of sound muted after resuming from 'deep' sleep mode.
The 'deep' sleep mode is not working too well overall, as the battery drains quite quickly anyway; so setting up the system to handle hibernation has ultimately proven more successful.

The following pages where very helpful in finding a solution:
https://weiguangcui.github.io/2019-03-1 ... anagement/
https://linuxpip.org/ubuntu-hibernate/th

I will echo the steps needed for the specific case of the Zenbook:
1. If not created at installation, with gparted, you need to create a swap partition large enough to handle a copy of your entire RAM.
Note: having a swap file rather than a partition does not seem to be a working option
What basis do you use for your "Note"? The first link you provided are instructions to save to a swap file.

The second link you provided is redirecting to a page on "The best Termux open-source scripts and projects" when I clicked it which means it is not helpful for this conversation.

We have two tutorials on this forum for hibernating which track similarly to what you have posted. They were originally written for LM19, but they also work for LM20.
How to enable hibernation with swap partition on Linux Mint 19
[GUIDE] How to hibernate to a swap file in Linux Mint 19.x
Image
A woman typing on a laptop with LM20.3 Cinnamon.
Hachesse
Level 1
Level 1
Posts: 8
Joined: Sun Feb 11, 2018 1:57 pm

Re: Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by Hachesse »

Thanks for checking the links, I have now corrected the typo that landed visitors in the wrong place.

Thanks also for pointing out the couple tutorials, they look good and are likely much more generic than what worked here. However I did not land on them with the search engines and queries I used, because they don't talk about the specific problems I was facing with this laptop.

My problem was not hibernation in general, but hibernation happens to be a solution to the particular problem of sound breaking down after suspend on this particular laptop.

This tutorial is specialized, with no ambition whatsoever. As a reader I like to find tutorials that address the problems I face.
User avatar
SMG
Level 25
Level 25
Posts: 31988
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by SMG »

Hachesse wrote: Sat Nov 27, 2021 6:35 pmMy problem was not hibernation in general, but hibernation happens to be a solution to the particular problem of sound breaking down after suspend on this particular laptop.
I will keep that in mind as there might be similarities with other hardware where such a solution might also help.
Image
A woman typing on a laptop with LM20.3 Cinnamon.
Hachesse
Level 1
Level 1
Posts: 8
Joined: Sun Feb 11, 2018 1:57 pm

Re: Tips'n'tricks for install on ASUS Zenbook OLED laptop / dualboot UEFI Win10

Post by Hachesse »

Now I'm at the point where everything works as intended and I can fine tune the look'n'feel.
With regard to window manager & compositing (Control Center -> Appearance -> Desktop parameters -> Windows), the default window manager is Marco; that delivers a rather flat user interface. To get some enhancement it's possible to switch to either Marco+composition or Marco+Compton. Compton reputedly brings graphic acceleration, so that would be my choice, although on this laptop the software composition works well enough and brings some visual enhancement.
If you hoped to play with compiz to impress your buddies, forget it for now, it's way too buggy on this laptop to be usable (or even to report bugs).

If you go for compton, you'll be happy to find the default config file deep in the system : /usr/share/doc/compton/examples/compton.sample.conf
Simply copy it into your home direcory under .compton.conf:
cp /usr/share/doc/compton/examples/compton.sample.conf ~/.compton.conf
and edit & mod to your taste. NB: activating the background blur option is not an option for this laptop; maybe the graphics acceleration doesn't work so well?
Then choosing Marco+Compton in the menu will start Compton and provide eye candy as per the configuration file.
In case you're lazy to find it, feel free to copy paste this slightly modified version of the sample:

Code: Select all

# Shadow
shadow = true;
no-dnd-shadow = true;
no-dock-shadow = true;
clear-shadow = true;
shadow-radius = 4;
shadow-offset-x = -5;
shadow-offset-y = 3;
shadow-opacity = 0.4;
# shadow-red = 0.0;
# shadow-green = 0.0;
# shadow-blue = 0.0;
shadow-exclude = [
	"name = 'Notification'",
	"class_g = 'Conky'",
	"class_g ?= 'Notify-osd'",
	"class_g = 'Cairo-clock'",
	"_GTK_FRAME_EXTENTS@:c"
];
# shadow-exclude = "n:e:Notification";
# shadow-exclude-reg = "x10+0+0";
# xinerama-shadow-crop = true;

# Opacity
menu-opacity = 0.9;
inactive-opacity = 0.9;
# active-opacity = 0.8;
frame-opacity = 1;
inactive-opacity-override = false;
alpha-step = 0.06;
inactive-dim = 0.2;
# inactive-dim-fixed = true;
#blur-background = true;
#blur-background-frame = true;
blur-kern = "3x3box"
# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"
# blur-background-fixed = true;
blur-background-exclude = [
	"window_type = 'dock'",
	"window_type = 'desktop'",
	"_GTK_FRAME_EXTENTS@:c"
];
# opacity-rule = [ "80:class_g = 'URxvt'" ];

# Fading
fading = true;
# fade-delta = 30;
fade-in-step = 0.03;
fade-out-step = 0.03;
# no-fading-openclose = true;
# no-fading-destroyed-argb = true;
fade-exclude = [ ];

# Other
backend = "xrender"
mark-wmwin-focused = true;
mark-ovredir-focused = true;
# use-ewmh-active-win = true;
detect-rounded-corners = true;
detect-client-opacity = true;
refresh-rate = 0;
vsync = "none";
dbe = false;
paint-on-overlay = true;
# sw-opti = true;
# unredir-if-possible = true;
# unredir-if-possible-delay = 5000;
# unredir-if-possible-exclude = [ ];
focus-exclude = [ "class_g = 'Cairo-clock'" ];
detect-transient = true;
detect-client-leader = true;
invert-color-include = [ ];
# resize-damage = 1;

# GLX backend
# glx-no-stencil = true;
glx-copy-from-front = false;
# glx-use-copysubbuffermesa = true;
# glx-no-rebind-pixmap = true;
glx-swap-method = "undefined";
# glx-use-gpushader4 = true;
# xrender-sync = true;
# xrender-sync-fence = true;

# Window type settings
wintypes:
{
  tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; };
};
# Hi SMG here's an easter egg for you :)
Post Reply

Return to “Tutorials”