Skip to content

Instantly share code, notes, and snippets.

@Brainiarc7
Last active December 31, 2021 02:57
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Brainiarc7/c3fa09bc2ecb4153434cd98b6fb06238 to your computer and use it in GitHub Desktop.
Save Brainiarc7/c3fa09bc2ecb4153434cd98b6fb06238 to your computer and use it in GitHub Desktop.
Installing Ubuntu 18.04LTS on the Asus GM501GS-XS74 notebook

Installing Linux on the Asus GM501GS-XS74:

For starters,

If you are dual booting, install Windows first, and partition from there with a tool such as Minitool. You'll only need two partitions, one for root and optionally, a small one for swap (say, 8GB). Partition them as appropriate, and when done, reboot into the UEFI menu and ensure that:

(a). Secure boot is disabled (otherwise you won't be able to load up proprietary drivers needed for the Nvidia GPU).

(b). Confirm that you're booting in UEFI mode ONLY. This is the default. CSM should remain disabled. Here's why.

(c). Ensure that SATA mode in the BIOS is set strictly to AHCI. RAID mode will NOT work with Linux.

The standard Ubuntu 18.04LTS ISOs will not work, for two reasons:

  1. The desktop edition acts up badly with both the touchpad and external mice, so even if you get to load the live environment (after blacklisting the nouveau driver via the pre-boot grub option blacklist=nouveau), you won't be able to proceed with the next steps such as guided partitioning, etc.

  2. The Ubuntu server image offered on the main download page disallows the use of existing partitions on your SSDs, which could be detrimental if you're dual booting. And this is where the alternate ISO comes in. Fetch it from here: http://cdimage.ubuntu.com/releases/18.04/release/

Then, create a bootable flash drive using etcher.io . If you can get Rufus to work with your flash drives (I had no such luck), you can use that too. When done, leave the USB drive plugged in and reboot to your UEFI (firmware settings). The shortcut is F2. Therein, go to the exit menu, boot override, and select your flash drive's partition with Linux on it. It will be listed as "drive-name/partition-number".

At this point, you'll also want to ensure that you have a plugged in Ethernet cable at the ready. The installer will be able to configure it as appropriate (select DHCP, its' the fastest option when you get to that point).

Start the Ubuntu server installer as you would, and take note of the custom partitioning settings:

(a). For the partition designated for root, set its' file-system as ext4, mount point /. Simple.

(b). The swap partition will be automatically recognized, if you so chose to have one.

(c). The ESP, where the UEFI-based installation boots from, will also be automatically detected and mounted as needed. This is that 100MB~ partition that the Windows installer creates and is marked as 'SYSTEM RESERVED'. Read more about it here.

The rest should be pretty straight-forward, even if you're new to Linux. The guided installer is driven primarily by keyboard input, needs no mice and you won't run into any modesetting issues. Use this as a refresher.

When done, reboot. You'll notice that grub will be the default boot manager. Go back to Linux so we can finish setting up the desktop.

When done booting, log in (with the username and password you set up earlier) and install the latest updates first. Remember that ethernet cable you had to plug in? That interface was configured by the installer, and its' configuration remains persistent , thanks to a new abstraction layer in 18.04LTS named netplan.io.

Now, update your system:

Run:

sudo apt-get -y update && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade

Next, install the Ubuntu desktop via tasksel:

sudo tasksel install ubuntu-desktop

You can see the list of alternate environments by running:

tasksel --list-task

For example, if you want KDE, you could run:

sudo tasksel install kubuntu-desktop

When you're done with that step, proceed to the next bit: The drivers for your GPUs.

Next, add the NVIDIA proprietary driver repository and Oibaf's PPAs as shown:

sudo add-apt-repository ppa:graphics-drivers/ppa -y && sudo add-apt-repository ppa:oibaf/graphics-drivers

Then update your software sources:

sudo apt-get update

Followed by an upgrade (to deploy the latest FOSS GPU drivers for your Intel card):

sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade

And now, install the latest NVIDIA driver (R415 as of the time of writing):

sudo apt-get -y install nvidia-driver-430

For Conky, install the conky-all package:

sudo apt install conky-all

Then add the scheduling module to /etc/modules-load.d/modules.conf:

nano /etc/modules-load.d/modules.conf

Content:

mq-deadline

When done, make the following changes to your grub configuration file, ensuring that the line below looks exactly as shown (under /etc/default/grub, use your preferred editor):

GRUB_CMDLINE_LINUX_DEFAULT="acpi_osi=! acpi_osi='Windows 2012' blacklist=nouveau scsi_mod.use_blk_mq=1 elevator=mq-deadline quiet splash i8042.reset"

The important options there are as follows:

  1. The acpi_osi setting ensures that you won't hang on reboot, or get stuck with lspci. It compensates for how Linux handles ACPI table parsing on these newer models.

  2. Blacklist nouveau here because that module, if loaded, will lock up your system.

  3. The scsi_mod.use_blk_mq=1 elevator=mq-deadline option enables the block multi-queue mode with the deadline scheduler in place for all block devices on the system. Ideal for SSDs.

  4. The i8042.reset option will allow the touchpad to be detected.

Now, generate new grub configs by running:

sudo update-grub

And reboot at this stage.

When you boot up, you'll be greeted by the fruits of your labor as shown below: A clean, minimalist Ubuntu desktop that you can tweak to your heart's content.

So far, no show stoppers encountered so far.

Here's the boot log with the ACPI _OSI override above enabled:

[    0.314578] ACPI: Core revision 20180810
[    0.781723] PM: Registering ACPI NVS region [mem 0x6a42c000-0x6a541fff] (1138688 bytes)
[    0.784222] ACPI: bus type PCI registered
[    0.784222] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
[    0.785058] ACPI: Disabled all _OSI OS vendors
[    0.785058] ACPI: Added _OSI(Module Device)
[    0.785058] ACPI: Added _OSI(Processor Device)
[    0.785058] ACPI: Added _OSI(3.0 _SCP Extensions)
[    0.785058] ACPI: Added _OSI(Processor Aggregator Device)
[    0.785058] ACPI: Added _OSI(Linux-Dell-Video)
[    0.785058] ACPI: Added _OSI(Linux-Lenovo-NV-HDMI-Audio)
[    0.785058] ACPI: Added _OSI(Windows 2017.2)
[    0.785058] ACPI: EC: EC started
[    0.785058] ACPI: EC: interrupt blocked
[    0.785058] ACPI: \: Used as first EC
[    0.785058] ACPI: \: GPE=0x27, EC_CMD/EC_SC=0x66, EC_DATA=0x62
[    0.785058] ACPI: \: Used as boot ECDT EC to handle transactions
[    0.861884] ACPI: 11 ACPI AML tables successfully acquired and loaded
[    0.892135] ACPI: Dynamic OEM Table Load:
[    0.892142] ACPI: SSDT 0xFFFF8CB229AF0000 0005BE (v02 PmRef  Cpu0Ist  00003000 INTL 20160527)
[    0.892914] ACPI: \_SB_.PR00: _OSC native thermal LVT Acked
[    0.895370] ACPI: Dynamic OEM Table Load:
[    0.895376] ACPI: SSDT 0xFFFF8CB2290C1400 000400 (v02 PmRef  Cpu0Cst  00003001 INTL 20160527)
[    0.896663] ACPI: Dynamic OEM Table Load:
[    0.896672] ACPI: SSDT 0xFFFF8CB229197000 000EF1 (v02 PmRef  ApIst    00003000 INTL 20160527)
[    0.898522] ACPI: Dynamic OEM Table Load:
[    0.898528] ACPI: SSDT 0xFFFF8CB2290C4800 00030A (v02 PmRef  ApCst    00003000 INTL 20160527)
[    0.901261] ACPI: Interpreter enabled
[    0.901313] ACPI: (supports S0 S3 S4 S5)
[    0.901314] ACPI: Using IOAPIC for interrupt routing
[    0.901366] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    0.903309] ACPI: Enabled 9 GPEs in block 00 to 7F
[    0.911265] ACPI: Power Resource [PG00] (on)
[    0.921746] ACPI: Power Resource [USBC] (on)
[    0.926563] ACPI: Power Resource [V0PR] (on)
[    0.926846] ACPI: Power Resource [V1PR] (on)
[    0.927121] ACPI: Power Resource [V2PR] (on)
[    0.933970] ACPI: Power Resource [WRST] (on)
[    0.943034] ACPI: Power Resource [PIN] (off)
[    0.943683] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-fe])
[    0.978417] ACPI: PCI Interrupt Link [LNKA] (IRQs) *0
[    0.978469] ACPI: PCI Interrupt Link [LNKB] (IRQs) *1
[    0.978519] ACPI: PCI Interrupt Link [LNKC] (IRQs) *0
[    0.978568] ACPI: PCI Interrupt Link [LNKD] (IRQs) *0
[    0.978617] ACPI: PCI Interrupt Link [LNKE] (IRQs) *0
[    0.978666] ACPI: PCI Interrupt Link [LNKF] (IRQs) *0
[    0.978715] ACPI: PCI Interrupt Link [LNKG] (IRQs) *0
[    0.978763] ACPI: PCI Interrupt Link [LNKH] (IRQs) *0
[    0.983313] ACPI: EC: interrupt unblocked
[    0.983313] ACPI: EC: event unblocked
[    0.983313] ACPI: \_SB_.PCI0.LPCB.EC0_: GPE=0x27, EC_CMD/EC_SC=0x66, EC_DATA=0x62
[    0.983313] ACPI: \_SB_.PCI0.LPCB.EC0_: Used as boot DSDT EC to handle transactions and events
[    0.983505] ACPI: bus type USB registered
[    1.003596] PCI: Using ACPI for IRQ routing
[    1.091155] pnp: PnP ACPI init
[    1.091453] system 00:00: Plug and Play ACPI device, IDs PNP0c02 (active)
[    1.091477] pnp 00:01: Plug and Play ACPI device, IDs PNP0b00 (active)
[    1.091615] system 00:02: Plug and Play ACPI device, IDs INT3f0d PNP0c02 (active)
[    1.091839] pnp 00:03: Plug and Play ACPI device, IDs ATK3001 PNP030b (active)
[    1.092119] system 00:04: Plug and Play ACPI device, IDs PNP0c02 (active)
[    1.092456] system 00:05: Plug and Play ACPI device, IDs PNP0c02 (active)
[    1.092898] system 00:06: Plug and Play ACPI device, IDs PNP0c02 (active)
[    1.094501] system 00:07: Plug and Play ACPI device, IDs PNP0c02 (active)
[    1.095812] pnp: PnP ACPI: found 8 devices
[    2.131521] ACPI: AC Adapter [AC0] (on-line)
[    2.131607] ACPI: Lid Switch [LID]
[    2.131670] ACPI: Sleep Button [SLPB]
[    2.131702] ACPI: Power Button [PWRB]
[    2.131742] ACPI: Power Button [PWRF]
[    2.133359] ACPI: Thermal Zone [THRM] (52 C)
[    2.143621] battery: ACPI: Battery Slot [BAT0] (battery present)
[    3.117448] [drm:intel_opregion_setup [i915]] Public ACPI methods supported
[    3.119365] [drm:intel_opregion_setup [i915]] Found valid VBT in ACPI OpRegion (Mailbox #4)
[    3.157152] ACPI: Video Device [GFX0] (multi-head: yes  rom: no  post: no)
[    3.157531] ACPI: Video Device [PEGP] (multi-head: no  rom: yes  post: no)
[    3.361558] ata1.00: ACPI cmd ef/10:06:00:00:00:00 (SET FEATURES) succeeded
[    3.361560] ata1.00: ACPI cmd f5/00:00:00:00:00:00 (SECURITY FREEZE LOCK) filtered out
[    3.361561] ata1.00: ACPI cmd b1/c1:00:00:00:00:00 (DEVICE CONFIGURATION OVERLAY) filtered out
[    3.367131] ata1.00: ACPI cmd ef/10:06:00:00:00:00 (SET FEATURES) succeeded
[    3.367133] ata1.00: ACPI cmd f5/00:00:00:00:00:00 (SECURITY FREEZE LOCK) filtered out
[    3.367134] ata1.00: ACPI cmd b1/c1:00:00:00:00:00 (DEVICE CONFIGURATION OVERLAY) filtered out
[    7.707528] ACPI Warning: \_SB.IETM._TRT: Return Package has no elements (empty) (20180810/nsprepkg-96)
[    7.744101] ACPI Warning: \_SB.PCI0.PEG0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20180810/nsarguments-66)

Continue on to system monitoring with conky below.

System monitoring:

See the conky script below. Note that you'll need to set hddtemp in daemon mode if you want HDD temps in the app:

Notes:

On my system, I recently upgraded to the Samsung 860 Evo 4 TB SSD from a 2 TB Crucial MX500. The temperature sensor on this drive isn't known to hddtemp, so we must add its' entry.

First, check the drive's SMART data output for temperature sensor data and look for the field "ID#":

sudo smartctl /dev/sda -a | grep -i Temp

190 Airflow_Temperature_Cel 0x0032   069   054   000    Old_age   Always       -       31

Now add this to hddtemp's database file, /etc/hddtemp.db, such that the bottom of the file looks like this:

tail -n 3 /etc/hddtemp.db

#Samsung 860 Evo 4TB:
"Samsung SSD 860 EVO 4TB"					 190 C "Label for SSD 4TB"

One liner:

sudo su
echo '"Samsung SSD 860 EVO 4TB"					 190 C "Label for SSD 4TB"' >> /etc/hddtemp.db

The very first field is the sensors attribute id#, "190" in this case.

For hard drive temperature, ensure that hddtemp is running as a daemon. You can do that by editing /etc/default/hddtemp and ensuring that RUN_DAEMON is set to TRUE. When done, restart the hddtemp unit service by:

sudo systemctl restart hddtemp.service

On autostart: https://wiki.archlinux.org/index.php/conky#Autostart

Undervolting the Asus GM501GS-XS74 on Linux:

Introduction:

Unlike Clevo-based designs such as the legendary Eurocom Q6, the Asus laptop's BIOS is quite limited in features, and does not expose any undervolting controls. For that reason, we will have to undervolt with intel-undervolt as it allows for different offsets to be applied for the core, uncore, GT slice and GT unslice in the same way Throttlestop does.

Note: This is completely optional, and can be safely skipped.

Before we begin:

Note the safe undervolt thresholds for the Asus GM501GS-XS74:

Core -125mV
Cache (and the rest) -50mV

Do not undervolt the cache lower than that threshold (50mV) or you'll crash irrecoverably due to MCE errors. See the tool's limitations below.

Usage:

Installing

git clone https://github.com/kitsunyan/intel-undervolt
cd intel-undervolt
make 
sudo make install

Getting started:

Read current offsets:

$ intel-undervolt --read

Sample output:

temperature target: -0 (100C)
core: 0.0 mV
gpu: -19.53 mV
cache: -30.27 mV
uncore: -29.3 mV
analogio: -70.31 mV

Setting the undervolt offsets:

Set these in /etc/intel-undervolt.conf.

For the Asus GM501GS, this should do for the offsets block:

undervolt 0 'CPU' -125
undervolt 1 'GPU' -50
undervolt 2 'CPU Cache' -50
undervolt 3 'System Agent' -50
undervolt 4 'Analog I/O' -50

For the EPP hints, this one line should do:

# Energy Versus Performance Preference Switch
# Usage: hwphint ${mode} ${algorithm} ${load_hint} ${normal_hint}
# Hints: see energy_performance_available_preferences
# Modes: switch, force
# Load algorithm: load:${capture}:${threshold}
# Power algorithm: power[:${domain}:[gt/lt]:${value}[:[and/or]]...]
# Capture: single, multi
# Threshold: CPU usage threshold
# Domain: RAPL power domain, check with `intel-undervolt measure`
# Example: hwphint force load:single:0.8 performance balance_performance
# Example: 
hwphint switch power:core:gt:8:and:uncore:lt:3 performance balance_performance

When done, you can apply the new offsets by:

sudo intel-undervolt apply

Which you can now confirm via:

sudo intel-undervolt read

Then make that file read only:

sudo chattr +i /etc/intel-undervolt.conf

Running automatically on boot:

Enable the following services via systemd as shown below:

sudo systemctl enable intel-undervolt.service 
sudo systemctl enable intel-undervolt-loop.service

Troubleshooting

1. Have my offsets appplied correctly?

To confirm, simply run:

sudo intel-undervolt read

And your output should resemble something similar:

CPU (0): -125.00 mV
GPU (1): -49.80 mV
CPU Cache (2): -49.80 mV
System Agent (3): -49.80 mV
Analog I/O (4): -49.80 mV

2. Why must I run the tool as root?

That's because the tool explicitly relies on the MSR kernel module, and it needs to write to model specific registers for the undervolt(ing) to take effect. Also note that secure boot will prevent the tool from running, so disable that option in the BIOS.

This is my Conky configuration:

alignment top_right
background = true 
border_width 1
color1 07CC0D
color2 D1E7D1
color3 FF0000
color4 FFFFFF
cpu_avg_samples 2
default_color D1E7D1
default_outline_color white
default_shade_color white
double_buffer yes
draw_borders no
draw_graph_borders yes
draw_outline no
draw_shades no
border_outer_margin 10
max_port_monitor_connections 64
maximum_width 500
minimum_width 500
max_user_text 16384
minimum_size 330 10
net_avg_samples 2
no_buffers yes
out_to_console no
stippled_borders 2
#settings to define how to draw the window. compiz needs these settings, adjust for your WM
own_window true
own_window_class Conky
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_transparent yes
own_window_argb_visual yes
own_window_argb_value 50
update_interval 2
uppercase no
use_xft yes
xftalpha 0.8
xftfont  Bitstream Vera Sans Mono:size=9

# WIDTH = 500pixel, ${goto 270} for 2 column designs
# SMALL BAR HEIGHT: 12, LARGE GRAPH HEIGHT: 240

TEXT
${color1}$nodename ${alignr}$kernel
${color1}Uptime:${color} $uptime ${color1} ${alignr}Load:${color} $loadavg
$hr
${alignr}${color1}RAM: $memperc% = $mem / $memmax
${color #88cc00}${cpugraph 60,240 07CC0D FF0000 -t} ${goto 270}${color #88cc00}${memgraph 60,250 07CC0D FF0000 -t}
${execi 1000 cat /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //'| uniq | cut -c 1-26}
${font sans-serif:bold:size=8}PROCESSOR UTILIZATION & FREQUENCY ${hr 2}${font}
CPU1: ${cpu cpu1}% $alignr ${exec awk '/cpu MHz/{i++}i==1{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu1 8,60}
CPU2: ${cpu cpu2}% $alignr ${exec awk '/cpu MHz/{i++}i==2{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu2 8,60}
CPU3: ${cpu cpu3}% $alignr ${exec awk '/cpu MHz/{i++}i==3{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu3 8,60}
CPU4: ${cpu cpu4}% $alignr ${exec awk '/cpu MHz/{i++}i==4{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu4 8,60}
CPU5: ${cpu cpu5}% $alignr ${exec awk '/cpu MHz/{i++}i==5{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu5 8,60}
CPU6: ${cpu cpu6}% $alignr ${exec awk '/cpu MHz/{i++}i==6{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu6 8,60}
CPU7: ${cpu cpu7}% $alignr ${exec awk '/cpu MHz/{i++}i==7{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu7 8,60}
CPU8: ${cpu cpu8}% $alignr ${exec awk '/cpu MHz/{i++}i==8{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu8 8,60}
CPU9: ${cpu cpu1}% $alignr ${exec awk '/cpu MHz/{i++}i==1{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu9 8,60}
CPU10: ${cpu cpu2}% $alignr ${exec awk '/cpu MHz/{i++}i==2{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu10 8,60}
CPU11: ${cpu cpu3}% $alignr ${exec awk '/cpu MHz/{i++}i==3{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu11 8,60}
CPU12: ${cpu cpu4}% $alignr ${exec awk '/cpu MHz/{i++}i==4{printf "%.f",$4; exit}' /proc/cpuinfo} MHz $alignr ${cpubar cpu12 8,60}



${color #88cc00}Swap Usage: $swapperc% = $swap/$swapmax ${color #88cc00} ${swapbar 4 color1 color3}
$hr
${color1}Net Down:${color} ${downspeed wlo1} ${goto 270}${color1}Net Up:${color} ${upspeed wlo1}
${color1}${downspeedgraph wlo1 60,240 07CC0D FF0000 -t}${color1} ${goto 270}${upspeedgraph wlo1 60,250 07CC0D FF0000 -t}
$hr
${color1}Temperatures in Celsius:
${color1}HDDs	${color} ${hddtemp /dev/sda}       
${color1}CPUs	${color} ${hwmon 1 temp 1}    ${hwmon 1 temp 2}

#GPU Attributes:
${if_match ${exec lsmod | grep 'nvidia' -c} > 0}\
${color1}GPU:${color #FCAF3E}${nvidia modelname} $color
${color1}GPU Temperature ${color}  ${nvidia temp} °C
${color1}GPU Utilization ${color}  ${nvidia gpuutil} %
${color1}GPU Core Frequency ${color}  ${nvidia gpufreq} MHz
${color1}GPU Memory Frequency ${color}  ${nvidia memfreq} MHz
${color1}VRAM Utilization ${color} ${nvidia memused} MB
${color1}GPU Power Draw ${color} ${exec nvidia-smi | grep % | cut -c 21-23} W
${color1}PCIe Utilization ${color} ${nvidia pcieutil} %
${color1}NVENC Utilization ${color} ${nvidia videoutil} %
${else}\
${color1}Prime status: Intel
${endif}\


${color1}Top Processes:
${color1}Name              PID    CPU%   MEM%  TIME     USER
${color}${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1} ${top time 1} ${top user 1}
${color}${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2} ${top time 2} ${top user 2}
${color}${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3} ${top time 3} ${top user 3}
${color}${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4} ${top time 4} ${top user 4}
${color}${top name 5} ${top pid 5} ${top cpu 5} ${top mem 5} ${top time 5} ${top user 5}

$hr
#${color Tan2}ESTABLISHED Connections${color DarkSlateGray}${hr 2}
#
#${offset 10}${color lightgrey}Inbound: ${color white}${tcp_portmon 1 32767 count} ${color lightgrey}Outbound: ${color white}${tcp_portmon 32768 61000 count}${alignr}${color lightgrey}Total: ${color white}${tcp_portmon 1 65535 count}
#
#${color slate grey}Process ${color slate grey}Remote Host ${color slate grey}L-Port ${alignr}${color slate grey}R-Port${color lightgrey}
#
#${texeci 3 netstat -ap | grep 'ESTABLISHED' | sed -r 's|.*[0-9.]+:([0-9]*)\s*([^:]+):([a-zA-Z]+)[^/]+/([a-zA-Z0-9]*)|\4 \2 \1 \3|' | awk '{printf("%-14s %-20s %5s %7s\n",$1,$2,$3,$4)}'}
#old way for network
${color1} Port(s) ${alignr} #Connections
${color}  Inbound: ${tcp_portmon 1 32767 count}  Outbound: ${tcp_portmon 32768 61000 count} ${alignr} ALL: ${tcp_portmon 1 65535 count}
${color1} Inbound Connection ${alignr} Local Service/Port ${color}
${tcp_portmon 1 32767 rhost 0} ${alignr} ${tcp_portmon 1 32767 lservice 0}
${tcp_portmon 1 32767 rhost 1} ${alignr} ${tcp_portmon 1 32767 lservice 1}
${tcp_portmon 1 32767 rhost 2} ${alignr} ${tcp_portmon 1 32767 lservice 2}
${tcp_portmon 1 32767 rhost 3} ${alignr} ${tcp_portmon 1 32767 lservice 3}
${tcp_portmon 1 32767 rhost 4} ${alignr} ${tcp_portmon 1 32767 lservice 4}
${color1}Outbound Connection ${alignr} Remote Service/Port${color}
${tcp_portmon 32768 61000 rhost 0} ${alignr} ${tcp_portmon 32768 61000 rservice 0}
${tcp_portmon 32768 61000 rhost 1} ${alignr} ${tcp_portmon 32768 61000 rservice 1}
${tcp_portmon 32768 61000 rhost 2} ${alignr} ${tcp_portmon 32768 61000 rservice 2}
${tcp_portmon 32768 61000 rhost 3} ${alignr} ${tcp_portmon 32768 61000 rservice 3}
${tcp_portmon 32768 61000 rhost 4} ${alignr} ${tcp_portmon 32768 61000 rservice 4}

See notes on enabling autostart above.

How to fix glitches, skips or crackling under high processor load:

The newer implementation of the PulseAudio sound server uses timer-based audio scheduling instead of the traditional, interrupt-driven approach.

Timer-based scheduling may expose issues in some ALSA drivers. On the other hand, other drivers might be glitchy without it on, so check to see what works on your system.

To turn timer-based scheduling off, add tsched=0 in /etc/pulse/default.pa:

/etc/pulse/default.pa
load-module module-udev-detect tsched=0

Then restart the PulseAudio server:

$ pulseaudio -k
$ pulseaudio --start

Do the reverse to enable timer-based scheduling, if not already enabled by default.

If you are using Intel's IOMMU and experience glitches and/or skips, add intel_iommu=igfx_off to your kernel command line.

How to fix Microphone crackling:

If you observe microphone crackling while recording, Some Pulseaudio config changes may help:

/etc/pulse/daemon.conf
resample-method = src-sinc-best-quality
default-sample-format = s16le
default-sample-rate = 48000

and add the use_ucm option to:

/etc/pulse/default.pa
load-module module-udev-detect use_ucm=0 tsched=0

then restart pulseaudio.

Taken from the glorious Arch Wiki.

You can switch your system to NetworkManager control with the following instructions.

Netplan is configured in a "yaml" file in /etc/netplan/. The configuration file may have different names on different systems. On my install the file name is 01-netcfg.yaml.

Lets make a backup copy of that yaml file and edit the existing one to use NetworkManager.

cd /etc/netplan
sudo cp 01-netcfg.yaml 01-netcfg.yaml-backup

Now edit 01-netcfg.yaml using your editor of choice (and use sudo). Change the file so it looks like,

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: NetworkManager

Then run the following to make the new setup:

sudo netplan generate
sudo netplan apply

Lastly restart the NetworkManager service:

sudo systemctl restart NetworkManager.service

You are now using NetworkManager.

You'll also need these additional steps:

  1. Install dnsmasq
  2. Configure it (listen address and DNS servers).

Now, install the package:

sudo apt -y install dnsmasq

Populate the dnsmasq.conf configuration file:

sudo su
tee -a /etc/dnsmasq.conf << ENDdm
interface=lo
bind-interfaces
listen-address=127.0.0.1
# DNS server from Cloudflare and Google. Use yours...
server=1.0.0.1
server=8.8.8.8
ENDdm

Start the service and enable it at boot:

systemctl restart dnsmasq
systemctl enable dnsmasq

And now you're all set up.

PS: Confirm that NetworkManager's config file is sane, under /etc/NetworkManager/NetworkManager.conf.

[main]
plugins=ifupdown,keyfile

[keyfile]
unmanaged-devices=*,except:type:wifi,except:type:wwan,except:type:ethernet

[ifupdown]
managed=true

Then restart the system.

Getting NVIDIA HDMI Audio to work in NVIDIA prime-select mode

This is mostly applicable when using the laptop in switchable graphics mode, which can only be toggled on from within Windows.

By default, even with the NVIDIA GPU left enabled by default (as recommended here), HDMI audio will be unavailable due to a known bug.

The audio chip on the nvidia GPU is disabled at boot, most likely due to an ACPI table parsing bug as described below.

This isn't a problem on Windows as the proprietary driver handles the initialization of the GPU's audio controller upon handshaking with an audio-ready HDMI device. This, however, is not the case on Linux.

See:

  1. https://devtalk.nvidia.com/default/topic/1024022/linux/gtx-1060-no-audio-over-hdmi-only-hda-intel-detected-azalia/?offset=4

  2. https://bugs.freedesktop.org/show_bug.cgi?id=75985

There's a fix available for this, which you can install, as shown below:

git clone https://github.com/hhfeuer/nvhda
cd nvhda
sudo make -f Makefile.dkms

When done, regenerate initramfs and update the grub menu, followed by a reboot:

sudo update-initramfs -u
sudo update-grub

Then reboot to test your changes.

Module usage:

Load Module:

sudo modprobe nvhda

Get status:

cat /proc/acpi/nvhda

Turn audio on/off:

sudo tee /proc/acpi/nvhda <<<ON sudo tee /proc/acpi/nvhda <<<OFF

Check dmesg for messages.

Credit: https://github.com/hhfeuer/nvhda

Now, you can select the HDMI audio device profile via pavucontrol.

The Intel wireless driver (iwlwifi) can be tuned even further.

Edit /etc/modprobe.d/iwlwifi.conf and add the following:

# /etc/modprobe.d/iwlwifi.conf
# iwlwifi will dyamically load either iwldvm or iwlmvm depending on the
# microcode file installed on the system.  When removing iwlwifi, first
# remove the iwl?vm module and then iwlwifi.
#remove iwlwifi \
(/sbin/lsmod | grep -o -e ^iwlmvm -e ^iwldvm -e ^iwlwifi | xargs /sbin/rmmod) \
&& /sbin/modprobe -r mac80211


#Fuck Ubuntu's default. We finna roll this shit :-) 

options iwlwifi 11n_disable=8

That should fix the performance issues observed with Wireless N access points on the Netgear R7000.

Original documentation from the Intel wireless entry on the Arch Wiki.

Place this in ~/.config/autostart/conky.desktop :

[Desktop Entry]
Type=Application
Name=conky
Exec=conky --daemonize --pause=5
StartupNotify=false
Terminal=false

How to get the keyboard backlight to work:

To get the keyboard backlight shortcut keys to work, you must blacklist the older asus-nb-wmi module as shown:

Create the file /etc/modprobe.d/blacklist-asus-nb-wmi.conf with the content:

blacklist asus-nb-wmi

Ensure that the correct module hid-asus is loaded automatically by creating the file /etc/modules-load.d/hid-asus.conf with the content:

# Load the Asus module at boot
hid-asus
hid-multitouch
asus-wmi

Then reboot.

On this laptop, use the hid-asus module which enables support for suspend, airplane mode, keyboard lights, screen lights, screen keys and volume controls. The hid-multitouch module will allow your touchpad to work as designed. Blacklisting the module above ensures that the latter only gets loaded, resolving the conflict.

Making a hardware probe of the Asus GM501GS-XS74:

On Ubuntu, install the hw-probe tool:

sudo add-apt-repository universe
sudo add-apt-repository ppa:mikhailnov/hw-probe
sudo apt update
sudo apt install hw-probe --no-install-recommends

Then run a probe:

sudo hw-probe -all -upload -id "DESC"

Where "DESC" is the description you want to use to identify your hardware probe.

When done, the process will generate a unique URL pointing to your submission. In my case, that points to: https://linux-hardware.org/?probe=2f1b160149

Backlight controls:

When using the dGPU, you will notice that the backlight slider has no effect.

Here's how you can fix that.

Install xbacklight:

sudo apt install xbacklight

Create the script /usr/local/bin/xbacklightmon.sh with the content:

#!/bin/sh

path=/sys/class/backlight/acpi_video0

luminance() {
    read -r level < "$path"/actual_brightness
    factor=$((100 / max))
    printf '%d\n' "$((level * factor))"
}

read -r max < "$path"/max_brightness

xbacklight -set "$(luminance)"

inotifywait -me modify --format '' "$path"/actual_brightness | while read; do
    xbacklight -set "$(luminance)"
done

And make the script executable:

sudo chmod +x /usr/local/bin/xbacklightmon.sh

Reference: https://wiki.archlinux.org/index.php/backlight#sysfs_modified_but_no_brightness_change

On this machine, it is advisable to disable selective USB autosuspend, as shown:

echo "options usbcore autosuspend=-1" | sudo tee /etc/modprobe.d/disable-usb-autosuspend.conf 

Then reboot.

How to set battery charging thresholds on Linux

On this laptop, there's a Windows tool called ASUS Battery Health Charging software which can be used to set a threshold for maximum charging capacity, which helps with extending the usable lifespan of the Li-Ion battery on the laptop. As from Kernel 5.4+, the same functionality is available, allowing the user to set up similar charging thresholds and make them persistent via udev, if so desired. The Arch Wiki entry for the Asus Zenbook UX534 has an excellent guide on how to enable this in a persistent manner, as quoted below:

Create a new udev rule under /etc/udev/rules.d/99-battery-charge-threshold.rules with the content:

KERNEL=="BAT0", SUBSYSTEM=="power_supply", ATTR{charge_control_end_threshold}="60"

Then reload udev rules:

sudo udevadm control --reload-rules && sudo udevadm trigger

And preferably reboot when done:

sudo systemctl reboot

Credit goes to u/esrevartb on reddit, as posted here.

@Brainiarc7
Copy link
Author

To disable the clickpad nonsense that Ubuntu has seen fit to implement for every one else, follow this: https://itsfoss.com/fix-right-click-touchpad-ubuntu/

@Brainiarc7
Copy link
Author

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