ThinkPad:ArchLinux: Difference between revisions

From Wiki³
mNo edit summary
 
(15 intermediate revisions by the same user not shown)
Line 4: Line 4:
{{SeeAlso|ArchLinux:Installation|Arch Linux Installation}}
{{SeeAlso|ArchLinux:Installation|Arch Linux Installation}}
This is a compilation of information I have scoured off the net in order to get my ThinkPad X220 running in the best possible configuration possible for my needs. If you need assistance installing Arch Linux, refer to the installation tutorial linked above.
This is a compilation of information I have scoured off the net in order to get my ThinkPad X220 running in the best possible configuration possible for my needs. If you need assistance installing Arch Linux, refer to the installation tutorial linked above.
{{Note|I personally use [[aur:pacaur]] to manage all of the packages on my Arch system as it can interface with the regular repositories and the AUR. However, use whatever you are comfortable with.}}
{{Note|I personally use [[aur:pikaur]] to manage all of the packages on my Arch system as it can interface with the regular repositories and the AUR. However, use whatever you are comfortable with.}}


Keep in mind all of this is optional and none of it is by any means required and should be used on a case by case basis.
Keep in mind all of this is optional and none of it is by any means required and should be used on a case by case basis.
Line 14: Line 14:


Next use El Torito to convert the ISO downloaded into a bootable image file and {{mono|dd}} it to a USB disk (or other form of writable bootable media). If [[aur:geteltorito]] is not installed, do so before hand. Also make sure you specify the correct disk node to write the image to, you can use {{mono|lsblk}} to find the device node.
Next use El Torito to convert the ISO downloaded into a bootable image file and {{mono|dd}} it to a USB disk (or other form of writable bootable media). If [[aur:geteltorito]] is not installed, do so before hand. Also make sure you specify the correct disk node to write the image to, you can use {{mono|lsblk}} to find the device node.
{{Console|1=pacaur -S geteltorito|2=geteltorito.pl -o securewipe.img 83fd04ww.iso|3=sudo dd if{{=}}securewipe.img of{{=}}/dev/sdX bs{{=}}10M}}
{{Console|1=pikaur -S geteltorito|2=geteltorito.pl -o securewipe.img 83fd04ww.iso|3=sudo dd if{{=}}securewipe.img of{{=}}/dev/sdX bs{{=}}10M}}
Reboot the machine booting off the prepared media; follow the steps presented.
Reboot the machine booting off the prepared media; follow the steps presented.
{{Warning|Using the disk erase will prompt you with a code to write down and then enter after a reboot. DO NOT skip this part.|margin-bottom=true}}
{{Warning|Using the disk erase will prompt you with a code to write down and then enter after a reboot. DO NOT skip this part.|margin-bottom=true}}
Line 21: Line 21:
=={{Icon|notebook}} Keeping the Boot Log on TTY1==
=={{Icon|notebook}} Keeping the Boot Log on TTY1==
In order to stop Arch Linux from clearing the screen on boot we can add the {{mono|i915}} module to {{mono|MODULES}} inside of {{mono|/etc/mkinitcpio.conf}} and then regenerate our kernel images.
In order to stop Arch Linux from clearing the screen on boot we can add the {{mono|i915}} module to {{mono|MODULES}} inside of {{mono|/etc/mkinitcpio.conf}} and then regenerate our kernel images.
{{Console|1=sudoedit /etc/mkinitcpio.conf}}<br/>
{{Console|1=sudoedit /etc/mkinitcpio.conf}}
{{Console|1={{WhiteBold|MODULES{{=}}}}{{Green|"&#8230; i915"}}|prompt=false}}<br/>
{{margin}}
{{Console|title=/etc/mkinitcpio.conf|1={{WhiteBold|MODULES{{=}}}}{{Green|"&#8230; i915"}}|prompt=false|margin=true}}
{{margin}}
{{Console|1=sudo mkinitcpio -p linux}}
{{Console|1=sudo mkinitcpio -p linux}}
Then create a directory for getty overrides and create one with the following.
Then create a directory for getty overrides and create one with the following.
{{Console|1=sudo mkdir /etc/systemd/system/getty@tty1.service.d|2=sudoedit /etc/systemd/system/getty@tty1.service.d/noclear.conf}}<br/>
{{Console|1=sudo mkdir /etc/systemd/system/getty@tty1.service.d|2=sudoedit /etc/systemd/system/getty@tty1.service.d/noclear.conf}}
{{Console|prompt=false|1={{MagentaBold|[Service]}}<br/>{{Magenta|TTYVTDisallocate{{=}}}}no}}
{{margin}}
{{Console|title=/etc/systemd/system/getty@tty1.service.d/noclear.conf|prompt=false|1={{MagentaBold|[Service]}}<br/>{{Magenta|TTYVTDisallocate{{=}}}}no}}


=={{Icon|notebook}} Traditional Device Node Names==
=={{Icon|notebook}} Traditional Device Node Names==
To translate the predictable device node names back into traditional ones, create the following. You can use the vim command {{mono|:r !cat /sys/class/net/wlp3s0/address}}, replacing the device node respectively, in order to get the MAC Address of each device pasted into vim.
To translate the predictable device node names back into traditional ones, create the following. You can use the vim command {{mono|:r !cat /sys/class/net/wlp3s0/address}}, replacing the device node respectively, in order to get the MAC Address of each device pasted into vim.
{{Console|1=vim /etc/udev/rules.d/10-network.rules}}<br/>
{{Console|title=/etc/udev/rules.d/10-network.rules|prompt=false|1={{BlueBold|SUBSYSTEM}}{{=}}{{=}}{{Green|"net"}}, {{BlueBold|ACTION}}{{=}}{{=}}{{Green|"add"}}, {{YellowBold|ATTR}}{{BlackBold|{}}{{YellowBold|address}}{{BlackBold|<nowiki>}</nowiki>}}{{=}}{{=}}{{Green|"ETHERNET:MAC:ADDRESS"}}, {{YellowBold|NAME}}{{=}}{{Green|"wired0"}}<br/>{{BlueBold|SUBSYSTEM}}{{=}}{{=}}{{Green|"net"}}, {{BlueBold|ACTION}}{{=}}{{=}}{{Green|"add"}}, {{YellowBold|ATTR}}{{BlackBold|{}}{{YellowBold|address}}{{BlackBold|<nowiki>}</nowiki>}}{{=}}{{=}}{{Green|"WIFI:MAC:ADDRESS"}}, {{YellowBold|NAME}}{{=}}{{Green|"wifi0"}}}}
{{Console|prompt=false|1={{BlueBold|SUBSYSTEM}}{{=}}{{=}}{{Green|"net"}}, {{BlueBold|ACTION}}{{=}}{{=}}{{Green|"add"}}, {{YellowBold|ATTR}}{{BlackBold|{}}{{YellowBold|address}}{{BlackBold|<nowiki>}</nowiki>}}{{=}}{{=}}{{Green|"ETHERNET:MAC:ADDRESS"}}, {{YellowBold|NAME}}{{=}}{{Green|"wired0"}}<br/>{{BlueBold|SUBSYSTEM}}{{=}}{{=}}{{Green|"net"}}, {{BlueBold|ACTION}}{{=}}{{=}}{{Green|"add"}}, {{YellowBold|ATTR}}{{BlackBold|{}}{{YellowBold|address}}{{BlackBold|<nowiki>}</nowiki>}}{{=}}{{=}}{{Green|"WIFI:MAC:ADDRESS"}}, {{YellowBold|NAME}}{{=}}{{Green|"wifi0"}}}}


=={{Icon|notebook}} Console Fonts==
=={{Icon|notebook}} Console Fonts==
Line 37: Line 39:
{{Console|1=setfont -m 8859-2 gr928-8x16-thin|2=showconsolefont}}
{{Console|1=setfont -m 8859-2 gr928-8x16-thin|2=showconsolefont}}
This can be set at boot by adding it to {{mono|/etc/vconsole.conf}}.
This can be set at boot by adding it to {{mono|/etc/vconsole.conf}}.
{{Console|1=sudoedit /etc/vconsole.conf}}<br/>
{{Console|title=/etc/vconsole.conf|1=FONT{{=}}gr928-8x16-thin<br>MAP{{=}}8859-2|prompt=false}}
{{Console|1=FONT{{=}}gr928-8x16-thin<br>MAP{{=}}8859-2|prompt=false}}


=={{Icon|notebook}} Auto-Login==
=={{Icon|notebook}} Auto-Login==
Line 50: Line 51:
=={{Icon|notebook}} Auto-Start Xorg on Graphical Boot==
=={{Icon|notebook}} Auto-Start Xorg on Graphical Boot==
Next to get Xorg to auto-start only when systemd has reached a {{mono|graphical.target}} one can merely use a little bash magic. Add the following to the end of {{mono|~/.bashrc}}.
Next to get Xorg to auto-start only when systemd has reached a {{mono|graphical.target}} one can merely use a little bash magic. Add the following to the end of {{mono|~/.bashrc}}.
{{Console|1=SYSTEMD_TARGET{{=}}`systemctl list-units --type target {{!}} g graphical {{!}} sed 's/    / /' {{!}} cut -d " " -f3`<br/>if [ "$SYSTEMD_TARGET" {{=}} "active" ]; then<br/>    if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then<br/>        exec startx<br/>    fi<br/>fi|prompt=false}}
{{Console|title=~/.bashrc|1=SYSTEMD_TARGET{{=}}`systemctl list-units --type target {{!}} g graphical {{!}} sed 's/    / /' {{!}} cut -d " " -f3`<br/>if [ "$SYSTEMD_TARGET" {{=}} "active" ]; then<br/>    if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then<br/>        exec startx<br/>    fi<br/>fi|prompt=false}}


=={{Icon|notebook}} Applications==
=={{Icon|notebook}} Applications==
Line 56: Line 57:
{{Console|<nowiki>git clone https://github.com/kyau/dotfiles && cd dotfiles && ./setup.sh && logout</nowiki>}}
{{Console|<nowiki>git clone https://github.com/kyau/dotfiles && cd dotfiles && ./setup.sh && logout</nowiki>}}
Once Xorg is installed and my shell environment and config files are in place, I usually then run my application install script.
Once Xorg is installed and my shell environment and config files are in place, I usually then run my application install script.
{{GitHub|My current [//github.com/kyau/dotfiles/blob/master/install-x220.sh install-x220.sh].|margin-bottom=true}}
{{GitHub|My current [//github.com/kyau/dotfiles/blob/master/pkgstrap pkgstrap].|margin-bottom=true}}


={{Icon24|sitemap}} Hardware=
={{Icon24|sitemap}} Hardware=
=={{Icon|notebook}} Battery/CPU==
=={{Icon|notebook}} Battery/CPU==
Install [[archwiki:TLP|TLP]] and related packages. Then enable it with systemd, don't forget to mask the required services (skip NetworkManager if you use this).
Install [[archwiki:TLP|TLP]] and related packages. Then enable it with systemd, don't forget to mask the required services (skip NetworkManager if you use this).
{{Console|1=pacaur -S tlp tp_smapi acpi_call|2=sudo systemctl enable tlp|3=sudo systemctl enable tlp-sleep}}<br/>
{{Console|1=pikaur -S tlp tp_smapi acpi_call|2=sudo systemctl enable tlp|3=sudo systemctl enable tlp-sleep}}
{{margin}}
{{Console|1=sudo systemctl mask NetworkManager.service|2=sudo systemctl mask systemd-rfkill.service|3=sudo systemctl mask systemd-rfkill.socket}}
{{Console|1=sudo systemctl mask NetworkManager.service|2=sudo systemctl mask systemd-rfkill.service|3=sudo systemctl mask systemd-rfkill.socket}}
Then edit the tlp config file to setup your TLP profile.
Then edit the tlp config file to setup your TLP profile.
Line 69: Line 71:
{{Console|1=sudo tlp-stat}}
{{Console|1=sudo tlp-stat}}
It is also a good idea to install PowerTOP in order to monitor power usage.
It is also a good idea to install PowerTOP in order to monitor power usage.
{{Console|1=pacaur -S powertop}}
{{Console|1=pikaur -S powertop}}


=={{Icon|notebook}} Fan Control==
=={{Icon|notebook}} Fan Control==
Install [//aur.archlinux.org/packages/thinkfan/ thinkfan], default configuration is installed into {{mono|/usr/lib/modprobe.d/thinkpad_acpi.conf}}.
Install [//aur.archlinux.org/packages/thinkfan/ thinkfan], default configuration is installed into {{mono|/usr/lib/modprobe.d/thinkpad_acpi.conf}}.
{{Console|1=pacaur -S acpi lm_sensors thinkfan}}
{{Console|1=pikaur -S acpi lm_sensors thinkfan}}
Then detect the hardware monitors chips that are available. Then re-enable the {{mono|thinkpad_acpi}} kernel module to update with the new config.
Then detect the hardware monitors chips that are available. Then re-enable the {{mono|thinkpad_acpi}} kernel module to update with the new config.
{{Console|1=sudo sensors-detect|2=sudo modprobe thinkpad_acpi}}
{{Console|1=sudo sensors-detect|2=sudo modprobe thinkpad_acpi}}
Line 94: Line 96:
{{Console|1=sudoedit /boot/EFI/BOOT/refind.conf}}
{{Console|1=sudoedit /boot/EFI/BOOT/refind.conf}}
At this point your kernel options should looks something similar to the following:
At this point your kernel options should looks something similar to the following:
{{Console|1=options {{Green|"rd.luks.uuid{{=}}PARTUUID-sda1-root-LUKS-encryptedXXX rd.luks.name{{=}}PARTUUID-sda1-root-LUKS-encryptedXXX{{=}}x220}} \<br/>        {{Green|lvm.lv{{=}}lvm/root rd.luks.options{{=}}discard root{{=}}/dev/mapper/x220-root resume{{=}}/dev/mapper/x220-swap}} \<br/>        {{Green|rw add_efi_memmap initrc{{=}}\intel-ucode.img}} {{Green|nowatchdog"}}|prompt=false}}
{{Console|title=/boot/EFI/BOOT/refind.conf|1=options {{Green|"rd.luks.uuid{{=}}PARTUUID-sda1-root-LUKS-encryptedXXX rd.luks.name{{=}}PARTUUID-sda1-root-LUKS-encryptedXXX{{=}}x220}} \<br/>        {{Green|lvm.lv{{=}}lvm/root rd.luks.options{{=}}discard root{{=}}/dev/mapper/x220-root resume{{=}}/dev/mapper/x220-swap}} \<br/>        {{Green|rw add_efi_memmap initrc{{=}}\intel-ucode.img}} {{Green|nowatchdog"}}|prompt=false}}
Since the watchdog is now disabled the kernel module is no longer required to auto-start, blacklist it by adding a config to {{mono|/etc/modprobe.d}}.
Since the watchdog is now disabled the kernel module is no longer required to auto-start, blacklist it by adding a config to {{mono|/etc/modprobe.d}}.
{{Console|1=echo "install iTCO_wdt /bin/false" {{!}} sudo tee /etc/modprobe.d/thinkpad.conf}}
{{Console|1=echo "install iTCO_wdt /bin/false" {{!}} sudo tee /etc/modprobe.d/thinkpad.conf}}
Then add that config to the {{mono|FILES}} section inside of {{mono|/etc/mkinicpio.conf}}.
Then add that config to the {{mono|FILES}} section inside of {{mono|/etc/mkinicpio.conf}}.
{{Console|1=sudoedit /etc/mkinitcpio.conf}}<br/>
{{Console|title=/etc/mkinitcpio.conf|1={{WhiteBold|FILES{{=}}}}{{Green|"&#8230; /etc/modprobe.d/thinkpad.conf"}}|prompt=false}}
{{Console|1={{WhiteBold|FILES{{=}}}}{{Green|"&#8230; /etc/modprobe.d/thinkpad.conf"}}|prompt=false}}
Finally rebuild the initramfs.
Finally rebuild the initramfs.
{{Console|1=sudo mkinitcpio -p linux}}
{{Console|1=sudo mkinitcpio -p linux}}
Line 105: Line 106:
=={{Icon|notebook}} Keyboard & TrackPoint==
=={{Icon|notebook}} Keyboard & TrackPoint==
For ideal usage the Touchpad has been disabled in BIOS, the TrackPoint middle click is then disabled and the menu key between the right alt and ctrl is remapped to Super (ie. Windows Key).<br/>
For ideal usage the Touchpad has been disabled in BIOS, the TrackPoint middle click is then disabled and the menu key between the right alt and ctrl is remapped to Super (ie. Windows Key).<br/>
{{Console|1=vim ~/.Xmodmap}}<br/>
{{Console|title=~/.Xmodmap|1=pointer {{=}} 1 9 3 4 5 6 7 8 2 10<br/>keycode 135 {{=}} Super_R|prompt=false|margin=true}}
{{Console|1=pointer {{=}} 1 9 3 4 5 6 7 8 2 10<br/>keycode 135 {{=}} Super_R|prompt=false}}
{{margin}}
{{Note|Remove the first line with {{mono|1 9 3 4..}} in order to only remap {{mono|Menu}}}}
{{Note|Remove the first line with {{mono|1 9 3 4..}} in order to only remap {{mono|Menu}}}}
You will still be able to use the middle TrackPoint button to hold and scroll but it will no longer annoy you by pasting the clipboard.<br/>
You will still be able to use the middle TrackPoint button to hold and scroll but it will no longer annoy you by pasting the clipboard.<br/>
Line 112: Line 113:
{{Console|1=xmodmap ~/.Xmodmap}}
{{Console|1=xmodmap ~/.Xmodmap}}
For the TrackPoint we can max out the speed and up the sensitivity a bit, defaults are {{mono|97}} for speed and {{mono|200}} for sensitivity. For this create a systemd service to change them on boot.
For the TrackPoint we can max out the speed and up the sensitivity a bit, defaults are {{mono|97}} for speed and {{mono|200}} for sensitivity. For this create a systemd service to change them on boot.
{{Console|1=sudoedit /etc/systemd/system/trackpoint.path}}<br/>
{{Console|title=/etc/systemd/system/trackpoint.path|1={{MagentaBold|[Unit]}}<br/>{{Magenta|Description{{=}}}}Lenovo Trackpoint Attributes<br/><br/>{{MagentaBold|[Path]}}<br/>{{Magenta|PathExists{{=}}}}/sys/devices/platform/i8042/serio1/speed<br/><br/>{{MagentaBold|[Install]}}<br/>{{Magenta|WantedBy{{=}}}}default.target|prompt=false|margin=true}}
{{Console|1={{MagentaBold|[Unit]}}<br/>{{Magenta|Description{{=}}}}Lenovo Trackpoint Attributes<br/><br/>{{MagentaBold|[Path]}}<br/>{{Magenta|PathExists{{=}}}}/sys/devices/platform/i8042/serio1/speed<br/><br/>{{MagentaBold|[Install]}}<br/>{{Magenta|WantedBy{{=}}}}default.target|prompt=false}}<br/>
{{margin}}
{{Console|1=sudoedit /etc/systemd/system/trackpoint.service}}<br/>
{{Console|title=/etc/systemd/system/trackpoint.service|1={{MagentaBold|[Unit]}}<br/>{{Magenta|Description{{=}}}}Set TrackPoint attributes<br/><br/>{{MagentaBold|[Service]}}<br/>{{Magenta|ExecStart{{=}}}}/usr/local/bin/trackpoint-config|prompt=false}}
{{Console|1={{MagentaBold|[Unit]}}<br/>{{Magenta|Description{{=}}}}Set TrackPoint attributes<br/><br/>{{MagentaBold|[Service]}}<br/>{{Magenta|ExecStart{{=}}}}/usr/local/bin/trackpoint-config|prompt=false}}
Create the script to change the Sysfs rules.
Create the script to change the Sysfs rules.
{{Console|1=sudoedit /usr/local/bin/trackpoint}}<br/>
{{Console|title=/usr/local/bin/trackpoint|1={{BlackBold|#!/bin/bash}}<br/><br/>{{Blue|echo}} {{Green|200}} {{Magenta|&gt;}} /sys/devices/platform/i8042/serio1/speed<br/>{{Blue|echo}} {{Green|220}} {{Magenta|&gt;}} /sys/devices/platform/i8042/serio1/sensitivity|prompt=false|margin=true}}
{{Console|1={{BlackBold|#!/bin/bash}}<br/><br/>{{Blue|echo}} {{Green|200}} {{Magenta|&gt;}} /sys/devices/platform/i8042/serio1/speed<br/>{{Blue|echo}} {{Green|220}} {{Magenta|&gt;}} /sys/devices/platform/i8042/serio1/sensitivity|prompt=false}}<br/>
{{margin}}
{{Console|1=sudo chmod a+x /usr/local/bin/trackpoint}}
{{Console|1=sudo chmod a+x /usr/local/bin/trackpoint}}
Then {{mono|enable}} and {{mono|start}} the service.
Then {{mono|enable}} and {{mono|start}} the service.
Line 135: Line 135:
For continuous trimming add {{mono|,discard}} to the filesystem mount options for the root partition.
For continuous trimming add {{mono|,discard}} to the filesystem mount options for the root partition.
{{Console|1=sudoedit /etc/fstab}}
{{Console|1=sudoedit /etc/fstab}}
====LVM Trim====
If LVM it being run on the SSD, also enable trim in the {{mono|lvm.conf}}
{{Console|title=/etc/lvm/lvm.conf|prompt=false|1=issue_discards {{=}} 1}}


====S.M.A.R.T Monitoring====
====S.M.A.R.T Monitoring====
To monitor the HDD or SSD installed you need to install the {{mono|smartmontools}} package.
To monitor the HDD or SSD installed you need to install the {{mono|smartmontools}} package.
{{Console|1=pacaur -S smartmontools}}
{{Console|1=pikaur -S smartmontools}}
You can view an overall health assessment with the following:
You can view an overall health assessment with the following:
{{Console|1=sudo smartctl -H /dev/sdX}}
{{Console|1=sudo smartctl -H /dev/sdX}}
Line 146: Line 149:
{{Console|1=sudo sed -i 's/^DEVICESCAN/DEVICESCAN -m address\@domain.com -M exec \/usr\/local\/bin\/smartdnotify/' /etc/smartd.conf}}
{{Console|1=sudo sed -i 's/^DEVICESCAN/DEVICESCAN -m address\@domain.com -M exec \/usr\/local\/bin\/smartdnotify/' /etc/smartd.conf}}
Then create the {{mono|/usr/local/bin/smartdnotify}} script (replacing both instances of ''kyau'' with your username).
Then create the {{mono|/usr/local/bin/smartdnotify}} script (replacing both instances of ''kyau'' with your username).
{{Console|1=sudoedit /usr/local/bin/smartdnotify}}<br/>
{{Console|title=/usr/local/bin/smartdnotify|prompt=false|1={{BlackBold|#!/bin/sh}}<br/>sudo -u kyau DISPLAY{{=}}:0 DBUS_SESSION_BUS_ADDRESS{{=}}unix:path{{=}}/run/user/kyau/bus notify-send \<br/>            "S.M.A.R.T Error ($SMARTD_FAILTYPE)" "$SMARTD_MESSAGE" --icon{{=}}dialog-warning}}
{{Console|prompt=false|1={{BlackBold|#!/bin/sh}}<br/>sudo -u kyau DISPLAY{{=}}:0 DBUS_SESSION_BUS_ADDRESS{{=}}unix:path{{=}}/run/user/kyau/bus notify-send \<br/>            "S.M.A.R.T Error ($SMARTD_FAILTYPE)" "$SMARTD_MESSAGE" --icon{{=}}dialog-warning}}<br/>
{{margin}}
{{Console|1=sudo chmod +x /usr/local/bin/smartdnotify}}
{{Console|1=sudo chmod +x /usr/local/bin/smartdnotify}}
Then you can start the service.
Then you can start the service.
Line 156: Line 159:
{{Note|Most X220 laptops will not need this option, it has been left here for niche uses.}}
{{Note|Most X220 laptops will not need this option, it has been left here for niche uses.}}
To fix the Intel HD 3000 graphics showing tearing during video playback or other fast movement on the screen.
To fix the Intel HD 3000 graphics showing tearing during video playback or other fast movement on the screen.
{{Console|1=sudoedit /etc/X11/xorg.conf.d/20-intel.conf}}<br/>
{{Console|title=/etc/X11/xorg.conf.d/20-intel.conf|1={{BlueBold|Section "Device"}}<br/>  {{Magenta|Identifier}} {{Green|"Intel HD 3000 Graphics"}}<br>  {{Magenta|Driver}} {{Green|"intel"}}<br/>  {{Magenta|Option}} {{Green|"TearFree" "}}{{MagentaBold|true}}{{Green|"}}<br/>{{BlueBold|EndSection}}|prompt=false}}
{{Console|1={{BlueBold|Section "Device"}}<br/>  {{Magenta|Identifier}} {{Green|"Intel HD 3000 Graphics"}}<br>  {{Magenta|Driver}} {{Green|"intel"}}<br/>  {{Magenta|Option}} {{Green|"TearFree" "}}{{MagentaBold|true}}{{Green|"}}<br/>{{BlueBold|EndSection}}|prompt=false}}


={{Icon24|sitemap}} tmpfs=
={{Icon24|sitemap}} tmpfs=
Line 166: Line 168:


To get started install [[aur:profile-sync-daemon|profile-sync-daemond]].
To get started install [[aur:profile-sync-daemon|profile-sync-daemond]].
{{Console|1=pacaur -S profile-sync-daemon}}
{{Console|1=pikaur -S profile-sync-daemon}}
Run {{mono|profile-sync-daemon}} once to generate the user config.
Run {{mono|profile-sync-daemon}} once to generate the user config.
{{Console|1=psd}}
{{Console|1=psd}}
Line 182: Line 184:
=={{Icon|notebook}} Makepkg==
=={{Icon|notebook}} Makepkg==
Moving the build directory that {{mono|makepkg}} uses to build packages into the {{mono|/tmp}} folder will effectively move the package building temporary directory into memory.
Moving the build directory that {{mono|makepkg}} uses to build packages into the {{mono|/tmp}} folder will effectively move the package building temporary directory into memory.
{{Console|1=sudoedit /etc/makepkg.conf}}<br/>
{{Console|title=/etc/makepkg.conf|1=BUILDDIR{{=}}/tmp/makepkg|prompt=false}}
{{Console|1=BUILDDIR{{=}}/tmp/makepkg|prompt=false}}


=={{Icon|notebook}} User Cache==
=={{Icon|notebook}} User Cache==
Line 189: Line 190:


Insert a line into the {{mono|fstab}} for your user.
Insert a line into the {{mono|fstab}} for your user.
{{Console|1=sudoedit /etc/fstab}}<br/>
{{Console|title=/etc/fstab|1={{WhiteBold|tmpfs /home/kyau/.cache/}} {{Magenta|tmpfs}} {{BlueBold|defaults,noatime,mode{{=}}1777,nosuid,nodev,uid{{=}}kyau,gid{{=}}users}} {{GreenBold|0 0}}|prompt=false}}
{{Console|1={{WhiteBold|tmpfs /home/kyau/.cache/}} {{Magenta|tmpfs}} {{BlueBold|defaults,noatime,mode{{=}}1777,nosuid,nodev,uid{{=}}kyau,gid{{=}}users}} {{GreenBold|0 0}}|prompt=false}}


[[Category:ThinkPad]]
[[Category:ThinkPad]]
[[Category:Arch Linux]]
[[Category:Arch Linux]]

Latest revision as of 01:42, 25 February 2019

This is a compilation of information I have scoured off the net in order to get my ThinkPad X220 running in the best possible configuration possible for my needs. If you need assistance installing Arch Linux, refer to the installation tutorial linked above.

IconI personally use aur:pikaur to manage all of the packages on my Arch system as it can interface with the regular repositories and the AUR. However, use whatever you are comfortable with.

Keep in mind all of this is optional and none of it is by any means required and should be used on a case by case basis.

Icon Pre-Install

My personal ThinkPad X220 Arch Linux configuration includes LUKS on LVM. For this I did a security wipe of my SSD before the installation.

Begin by downloading the ThinkPad Drive Erase Utility, this is used for performing a security wipe on an SSD. Given that the ThinkPad X220 BIOS puts all SSDs into the frozen state on boot, which makes it challenging to use hdparm to secure wipe them, this utility is the only safe way to perform a security wipe.

Next use El Torito to convert the ISO downloaded into a bootable image file and dd it to a USB disk (or other form of writable bootable media). If aur:geteltorito is not installed, do so before hand. Also make sure you specify the correct disk node to write the image to, you can use lsblk to find the device node.

# pikaur -S geteltorito
# geteltorito.pl -o securewipe.img 83fd04ww.iso
# sudo dd if=securewipe.img of=/dev/sdX bs=10M

Reboot the machine booting off the prepared media; follow the steps presented.

IconWARNING: Using the disk erase will prompt you with a code to write down and then enter after a reboot. DO NOT skip this part.

Icon Post-Install

Icon Keeping the Boot Log on TTY1

In order to stop Arch Linux from clearing the screen on boot we can add the i915 module to MODULES inside of /etc/mkinitcpio.conf and then regenerate our kernel images.

# sudoedit /etc/mkinitcpio.conf
 
filename: /etc/mkinitcpio.conf
MODULES="… i915"
 
# sudo mkinitcpio -p linux

Then create a directory for getty overrides and create one with the following.

# sudo mkdir /etc/systemd/system/getty@tty1.service.d
# sudoedit /etc/systemd/system/getty@tty1.service.d/noclear.conf
 
filename: /etc/systemd/system/getty@tty1.service.d/noclear.conf
[Service]
TTYVTDisallocate=no

Icon Traditional Device Node Names

To translate the predictable device node names back into traditional ones, create the following. You can use the vim command :r !cat /sys/class/net/wlp3s0/address, replacing the device node respectively, in order to get the MAC Address of each device pasted into vim.

filename: /etc/udev/rules.d/10-network.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ETHERNET:MAC:ADDRESS", NAME="wired0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="WIFI:MAC:ADDRESS", NAME="wifi0"

Icon Console Fonts

Everyone have their own opinion, you can pull up a list with ls /usr/share/kbd/consolefonts. To test out a font use setfont, issue the command by itself to return to the default. You can also issue showconsolefont to show a list of all available characters.

# setfont -m 8859-2 gr928-8x16-thin
# showconsolefont

This can be set at boot by adding it to /etc/vconsole.conf.

filename: /etc/vconsole.conf
FONT=gr928-8x16-thin
MAP=8859-2

Icon Auto-Login

 
IconIt would be advised to skip this section unless you use full disk encryption

Since I am using full disk encryption and I am prompted for a password before I ever even get to login to the system there is no reason to have two separate logins. Therefore, to setup an auto-login on TTY1 edit the service.

# sudo systemctl edit getty@tty1

Paste in the following (changing the username accordingly):

[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin kyau --noclear %I $TERM

Icon Auto-Start Xorg on Graphical Boot

Next to get Xorg to auto-start only when systemd has reached a graphical.target one can merely use a little bash magic. Add the following to the end of ~/.bashrc.

filename: ~/.bashrc
SYSTEMD_TARGET=`systemctl list-units --type target | g graphical | sed 's/ / /' | cut -d " " -f3`
if [ "$SYSTEMD_TARGET" = "active" ]; then
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
exec startx
fi
fi

Icon Applications

Personally, I keep a running backup of all of my dotfiles on GitHub along with a script to redo all the symbolic links. This makes the process as simple as:

# git clone https://github.com/kyau/dotfiles && cd dotfiles && ./setup.sh && logout

Once Xorg is installed and my shell environment and config files are in place, I usually then run my application install script.

IconGitHub: My current pkgstrap.

Icon Hardware

Icon Battery/CPU

Install TLP and related packages. Then enable it with systemd, don't forget to mask the required services (skip NetworkManager if you use this).

# pikaur -S tlp tp_smapi acpi_call
# sudo systemctl enable tlp
# sudo systemctl enable tlp-sleep
 
# sudo systemctl mask NetworkManager.service
# sudo systemctl mask systemd-rfkill.service
# sudo systemctl mask systemd-rfkill.socket

Then edit the tlp config file to setup your TLP profile.

IconGitHub: My current tlp config. I highly suggest looking at the default as it is fully commented.
# sudoedit /etc/defaults/tlp

TLP status can be shown with the following:

# sudo tlp-stat

It is also a good idea to install PowerTOP in order to monitor power usage.

# pikaur -S powertop

Icon Fan Control

Install thinkfan, default configuration is installed into /usr/lib/modprobe.d/thinkpad_acpi.conf.

# pikaur -S acpi lm_sensors thinkfan

Then detect the hardware monitors chips that are available. Then re-enable the thinkpad_acpi kernel module to update with the new config.

# sudo sensors-detect
# sudo modprobe thinkpad_acpi

To show the current thermal and cooling information use acpi.

# sudo acpi -V

To show the current fan speed and level.

# sudo cat /proc/acpi/ibm/fan

Make the changes to point it to the right temperature reading, you can use :r !sudo find /sys/devices -type f -name "temp*_input" in order to paste all the monitors into the file.

IconGitHub: My current thinkfan.conf
# sudoedit /etc/thinkfan.conf

You can verify the config is written correctly with the following command.

# sudo thinkfan -n

Finally enable and start thinkfan.

# sudo systemctl enable thinkfan
# sudo systemctl start thinkfan

Icon Kernel

Since the target system is a laptop the watchdog timer is not needed. This is typically used on systems that have mission-critical roles (i.e. servers), or because of the lack of power reset (i.e. embedded devices). However, when running a desktop or laptop this feature is not needed. To disable it merely add nowatchdog to your kernel options.

Edit your rEFInd config to modify kernel options.

# sudoedit /boot/EFI/BOOT/refind.conf

At this point your kernel options should looks something similar to the following:

filename: /boot/EFI/BOOT/refind.conf
options "rd.luks.uuid=PARTUUID-sda1-root-LUKS-encryptedXXX rd.luks.name=PARTUUID-sda1-root-LUKS-encryptedXXX=x220 \
lvm.lv=lvm/root rd.luks.options=discard root=/dev/mapper/x220-root resume=/dev/mapper/x220-swap \
rw add_efi_memmap initrc=\intel-ucode.img nowatchdog"

Since the watchdog is now disabled the kernel module is no longer required to auto-start, blacklist it by adding a config to /etc/modprobe.d.

# echo "install iTCO_wdt /bin/false" | sudo tee /etc/modprobe.d/thinkpad.conf

Then add that config to the FILES section inside of /etc/mkinicpio.conf.

filename: /etc/mkinitcpio.conf
FILES="… /etc/modprobe.d/thinkpad.conf"

Finally rebuild the initramfs.

# sudo mkinitcpio -p linux

Icon Keyboard & TrackPoint

For ideal usage the Touchpad has been disabled in BIOS, the TrackPoint middle click is then disabled and the menu key between the right alt and ctrl is remapped to Super (ie. Windows Key).

filename: ~/.Xmodmap
pointer = 1 9 3 4 5 6 7 8 2 10
keycode 135 = Super_R
 
IconRemove the first line with 1 9 3 4.. in order to only remap Menu

You will still be able to use the middle TrackPoint button to hold and scroll but it will no longer annoy you by pasting the clipboard.
Don't forget to load this when Xorg starts by inserting it into either ~/.xinitrc or the window manager's autostart file. Alternately it can be run from the prompt for immediate change.

# xmodmap ~/.Xmodmap

For the TrackPoint we can max out the speed and up the sensitivity a bit, defaults are 97 for speed and 200 for sensitivity. For this create a systemd service to change them on boot.

filename: /etc/systemd/system/trackpoint.path
[Unit]
Description=Lenovo Trackpoint Attributes

[Path]
PathExists=/sys/devices/platform/i8042/serio1/speed

[Install]
WantedBy=default.target
 
filename: /etc/systemd/system/trackpoint.service
[Unit]
Description=Set TrackPoint attributes

[Service]
ExecStart=/usr/local/bin/trackpoint-config

Create the script to change the Sysfs rules.

filename: /usr/local/bin/trackpoint
#!/bin/bash

echo 200 > /sys/devices/platform/i8042/serio1/speed
echo 220 > /sys/devices/platform/i8042/serio1/sensitivity
 
# sudo chmod a+x /usr/local/bin/trackpoint

Then enable and start the service.

# sudo systemctl enable trackpoint.path
# sudo systemctl start trackpoint.path

Icon Removable Storage Encryption

Use an additional disk (USB, SD) in order to bolster the X220 disk space in addition to the two hard drive bays. This will take you through adding one with LUKS and ext4.

Icon SSD

For SSD trimming there are a couple of options.

Weekly TRIM

For most a weekly fstrim should be most effective. This single command can take care of all of that.

# sudo systemctl enable fstrim.timer

Continuous TRIM

For continuous trimming add ,discard to the filesystem mount options for the root partition.

# sudoedit /etc/fstab

LVM Trim

If LVM it being run on the SSD, also enable trim in the lvm.conf

filename: /etc/lvm/lvm.conf
issue_discards = 1

S.M.A.R.T Monitoring

To monitor the HDD or SSD installed you need to install the smartmontools package.

# pikaur -S smartmontools

You can view an overall health assessment with the following:

# sudo smartctl -H /dev/sdX

Enable and start the smartd systemd service to enable SMART monitoring for all disks.

# sudo systemctl enable smartd

We can also have SMART email us and run a script for notifications on SMART errors.

# sudo sed -i 's/^DEVICESCAN/DEVICESCAN -m address\@domain.com -M exec \/usr\/local\/bin\/smartdnotify/' /etc/smartd.conf

Then create the /usr/local/bin/smartdnotify script (replacing both instances of kyau with your username).

filename: /usr/local/bin/smartdnotify
#!/bin/sh
sudo -u kyau DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/kyau/bus notify-send \
"S.M.A.R.T Error ($SMARTD_FAILTYPE)" "$SMARTD_MESSAGE" --icon=dialog-warning
 
# sudo chmod +x /usr/local/bin/smartdnotify

Then you can start the service.

# sudo systemctl start smartd

Icon Video

 
IconMost X220 laptops will not need this option, it has been left here for niche uses.

To fix the Intel HD 3000 graphics showing tearing during video playback or other fast movement on the screen.

filename: /etc/X11/xorg.conf.d/20-intel.conf
Section "Device"
Identifier "Intel HD 3000 Graphics"
Driver "intel"
Option "TearFree" "true"
EndSection

Icon tmpfs

tmpfs can be used to mount portions of your ram for use as temporary directories. The advantages of this are multi-fold: speed (RAM is much faster than any HDD or SSD), security (the files get wiped on boot, which removed the need for periodic cleanup) and finally, given that this is usually the most written data to the disk it will increase the life of your disk by reducing wear.

Icon Browser Profile

Putting the web browser's user profile directory onto tmpfs can dramatically speed up the browser.

To get started install profile-sync-daemond.

# pikaur -S profile-sync-daemon

Run profile-sync-daemon once to generate the user config.

# psd

Edit the configuration and specify which BROWSERS you are using, I personally only use google-chrome-stable. It is also a good idea to enable overlayfs to decrease the memory footprint and increase sync speed.

USE_OVERLAYFS="yes"
BROWSERS="google-chrome"

When using overlayfs it is also required to give the program sudo rights, we can do this for only this program by using visudo.

# sudo visudo

Add a line that for overlayfs replacing my username with your own.

kyau ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper

With that set we can run profile-sync-daemon one last time manually to preview what it will setup.

# psd p

Provided everything is as it should be, enable and then start the service.

# systemctl --user enable psd
# systemctl --user start psd

Icon Makepkg

Moving the build directory that makepkg uses to build packages into the /tmp folder will effectively move the package building temporary directory into memory.

filename: /etc/makepkg.conf
BUILDDIR=/tmp/makepkg

Icon User Cache

In order to speed up programs that store lots of temporary cached data on the local disk, put the user's cache directory into a tmpfs ramdisk.

Insert a line into the fstab for your user.

filename: /etc/fstab
tmpfs /home/kyau/.cache/ tmpfs defaults,noatime,mode=1777,nosuid,nodev,uid=kyau,gid=users 0 0