ThinkPad:ArchLinux: Difference between revisions
m (→Applications) |
|||
(119 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:ThinkPad X220: Arch Linux Notes}}<metadesc>Information about running Arch Linux on a Lenovo ThinkPad X220.</metadesc> | {{DISPLAYTITLE:ThinkPad X220: Arch Linux Notes}}<metadesc>Information about running Arch Linux on a Lenovo ThinkPad X220.</metadesc> | ||
<div id="tocalign">__TOC__</div> | <div id="tocalign">__TOC__</div> | ||
{{Back|ThinkPad|break=false}} | {{Back|ThinkPad|break=false}} | ||
{{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 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: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. | ||
=== Keeping the Boot Log on TTY1 | |||
={{Icon24|sitemap}} 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 [//download.lenovo.com/pccbbs/mobiles/83fd04ww.iso 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 {{mono|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 {{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=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. | |||
{{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}} | |||
={{Icon24|sitemap}} Post-Install= | |||
=={{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= | {{Console|1=sudoedit /etc/mkinitcpio.conf}} | ||
{{margin}} | |||
{{Console|title=/etc/mkinitcpio.conf|1={{WhiteBold|MODULES{{=}}}}{{Green|"… i915"}}|prompt=false|margin=true}} | |||
{{margin}} | |||
{{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= | {{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=[Service]<br/>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== | ||
To translate the predictable device node names back into traditional ones, | 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| | {{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"}}}} | ||
== | =={{Icon|notebook}} Console Fonts== | ||
Everyone have their own opinion, you can pull up a list with {{mono|ls /usr/share/kbd/consolefonts}}. To test out a font use {{mono|setfont}}, issue the command by itself to return to the default. You can also issue {{mono|showconsolefont}} to show a list of all available characters. | Everyone have their own opinion, you can pull up a list with {{mono|ls /usr/share/kbd/consolefonts}}. To test out a font use {{mono|setfont}}, issue the command by itself to return to the default. You can also issue {{mono|showconsolefont}} to show a list of all available characters. | ||
{{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}}. | |||
{{Console|1= | {{Console|title=/etc/vconsole.conf|1=FONT{{=}}gr928-8x16-thin<br>MAP{{=}}8859-2|prompt=false}} | ||
=={{Icon|notebook}} Auto-Login== | |||
{{margin}} | |||
{{Note|It 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. | |||
{{Console|1=sudo systemctl edit getty@tty1}} | |||
Paste in the following (changing the username accordingly): | |||
{{Console|1={{MagentaBold|[Service]}}<br/>{{Magenta|ExecStart{{=}}}}<br/>{{Magenta|ExecStart{{=}}}}-/usr/bin/agetty --autologin kyau --noclear %I $TERM|prompt=false}} | |||
=={{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}}. | |||
{{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== | |||
Personally, I keep a running backup of all of my [//github.com/kyau/dotfiles dotfiles] on GitHub along with a script to redo all the symbolic links. This makes the process as simple as: | |||
{{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. | |||
{{GitHub|My current [//github.com/kyau/dotfiles/blob/master/pkgstrap pkgstrap].|margin-bottom=true}} | |||
= Hardware = | ={{Icon24|sitemap}} Hardware= | ||
== | =={{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= | {{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. | ||
{{GitHub|My current [//github.com/kyau/dotfiles/blob/master/etc/default/tlp tlp] config| | {{GitHub|My current [//github.com/kyau/dotfiles/blob/master/system/etc/default/tlp tlp] config. I highly suggest looking at the default as it is fully commented.|margin-bottom=true}} | ||
{{Console|1= | {{Console|1=sudoedit /etc/defaults/tlp}} | ||
TLP status can be shown with the following: | TLP status can be shown with the following: | ||
{{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= | {{Console|1=pikaur -S powertop}} | ||
== | |||
=={{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= | {{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 51: | Line 83: | ||
{{Console|1=sudo cat /proc/acpi/ibm/fan}} | {{Console|1=sudo cat /proc/acpi/ibm/fan}} | ||
Make the changes to point it to the right temperature reading, you can use {{mono|:r !sudo find /sys/devices -type f -name "temp*_input"}} in order to paste all the monitors into the file. | Make the changes to point it to the right temperature reading, you can use {{mono|:r !sudo find /sys/devices -type f -name "temp*_input"}} in order to paste all the monitors into the file. | ||
{{GitHub|My current [//github.com/kyau/dotfiles/blob/master/etc/thinkfan.conf thinkfan.conf]| | {{GitHub|My current [//github.com/kyau/dotfiles/blob/master/system/etc/thinkfan.conf thinkfan.conf]|margin-bottom=true}} | ||
{{Console|1= | {{Console|1=sudoedit /etc/thinkfan.conf}} | ||
You can verify the config is written correctly with the following command. | You can verify the config is written correctly with the following command. | ||
{{Console|1=sudo thinkfan -n}} | {{Console|1=sudo thinkfan -n}} | ||
Finally enable and start thinkfan. | Finally enable and start thinkfan. | ||
{{Console|1=sudo systemctl enable thinkfan|2=sudo systemctl start thinkfan}} | {{Console|1=sudo systemctl enable thinkfan|2=sudo systemctl start thinkfan}} | ||
== | |||
=={{Icon|notebook}} Kernel== | |||
To | Since the target system is a laptop the {{mono|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 {{mono|nowatchdog}} to your kernel options. | ||
{{Console| | |||
=== | Edit your rEFInd config to modify kernel options. | ||
{{Console|1=sudoedit /boot/EFI/BOOT/refind.conf}} | |||
At this point your kernel options should looks something similar to the following: | |||
{{Console| | {{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}}. | ||
Then enable the service. | {{Console|1=echo "install iTCO_wdt /bin/false" {{!}} sudo tee /etc/modprobe.d/thinkpad.conf}} | ||
{{Console|1=sudo systemctl enable | Then add that config to the {{mono|FILES}} section inside of {{mono|/etc/mkinicpio.conf}}. | ||
{{Console|title=/etc/mkinitcpio.conf|1={{WhiteBold|FILES{{=}}}}{{Green|"… /etc/modprobe.d/thinkpad.conf"}}|prompt=false}} | |||
Finally rebuild the initramfs. | |||
{{Console|1=sudo mkinitcpio -p linux}} | |||
=={{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/> | |||
{{Console|title=~/.Xmodmap|1=pointer {{=}} 1 9 3 4 5 6 7 8 2 10<br/>keycode 135 {{=}} Super_R|prompt=false|margin=true}} | |||
{{margin}} | |||
{{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/> | |||
Don't forget to load this when Xorg starts by inserting it into either {{mono|~/.xinitrc}} or the window manager's autostart file. Alternately it can be run from the prompt for immediate change. | |||
{{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. | |||
{{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}} | |||
{{margin}} | |||
{{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}} | |||
Create the script to change the Sysfs rules. | |||
{{Console|title=/usr/local/bin/trackpoint|1={{BlackBold|#!/bin/bash}}<br/><br/>{{Blue|echo}} {{Green|200}} {{Magenta|>}} /sys/devices/platform/i8042/serio1/speed<br/>{{Blue|echo}} {{Green|220}} {{Magenta|>}} /sys/devices/platform/i8042/serio1/sensitivity|prompt=false|margin=true}} | |||
{{margin}} | |||
{{Console|1=sudo chmod a+x /usr/local/bin/trackpoint}} | |||
Then {{mono|enable}} and {{mono|start}} the service. | |||
{{Console|1=sudo systemctl enable trackpoint.path|2=sudo systemctl start trackpoint.path}} | |||
=={{Icon|notebook}} 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 {{mono|ext4}}. | |||
{{SeeAlso|ArchLinux:LUKS|Arch Linux: Encrypted Removable Storage}} | |||
=={{Icon|notebook}} SSD== | |||
For SSD trimming there are a couple of options. | |||
====Weekly TRIM==== | |||
For most a weekly {{mono|fstrim}} should be most effective. This single command can take care of all of that. | |||
{{Console|1=sudo systemctl enable fstrim.timer}} | |||
====Continuous TRIM==== | |||
For continuous trimming add {{mono|,discard}} to the filesystem mount options for the root partition. | |||
{{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==== | |||
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= | {{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 75: | Line 147: | ||
{{Console|1=sudo systemctl enable smartd}} | {{Console|1=sudo systemctl enable smartd}} | ||
We can also have SMART email us and run a script for notifications on SMART errors. | We can also have SMART email us and run a script for notifications on SMART errors. | ||
{{Console|1=sudo sed -i 's/^DEVICESCAN/DEVICESCAN -m address\@domain.com -M exec \/usr\/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/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| | {{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}} | ||
{{margin}} | |||
{{Console|1=sudo chmod +x /usr/bin/smartdnotify}} | {{Console|1=sudo chmod +x /usr/local/bin/smartdnotify}} | ||
Then you can start the service. | Then you can start the service. | ||
{{Console|1=sudo systemctl start smartd}} | {{Console|1=sudo systemctl start smartd}} | ||
== | =={{Icon|notebook}} Video== | ||
{{margin}} | |||
{{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= | {{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}} | ||
={{Icon24|sitemap}} tmpfs= | |||
[[archwiki: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|notebook}} Browser Profile== | |||
Putting the web browser's user profile directory onto {{mono|tmpfs}} can dramatically speed up the browser. | |||
To get started install [[aur:profile-sync-daemon|profile-sync-daemond]]. | |||
{{Console|1=pikaur -S profile-sync-daemon}} | |||
Run {{mono|profile-sync-daemon}} once to generate the user config. | |||
{{Console|1=psd}} | |||
Edit the configuration and specify which {{mono|BROWSERS}} you are using, I personally only use [[aur:google-chrome-stable|google-chrome-stable]]. It is also a good idea to enable overlayfs to decrease the memory footprint and increase sync speed. | |||
{{Console|1=USE_OVERLAYFS="yes"<br/>BROWSERS="google-chrome"|prompt=false}} | |||
When using overlayfs it is also required to give the program sudo rights, we can do this for only this program by using {{mono|visudo}}. | |||
{{Console|1=sudo visudo}} | |||
Add a line that for overlayfs replacing my username with your own. | |||
{{Console|1=kyau ALL{{=}}(ALL) NOPASSWD: /usr/bin/psd-overlay-helper|prompt=false}} | |||
With that set we can run {{mono|profile-sync-daemon}} one last time manually to preview what it will setup. | |||
{{Console|1=psd p}} | |||
Provided everything is as it should be, enable and then start the service. | |||
{{Console|1=systemctl --user enable psd|2=systemctl --user start psd}} | |||
= | =={{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. | |||
{{ | {{Console|title=/etc/makepkg.conf|1=BUILDDIR{{=}}/tmp/makepkg|prompt=false}} | ||
{{ | =={{Icon|notebook}} 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 {{mono|tmpfs}} ramdisk. | |||
{{ | Insert a line into the {{mono|fstab}} for your user. | ||
{{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| | |||
== | |||
{{Console| | |||
[[Category:ThinkPad]] | [[Category:ThinkPad]] | ||
[[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.
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.
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.
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. |
Post-Install
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 |
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 |
[Service] TTYVTDisallocate=no |
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.
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ETHERNET:MAC:ADDRESS", NAME="wired0" SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="WIFI:MAC:ADDRESS", NAME="wifi0" |
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.
FONT=gr928-8x16-thin MAP=8859-2 |
Auto-Login
It 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 |
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.
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 |
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.
GitHub: My current pkgstrap. |
Hardware
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.
GitHub: 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 |
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.
GitHub: 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 |
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:
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.
FILES="… /etc/modprobe.d/thinkpad.conf" |
Finally rebuild the initramfs.
# sudo mkinitcpio -p linux |
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).
pointer = 1 9 3 4 5 6 7 8 2 10 keycode 135 = Super_R |
Remove 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.
[Unit] Description=Lenovo Trackpoint Attributes [Path] PathExists=/sys/devices/platform/i8042/serio1/speed [Install] WantedBy=default.target |
[Unit] Description=Set TrackPoint attributes [Service] ExecStart=/usr/local/bin/trackpoint-config |
Create the script to change the Sysfs rules.
#!/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 |
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.
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
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).
#!/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 |
Video
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.
Section "Device" Identifier "Intel HD 3000 Graphics" Driver "intel" Option "TearFree" "true" EndSection |
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.
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 |
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.
BUILDDIR=/tmp/makepkg |
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.
tmpfs /home/kyau/.cache/ tmpfs defaults,noatime,mode=1777,nosuid,nodev,uid=kyau,gid=users 0 0 |