Back to Home

EDC device for the sysadmin: Linux in your pocket

Each admin Β· perhaps Β· was the case when something suddenly breaks Β· and you're somewhere on the road: you go by car Β· take the train or Β· trivially Β· sit somewhere on a park bench and get lost and ...

EDC device for the sysadmin: Linux in your pocket

Each administrator, perhaps, had a case when something suddenly breaks, and you are somewhere on the road: you go by car, sit on a train or, trivially, sit somewhere on a park bench and get lost and run somewhere there is no desire. And it is necessary to repair. Or, at a minimum, estimate the scale of the white fur animal that arrived.

It is clear that you can do with a smartphone or tablet, especially if you only need to go by ssh. But to use the touchscreen in such cases, as for me, is pain and suffering.



You can purchase an external keyboard, holder, or tablet stand, but I find it easier then to carry around a full-fledged laptop. Places will take about the same.

A little bit of memories and reasoning


If you are too lazy to read, you can go straight to the practical part.

At one time, when androids and iPhones did not exist yet, for such things I used the Nokia N810 β€œinternet tablet”. The device dimensions with a modern smartphone, while having a qwerty-keyboard and even with a full Linux on board. Ssh, vnc, rdesktop - no question! Plus, I actively used CAS Maxima when it was necessary to quickly calculate something and show the result.





But as time went on, android smartphones began to appear. Here it is, I thought: practically full-fledged Linux, while there is no need to carry another device with you to distribute the Internet. I began to look after the device with qwerty, which would replace me with the good old n810, by that time already pretty tired (screen loop, two times replaced battery, keyboard, broken case). The choice fell on Motorola Milestone.

Here it is, next to my good old Palm V and N810: I must say that the product did not justify trust. The keyboard was a complete disappointment. Not even because of the layout, but because of the extremely poor quality of workmanship: after six months of use, she began to flake off and hang out.





The encrypted bootloader added its own nails to the coffin: the inability to use the custom kernel with all the consequences, debian chroot, because of the peculiarities of the power supply, consumed the battery as if not in itself, but still, somehow the product solved the tasks assigned to it.

At the very least, it continued to be used after the expiration of the planned obsolescence period, determined by the manufacturer, when several more recent models were released (differing, perhaps, by a slightly modified layout and a large amount of RAM) and at the same time it was wildly buggy and slowed down. She finished her motorbike days very brutally: having gone to another dead frieze during a call, she was smashed against the wall.




Ok, as the ssh-terminal will come down and the smartphone (it will, of course, devour a certain amount of your nerve cells). But there are cases that it is necessary to cling to some piece of hardware with a console cable, or to remove tcpdump'n an unknown IP device in order to do something with it.

It’s fabulous when, due to the COM port on the docking station, a person pulls along a hefty 17 "HP stupid fool with a dock and a 1.5-pound power supply, and then also hangs with all this stuff on a stepladder in front of the bar.

Last time, I used a 12 "ThinkPad x220 with a usb2com adapter. But more and more often he began to leave the laptop at home, until once (once again) it happened β€œ$ username, everything broke!”, And with him only a smartphone on the android.

Here it is, the fish of my dreams (actually, no)


And I stumbled, once, on a product called GPD Pocket. A full-fledged laptop in the form factor of a resmartphone or under-tablet. 7 ", qwerty-keyboard, a decent supply of autonomy - oh, we must take. Ordered, received, unpacked.

For comparison with x220 and n810: I will not describe the characteristics, who should - will find on the Internet, especially since there was a recent review from Girbest. Just bring exhaust lshw and lspci: lshw:







Hidden text
    описаниС: ΠΠ°ΡΡ‚ΠΎΠ»ΡŒΠ½Ρ‹ΠΉ ΠΊΠΎΠΌΠΏΡŒΡŽΡ‚Π΅Ρ€
    ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Default string (Default string)
    ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Default string
    вСрсия: Default string
    сСрийный β„–: Default string
    Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 64 bits
    возмоТности: smbios-3.0 dmi-3.0 vsyscall32
    конфигурация: boot=normal chassis=desktop family=Default string sku=Default string uuid=00020003-0004-0005-0006-000700080009
  *-core
       описаниС: ΠœΠ°Ρ‚Π΅Ρ€ΠΈΠ½ΡΠΊΠ°Ρ ΠΏΠ»Π°Ρ‚Π°
       ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Default string
       ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: AMI Corporation
       физичСский ID:0
       вСрсия: Default string
       сСрийный β„–: Default string
       слот: Default string
     *-firmware
          описаниС: BIOS
          ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: American Megatrends Inc.
          физичСский ID:0
          вСрсия: 5.11date: 08/07/2017
          Ρ€Π°Π·ΠΌΠ΅Ρ€: 64KiB
          capacity:4032KiB
          возмоТности: pci upgrade shadowing cdboot bootselect socketedrom edd int13floppy1200 int13floppy720 int13floppy2880 int5printscreen int14serial int17printer acpi usb biosbootspecification uefi
     *-memory
          описаниС: БистСмная ΠΏΠ°ΠΌΡΡ‚ΡŒ
          физичСский ID:28
          слот: БистСмная ΠΏΠ»Π°Ρ‚Π° ΠΈΠ»ΠΈ матСринская ΠΏΠ»Π°Ρ‚Π°
          Ρ€Π°Π·ΠΌΠ΅Ρ€: 8GiB
        *-bank:0
             описаниС: DIMM DDR3 1066 MHz (0,9 ns)
             ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: 00000000
             ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Hynix Semiconductor
             физичСский ID:0
             сСрийный β„–: 00000000
             слот: A1_DIMM0
             Ρ€Π°Π·ΠΌΠ΅Ρ€: 4GiB
             Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 8 bits
             частота: 1066MHz (0.9ns)
        *-bank:1
             описаниС: DIMM DDR3 1066 MHz (0,9 ns)
             ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: 00000000
             ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Hynix Semiconductor
             физичСский ID:1
             сСрийный β„–: 00000000
             слот: A1_DIMM1
             Ρ€Π°Π·ΠΌΠ΅Ρ€: 4GiB
             Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 8 bits
             частота: 1066MHz (0.9ns)
     *-cache:0
          описаниС: L1 кэш
          физичСский ID:32
          слот: CPU Internal L1
          Ρ€Π°Π·ΠΌΠ΅Ρ€: 224KiB
          capacity:224KiB
          возмоТности: internal write-back
          конфигурация: level=1
     *-cache:1
          описаниС: L2 кэш
          физичСский ID:33
          слот: CPU Internal L2
          Ρ€Π°Π·ΠΌΠ΅Ρ€: 2MiB
          capacity:2MiB
          возмоТности: internal write-back unified
          конфигурация: level=2
     *-cpu
          описаниС: ЦПУ
          ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Intel(R) Atom(TM) x7-Z8750  CPU @ 1.60GHz
          ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Intel Corp.
          физичСский ID:34
          свСдСния о шинС: cpu@0
          вСрсия: Intel(R) Atom(TM) x7-Z8750 CPU @ 1.60GHz
          слот: SOCKET 0
          Ρ€Π°Π·ΠΌΠ΅Ρ€: 889MHz
          capacity:2560MHz
          Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 64 bits
          частота: 80MHz
          возмоТности: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp constant_tsc arch_perfmon pebs bts rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes rdrand lahf_lm 3dnowprefetch epb pti tpr_shadow vnmi flexpriority ept vpid tsc_adjust smep erms dtherm ida arat cpufreq
          конфигурация: cores=4 enabledcores=4 threads=4
     *-pci
          описаниС: Host bridge
          ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Intel Corporation
          ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Intel Corporation
          физичСский ID:100
          свСдСния о шинС: pci@0000:00:00.0
          вСрсия: 34
          Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 32 bits
          частота: 33MHz
          конфигурация: driver=iosf_mbi_pci
          рСсурсы: IRQ:0
        *-display
             описаниС: VGA compatible controller
             ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Intel Corporation
             ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Intel Corporation
             физичСский ID:2
             свСдСния о шинС: pci@0000:00:02.0
             вСрсия: 34
             Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 64 bits
             частота: 33MHz
             возмоТности: pm msi vga_controller bus_master cap_list rom
             конфигурация: driver=i915 latency=0
             рСсурсы: IRQ:123 ΠΏΠ°ΠΌΡΡ‚ΡŒ:a0000000-a0ffffff ΠΏΠ°ΠΌΡΡ‚ΡŒ:80000000-9fffffff ioport:f000(Ρ€Π°Π·ΠΌΠ΅Ρ€=64) ΠΏΠ°ΠΌΡΡ‚ΡŒ:c0000-dffff
        *-generic:0
             описаниС: Signal processing controller
             ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Intel Corporation
             ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Intel Corporation
             физичСский ID: b
             свСдСния о шинС: pci@0000:00:0b.0
             вСрсия: 34
             Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 64 bits
             частота: 33MHz
             возмоТности: msi pm cap_list
             конфигурация: driver=proc_thermal latency=0
             рСсурсы: IRQ:129 ΠΏΠ°ΠΌΡΡ‚ΡŒ:a1a3b000-a1a3bfff
        *-usb
             описаниС: USB controller
             ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Intel Corporation
             ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Intel Corporation
             физичСский ID:14
             свСдСния о шинС: pci@0000:00:14.0
             вСрсия: 34
             Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 64 bits
             частота: 33MHz
             возмоТности: pm msi xhci bus_master cap_list
             конфигурация: driver=xhci_hcd latency=0
             рСсурсы: IRQ:121 ΠΏΠ°ΠΌΡΡ‚ΡŒ:a1a00000-a1a0ffff
           *-usbhost:0
                ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: xHCI Host Controller
                ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Linux 4.15.0-rc7-stockmind-gpdpocket xhci-hcd
                физичСский ID:0
                свСдСния о шинС: usb@1
                логичСскоС имя: usb1
                вСрсия: 4.15
                возмоТности: usb-2.00
                конфигурация: driver=hub slots=7 speed=480Mbit/s
              *-usb:0
                   описаниС: ΠšΠ»Π°Π²ΠΈΠ°Ρ‚ΡƒΡ€Π°
                   ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Gaming Keyboard
                   ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: SINO WEALTH
                   физичСский ID:2
                   свСдСния о шинС: usb@1:2
                   вСрсия: 1.00
                   возмоТности: usb-1.10
                   конфигурация: driver=usbhid maxpower=100mA speed=1Mbit/s
              *-usb:1
                   описаниС: Π’ΠΈΠΏΠΎΠ²ΠΎΠΉ USB-Π½Π°ΠΊΠΎΠΏΠΈΡ‚Π΅Π»ΡŒ
                   ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: BCM2045A0
                   ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Broadcom Corp
                   физичСский ID:3
                   свСдСния о шинС: usb@1:3
                   вСрсия: 1.12
                   сСрийный β„–: B0F1ECED56A9
                   возмоТности: usb-2.00
                   конфигурация: driver=btusb maxpower=100mA speed=12Mbit/s
           *-usbhost:1
                ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: xHCI Host Controller
                ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Linux 4.15.0-rc7-stockmind-gpdpocket xhci-hcd
                физичСский ID:1
                свСдСния о шинС: usb@2
                логичСскоС имя: usb2
                вСрсия: 4.15
                возмоТности: usb-3.00
                конфигурация: driver=hub slots=6 speed=5000Mbit/s
        *-generic:1
             описаниС: Encryption controller
             ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Intel Corporation
             ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Intel Corporation
             физичСский ID:1a
             свСдСния о шинС: pci@0000:00:1a.0
             вСрсия: 34
             Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 32 bits
             частота: 33MHz
             возмоТности: pm msi bus_master cap_list
             конфигурация: driver=mei_txe latency=0
             рСсурсы: IRQ:130 ΠΏΠ°ΠΌΡΡ‚ΡŒ:a1900000-a19fffff ΠΏΠ°ΠΌΡΡ‚ΡŒ:a1800000-a18fffff
        *-pci
             описаниС: PCI bridge
             ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Intel Corporation
             ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Intel Corporation
             физичСский ID:1c
             свСдСния о шинС: pci@0000:00:1c.0
             вСрсия: 34
             Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 32 bits
             частота: 33MHz
             возмоТности: pci pciexpress msi pm normal_decode bus_master cap_list
             конфигурация: driver=pcieport
             рСсурсы: IRQ:117 ΠΏΠ°ΠΌΡΡ‚ΡŒ:a1000000-a14fffff
           *-network
                описаниС: БСспроводной интСрфСйс
                ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: BCM4356 802.11ac Wireless Network Adapter
                ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Broadcom Corporation
                физичСский ID:0
                свСдСния о шинС: pci@0000:01:00.0
                логичСскоС имя: wlp1s0
                вСрсия: 02
                сСрийный β„–: b0:f1:ec:ed:56:a8
                Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 64 bits
                частота: 33MHz
                возмоТности: pm msi pciexpress bus_master cap_list ethernet physical wireless
                конфигурация: broadcast=yes driver=brcmfmac driverversion=7.35.180.119 firmware=01-1a5c4016 ip=192.168.1.142 latency=0 multicast=yes wireless=IEEE 802.11
                рСсурсы: IRQ:125 ΠΏΠ°ΠΌΡΡ‚ΡŒ:a1400000-a1407fff ΠΏΠ°ΠΌΡΡ‚ΡŒ:a1000000-a13fffff
        *-isa
             описаниС: ISA bridge
             ΠΏΡ€ΠΎΠ΄ΡƒΠΊΡ‚: Intel Corporation
             ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ: Intel Corporation
             физичСский ID:1f
             свСдСния о шинС: pci@0000:00:1f.0
             вСрсия: 34
             Ρ€Π°Π·Ρ€ΡΠ΄Π½ΠΎΡΡ‚ΡŒ: 32 bits
             частота: 33MHz
             возмоТности: isa bus_master cap_list
             конфигурация: driver=lpc_ich latency=0
             рСсурсы: IRQ:0

lspci:

Hidden text
00:00.0Hostbridge: IntelCorporationDevice 2280 (rev 34)
00:02.0VGAcompatiblecontroller: IntelCorporationDevice 22b0 (rev 34)
00:0b.0Signalprocessingcontroller: IntelCorporationDevice 22dc (rev 34)
00:14.0USBcontroller: IntelCorporationDevice 22b5 (rev 34)
00:1a.0Encryptioncontroller: IntelCorporationDevice 2298 (rev 34)
00:1c.0PCIbridge: IntelCorporationDevice 22c8 (rev 34)
00:1f.0ISAbridge: IntelCorporationDevice 229c (rev 34)
01:00.0Networkcontroller: BroadcomCorporationBCM4356 802.11acWirelessNetworkAdapter (rev 02)

Build quality is good, no backlash, no creaks, no flex. Aluminum housing and in general, the device gives the impression of such a monolithic block. This is a plus.

But there are plenty of cons too. Glossy screen. No, it is not just glossy - it is literally a mirror. That is, you will see your reflection in the conditions of any non-zero light. In the kit was a protective film, but she did not solve the problem.

The second is the keyboard. What it is is wonderful. But how it is implemented is shame and horror. Attempt to roll under MacBook, with these hefty gaps between the buttons - well, why? After all, the target audience, it seems, is not a glamor kitty - they will just take another iped or macbook. Do not be these unfortunate intervals, the size of the keys could be made larger.





The Fn button has a very poor layer: these are 2 buttons for brightness adjustment, F1-F12 and Insert. Why do you need the top row? It could be implemented as a separate layer.

Particular pain and suffering among users of Vim is caused by a colon, placed in the bottom row, next to ctrl.

All right, everything is bad, we will treat, the benefit is there are some ways (about it below).

Oh yeah, there is a trackpoint. That to me, as an experienced ThinkPad user, heats the soul. Only here is one thing: the trackpoint is located completely in the wrong place and in order to use it, you will have to bend your thumb. This, unfortunately, is incurable. But for a couple of extra red caps in the kit, of course, thanks.

Trackpoint healthy person:


Trackpoint smoker:


Installing and configuring Linux on GPD Pocket


It is clear that β€œwindows”, and β€œwindows 10” especially, on this device is not something that I do not need, but simply contraindicated.

Because of the features of the device, such as the screen orientation (it is turned to the side), it’s just impossible to install and install your favorite Debian without dancing with a tambourine. In principle, the official site has the official image of Ubuntu LTS 16.04 (which seems to me a good alternative to stable Debian), but after reading the discussions on the Internet, it was decided to use the project GPD Pocket Ubuntu Respin I emphasize, in general, the obvious thing, that only an image built on Ubuntu is suitable for use and fed to a script, for example, Debian, will not work:







$./build.sh debian-9.3.0-amd64-netinst.iso
Display setting: Xorg-Standard
Looking for kernel image...
Extracting kernel files...
Archive:  gpdpocket-20180115-kernel-files.zip
  inflating: linux-headers-4.15.0-rc7-stockmind-gpdpocket_4.15.0-rc7-stockmind-gpdpocket-1_amd64.deb
  inflating: linux-image-4.15.0-rc7-stockmind-gpdpocket_4.15.0-rc7-stockmind-gpdpocket-1_amd64.deb
  inflating: linux-libc-dev_4.15.0-rc7-stockmind-gpdpocket-1_amd64.deb
./isorespin.sh: 'debian-9.3.0-amd64-netinst.iso' must be an Ubuntu (or Ubuntu flavour), Linux Mint, neon, elementary, BackBox or Peppermint desktop ISO.

At the output we get the file linuxium-xubuntu-16.04-desktop-amd64.iso, which we write on the USB flash drive:

#dd if=linuxium-xubuntu-16.04-desktop-amd64.iso of=/dev/sdX

We are loading from it, setting the boot device, going to the UEFI settings with the Delete button when loading.

The installation procedure is trivial, I can’t see the meaning of details. I will only note that it is better to produce it from the Live mode, so the screen will not be turned to the side.

I use full disk encryption in case the device is suddenly lost or stolen. So, at least, all your ssh-keys (yes, I know about password protection and ssh-agent) and logins on Internet resources will remain intact. Therefore, I put LVM on top of LUKS, which is what you want.

Fix the curvature


Sleep and Hibernation


It would be nice to be able to throw the laptop into the bag and forget about it until it is needed. Fortunately, the size and weight allow. It would be nice not to start up, every time, the necessary applications manually, but simply to continue working from the place where you stopped.

Sleep mode, like, works out-of-the-box. It is implemented by regular means, I mean through systemctl suspend. However, empirically, it was found that the power consumption in this mode is not much inferior to consumption in idle. Apparently, the device simply extinguishes the screen, network interfaces and disables the cooler. As a result, the battery will land at zero days for two.

Need hibernation. The standard hibernate systemctl turned out to be inoperable: the state is dumped into the swap, but it cannot recover when it is loaded.

I remembered that there is such a project - Userspace Software Suspend and there are its packages in the repository.

#apt install hibernate

Checking:

#hibernate-disk

Voila, it works! The system has been dumped and turned off. After entering the password LUKS, recovered. But the sound and wifi were covered, the brightness of the screen backlight was reset to the maximum. We will finish.

We need to install


Before proceeding to configure ACPI, you will need to install several utilities.

So xbacklight is responsible for adjusting the brightness of the screen.

#apt install xbacklight

The laptop is not a hard disk, but a flash drive, so I don’t want to kill it with a swap. There is such a thing ZRam , so we will use it. Now everything is simple with this, it is not necessary to prescribe sheets in rc.local, and you only need to do the following:

#apt install zram-config#sudo systemctl enable zram-config.service

The script itself will calculate the required amount of memory and make swapon.

As it was rightly reminded in the comments, the flash resource eats up not only the swap, but also the logging. Therefore, / tmp and / var / log will be rendered in ram to tmpfs. To do this, we add two lines in / etc / fstab:

tmpfs   /tmp         tmpfs   nodev,nosuid,size=256M          00
tmpfs   /var/log         tmpfs   nodev,nosuid,size=512M          00


We finish acpi


First of all, disable systemg handlers. So how does it all by its own means, and they are inoperable. The motto - we do everything, but we do it badly. For example, it did not learn how to handle the connection of the power adapter or headphones, keystrokes, and the like.

He ate acpid and still hungry! (4Mb)

/etc/systemd/logind.conf

HandlePowerKey=ignore
HandleLidSwitch=ignore

#systemctlrestartsystemd-logind.service

The acpid daemon is responsible for handling acpi-events; its config files are stored in / etc / acpi.

We will send the laptop to hibernation by pressing the power button. To do this, edit the following files (if they are not there, you need to create it):

/ etc / acpi / events / powerbtn

event=button[ /]power
action=/etc/acpi/hibernate.sh

/etc/acpi/hibernate.sh (with comments)

Hidden text
#!/bin/bash#ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π°ΡŽ свой скрипт Π±Π»ΠΎΠΊΠΈΡ€ΠΎΠ²ΠΊΠΈ экрана, Ρ‚Π°ΠΊ ΠΊΠ°ΠΊ ΠΏΡ€ΠΈ Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ΅ Π±ΡƒΠ΄Π΅Ρ‚ Π·Π°ΠΏΡ€ΠΎΡˆΠ΅Π½ ΠΏΠ°Ρ€ΠΎΠ»ΡŒ LUKS
mv /home/user/bin/lock  /home/user/bin/nolock 
#ΡƒΠ±ΠΈΠ²Π°Π΅ΠΌ пшшш-Π°ΡƒΠ΄ΠΈΠΎ
killall -9 pulseaudio
#ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π°Π΅ zram ΠΈ Π°ΠΊΡ‚ΠΈΠ²ΠΈΡ€ΡƒΠ΅ΠΌ swap
systemctl stop zram-config.service
swapon /dev/xubuntu-vg/swap_1
#сохраняСм состояниС подсвСтки экрана
DISPLAY=:0.0 su user -c "xbacklight >/tmp/xbl"#ΠΎΡ‚ΠΌΠΎΠ½Ρ‚ΠΈΡ€ΡƒΠ΅ΠΌ сСтСвыС Ρ„Π°ΠΉΠ»ΠΎΠ²Ρ‹Π΅ систСмы
umount -alt nfs4
umount -alt cifs
#усыпляСм wpa_supplicant
/sbin/wpa_cli suspend
hibernate-disk
sleep2#восстанавливаСм статус подсвСтки
DISPLAY=:0.0 su user -c "xbacklight -set `cat /tmp/xbl`"#восстанавливаСм wpa_supplicant
/sbin/wpa_cli resume#ΠΏΠ΅Ρ€Π΅Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΌΠΎΠ΄ΡƒΠ»ΠΈ alsa, ΠΈΠ½Π°Ρ‡Π΅ Π·Π²ΡƒΠΊΠ° Π½Π΅ Π±ΡƒΠ΄Π΅Ρ‚. пшш-Π°ΡƒΠ΄ΠΈΠΎ ΠΏΡ€ΠΈ Π²Ρ‹Π·ΠΎΠ²Π΅ восстановится ΡΠ°ΠΌΠΎΡΡ‚ΠΎΡΡ‚Π΅Π»ΡŒΠ½ΠΎ
/sbin/alsa force-reload
#звуковая систСма Π½ΠΎΡƒΡ‚Π° оставляСт ΠΆΠ΅Π»Π°Ρ‚ΡŒ Π»ΡƒΡ‡ΡˆΠ΅Π³ΠΎ. Π±Ρ‹Π»ΠΎ Π·Π°ΠΌΠ΅Ρ‡Π΅Π½ΠΎ, Ρ‡Ρ‚ΠΎ ΠΏΡ€ΠΈ Π±ΠΎΠ»ΡŒΡˆΠΈΡ… значСниях ΠΊΠ°Π½Π°Π»Π° DAC1, ΠΈΠ· Π΄ΠΈΠ½Π°ΠΌΠΈΠΊΠΎΠ² ΠΈ Π½Π°ΡƒΡˆΠ½ΠΈΠΊΠΎΠ² ΠΈΠ΄Π΅Ρ‚ Π΄ΠΈΠΊΠΈΠΉ ΠΏΠ΅Ρ€Π΅Π³Ρ€ΡƒΠ· Π΄ΠΎ Ρ…Ρ€ΠΈΠΏΠΎΡ‚Ρ‹ ΠΈ дрСбСзТания
amixer -c 1set'DAC1'90%
#ΡƒΠ±ΠΈΠ²Π°Π΅ΠΌ Π±Π»ΠΎΠΊΠΈΡ€ΠΎΠ²Ρ‰ΠΈΠΊ экрана Π½Π° случай, Ссли гибСрнация Π±Ρ‹Π»Π° Π·Π°ΠΏΡƒΡ‰Π΅Π½Π° ΠΏΡ€ΠΈ Π·Π°Π»ΠΎΡ‡Π΅Π½Π½ΠΎΠΌ экранС
killall i3lock
#восстанавливаСм Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ запуска Π±Π»ΠΎΠΊΠΈΡ€ΠΎΠ²Ρ‰ΠΈΠΊΠ°
mv /home/user/bin/nolock /home/user/bin/lock#восстанавливаСм zram
systemctl start zram-config.service
#ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π°Π΅ΠΌ своп Π½Π° ΠΊΠ°Ρ€Ρ‚Ρƒ
swapoff /dev/xubuntu-vg/swap_1

It is not easy to realize automatic hibernation at low charge, but very simple:

#apt install acpi

/etc/acpi/ifbatlowgotosleep.sh

#!/bin/bash
level=`/usr/bin/acpi -b|sed '/unava/d'|awk -F\  '{ print $4 }'|sed -e 's/,//' -e's/%//'`
if [ "$level" -lt "10" ]
    then
        /etc/acpi/hibernate.sh
    fi

The script checks the state of charge. If less than 10%, then the hibernation script given above performs.

Periodic execution is set via crontab:

$sudo crontab -e
*/3  *  * * * /etc/acpi/ifbatlowgotosleep.sh 2>/dev/null

In my case, the battery is polled every 3 minutes.

Sleep mode (systemctl suspend), as mentioned above, is rather useless. Therefore, I see no reason to activate it when the lid is closed. Moreover, there may be a desire, say, to listen to music from a gated laptop, located in a pocket (no wonder he is β€œpocket”).

Therefore, simply extinguish the screen when closing and turn on when opening.

Remove / etc / acpi / lidbtn.

Create and edit:

/ etc / acpi / events / lidclose:

event=button/lid LID close
action=/etc/acpi/lidclose.sh

/ etc / acpi / events / lidopen:

event=button/lid LID open
action=/etc/acpi/lidopen.sh

/etc/acpi/lidopen.sh

DISPLAY=:0.0 su user -c"xrandr --output DSI1 --off"

/etc/acpi/lidclose.sh

DISPLAY=:0.0 su user -c"xrandr --output DSI1 --auto --rotate right --dpi 200"

Set the DPI value to taste, and user is the simple name of my account (change to your own).

Adjust the sound and brightness control keys


We do this through all the same acpi-events.

/ etc / acpi / events / voldown

event=button[ /]volumedown
action=/etc/acpi/volume-down.sh

/ etc / acpi / events / volup

event=button[ /]volumeup
action=/etc/acpi/volume-up.sh

/ etc / acpi / events / mute

event=button[ /]mute
action=/etc/acpi/volume-toggle.sh

Scripts:

/etc/acpi/volume-toggle.sh

amixer -c1set 'SpeakerChannel' toggle
amixer -c1set 'HeadphoneChannel' toggle

/etc/acpi/volume-up.sh

amixer -c1set 'Headphone'5%+
amixer -c1set 'Speaker'5%+

/etc/acpi/volume-down.sh

amixer -c1set 'Headphone'5%-
amixer -c1set 'Speaker'5%-

Similarly for brightness:
/ etc / acpi / events / bdown

event=button[ /]brightnessdown
action=/etc/acpi/bdown.sh

/ etc / acpi / events / bup

event=button[ /]brightnessup
action=/etc/acpi/bup.sh

/etc/acpi/bup.sh

DISPLAY=:0.0 su user -c"xbacklight -inc 5%"

/etc/acpi/bdown.sh

DISPLAY=:0.0 su user -c"xbacklight -dec 5%"

Let me remind you, user is the name of my account. Enter your.

Headphones


Shit ^ WCSpeaky chip Realtek ALC5645 can not turn off the speakers when connecting headphones. We'll have to teach the system to do it yourself.

There is a script in respin:

Hidden text
#!/bin/bashset -e -u
if [ "$1" = "jack/headphone" -a "$2" = "HEADPHONE" ]; thencase"$3"in
        plug)
            sink="[Out] Headphones"
            ;;
        *)
            sink="[Out] Speaker"
            ;;
    esacfor userdir in /run/user/*; do
        uid="$(basename $userdir)"
        user="$(id -un $uid)"if [ -f "$userdir/pulse/pid" ]; then
            su "$user" -c "pacmd set-sink-port alsa_output.platform-cht-bsw-rt5645.HiFi__hw_chtrt5645__sink $sink"fidonefi

But it does not work. He is trying to make the switch through the control of the cine-audio cine-synks, but he fails. Because:

$sudo su
#su user -c "pacmd set-sink-port alsa_output.platform-cht-bsw-rt5645.HiFi__hw_chtrt5645__sink '[Out] Speaker'"
НСт Π·Π°ΠΏΡƒΡ‰Π΅Π½Π½ΠΎΠ³ΠΎ Π΄Π΅ΠΌΠΎΠ½Π° PulseAudio, Π»ΠΈΠ±ΠΎ ΠΎΠ½ Π½Π΅ Π·Π°ΠΏΡƒΡ‰Π΅Π½ Π² качСствС сСансового Π΄Π΅ΠΌΠΎΠ½Π°.

The answer is simple: when the pshsh-audio process is not yet called by the client, there is nothing to communicate with pacmd. You can, of course, add a line to launch this one in rc.local, xinitrc, or write a separate systemg unit at all, but I decided that it would be better to pull out my own crutch than repair others. And I wrote my script, much less monstrous and sophisticated, I think.

/etc/acpi/headphone-jack.sh

#!/bin/bashset -e -u
if [ "$3" = "plug" ]; then
	amixer -c 1 set'Speaker Channel' mute >/dev/null
	amixer -c 1 set'Headphone Channel' unmute >/dev/null
else 
	amixer -c 1 set'Speaker Channel' unmute >/dev/null
	amixer -c 1 set'Headphone Channel' mute >/dev/null
fi

We treat the layout and other little things


As already mentioned, the layout infuriates me. The delete button is where there should be backslash and bar, a colon in the bottom row, it’s not clear why the menu key is a tab, where the escape is on normal keyboards ...

I’ll not write out details, I’ll just give my own ~ / .xmodmaprc and I will describe how all this is done.

First, we need to catch keikod. This is done using the xev program (#apt install xev, yes). Run, press the desired key and get the output like:

KeyPress event, serial33, synthetic NO, window0x3200001,
    root 0x2c0, subw 0x0, time187713326, (979,493), root:(982,1078),
    state 0x0, keycode 119 (keysym 0xffff, Delete), same_screen YES,
    XLookupString gives 1 bytes: (7f) ""
    XmbLookupString gives 1 bytes: (7f) ""
    XFilterEvent returns: False

We need the value "keycode 119".

Next, open ~ / .xmodmaprc and write it there.

keycode119 = backslash bar backslash bar

And we bring the execution of "xmodmap ~ / .xmodmaprc" into your xinitrc or whatever you call when starting your favorite DE or WM.

My ~ / .xmodmaprc:

Hidden text
pointer = 1 2 3 4 5
remove Lock = Caps_Lock
remove Control = Control_L
keycode 0x42 = Control_L
keycode 135 = Alt_R
keycode 0x25 = Super_R
keycode 133 = Super_R
add Control = Control_L
keycode 113 = Left
keycode 111 = Up
keycode 114 = Right
keycode 116 = Down
keycode 110 = Home
keycode 115 = End
keycode	108 = ISO_Next_Group
keycode 136 = ISO_First_Group
keycode 49 = asciitilde grave asciitilde grave
keycode 119 = backslash bar backslash bar
keycode 51 = Delete
keycode 48 = colon semicolon Cyrillic_zhe Cyrillic_ZHE
keycode 47 = apostrophe quotedbl Cyrillic_e Cyrillic_E
keycode 130 = XF86Explorer
keycode 121 = XF86AudioMute
keycode 198 = XF86AudioMicMute
keycode 122 = XF86AudioLowerVolume
keycode 123 = XF86AudioRaiseVolume
keycode 37 = Tab
clear mod5
add mod5 = XF86Explorer
keycode 166 = Prior
keycode 167 = Next

They use such questionable, for most users, things like moving ctrl to caps-lock, tab to ctrl_l, alt_gr to menu and switching layouts to the old altgr position.

I also use xcape to emulate pressing escape when I press ctrl_l once. Called as follows:

xcape -t 1000 -e "Control_L=Escape"

Since I prefer dark themes that are more comfortable (I have an opinion, hell to challenge) in low light conditions, but often have to work in bright daylight, there is a small trick: you can invert the colors of the image. To do this, you need the xcalib program:

#apt install xcalib

Invert:

$xcalib -i -a

You can zabindit to any convenient hot key tools window manager. I'm hanging on Super_L + Backspace.

Total


Impressions of the device are more positive than negative. I do not regret the money spent. The device does not take up much space in the bag, it fits in the pocket of cargo pants and a smok-like jacket. It works for a long time from the battery, for the test I ran through three and a half hours films with wifi on, discharged about half. Charged from the paver with usb-a through the adapter ac. All encountered soft curvatures successfully treated. It is a pity that there is no rj45 port, but I hope it will be decided by the ordered adapter with usb. The lack of mobile communications and cameras, now, in conditions of total surveillance, I think rather a plus.







Read Next