###### tags: `Public`, `Technical`, `Configuration`, `Linux`, `Ubuntu`, `GPD Pocket 3`
# Ubuntu
## General Rule
- Hostname: `${PLATFORM}-${OS}-${'[[:digit:]][[:digit:]]'}` → `X79-Focal-00`
- Language: English
## Universal
### Auto Mount Disk
- Check target disk UUID
- `sudo blkid /dev/sde1 `
```/dev/sde1: UUID="e030f70e-3006-468e-8ca9-1c95ce63e14c" TYPE="ext4" PARTUUID="5717dfe0-01"```
- Add command to `/etc/fstab`
```UUID=e030f70e-3006-468e-8ca9-1c95ce63e14c /mnt/uv500_raid0 ext4 defaults 0 2```
### Git Config
- `git config --global user.email "user@gmail.com"`
- `git config --global user.name "User"`
- `git config --global core.editor vim`
### [Install Docker](https://hackmd.io/qtx67km3SsqvB6oxDlZVpA#Install-Docker-Engine-on-Ubuntu)
---
## Ubuntu 22.04 LTS (Jammy Jellyfish)
### Install Ubuntu Desktop Minimal on Ubuntu Server
- `sudo apt update`
- `sudo apt install ubuntu-desktop-minimal`
- `sudo reboot`
### Common
- `sudo apt update`
- `sudo apt install bash-completion`
## Ubuntu 20.04 LTS (Focal Fossa)
- [64-bit PC (AMD64) desktop image](https://releases.ubuntu.com/focal/ubuntu-20.04.3-desktop-amd64.iso)
- Minimal Installation
### Disk Partitions
Mount the following path to **different partition**.
Recommended use **different physical disk** in virtual machine.
- `/` - at least 128 GB
- EFI System Partition - 100 MB
- swap area - 2 GB
- `/var` - at least 256 GB for Docker
- `/home` - at least 128 GB
- Total: 512GB or more
### Drivers
#### Hyper-V
- [Supported Ubuntu virtual machines on Hyper-V](https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/supported-ubuntu-virtual-machines-on-hyper-v)
- `sudo apt install linux-azure`
- reboot
##### Change the Resolution of an Ubuntu Hyper-V Virtual Machine
- [x] Tested
- https://virtualizationreview.com/Blogs/Virtual-Insider/2014/09/change-ubuntu-resolution-on-hyper-v-vm.aspx
1. `sudo vim /etc/default/grub`
2. GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" -> GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1366x768"
3. `sudo update-grub`
##### Hyper-V Linux Guest VM Enhancements
- [ ] Tested
- [linux-vm-tools](https://github.com/z80020100/linux-vm-tools)
- [How to install Ubuntu 20.04 on Hyper-V with enhanced session](https://francescotonini.medium.com/how-to-install-ubuntu-20-04-on-hyper-v-with-enhanced-session-b20a269a5fa7)
- [Ubuntu 20.04 on Hyper-V](https://medium.com/@labappengineering/ubuntu-20-04-on-hyper-v-8888fe3ced64)
##### Downgrade Kernel version to compatibility with Synology Active Backup for Business
- `sudo apt install linux-image-5.4.0-1064-azure linux-headers-5.4.0-1064-azure`
- Find the list of kernels installed and the grub menu entries
- `sudo grub-mkconfig | grep -E 'submenu |menuentry '`
- `sudo vim /etc/default/grub`
- Comment `GRUB_DEFAULT=0`
- Add `GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-1064-azure"`
- `sudo update-grub`
- `sudo reboot`
#### VMware
- VMware Tools
- [x] Tested
- [How to install VMware Tools on Ubuntu 20.04 LTS Linux using command line](https://www.how2shout.com/linux/how-to-install-vmware-tools-on-ubuntu-20-04-lts-linux-using-command-line/)
- [安裝 Open VM Tools](https://docs.vmware.com/tw/VMware-Tools/11.3.0/com.vmware.vsphere.vmwaretools.doc/GUID-C48E1F14-240D-4DD1-8D4C-25B6EBE4BB0F.html)
- `sudo apt install open-vm-tools-desktop`
#### NVIDIA
##### Install NVIDIA driver
- `ubuntu-drivers devices`
```
WARNING:root:_pkg_get_support nvidia-driver-390: package has invalid Support Legacyheader, cannot determine support level
== /sys/devices/pci0000:00/0000:00:03.0/0000:04:00.0 ==
modalias : pci:v000010DEd00001C03sv00001462sd00003283bc03sc00i00
vendor : NVIDIA Corporation
model : GP106 [GeForce GTX 1060 6GB]
driver : nvidia-driver-390 - distro non-free
driver : nvidia-driver-418-server - distro non-free
driver : nvidia-driver-455 - third-party non-free
driver : nvidia-driver-470-server - distro non-free
driver : nvidia-driver-470 - third-party non-free recommended
driver : nvidia-driver-450 - third-party non-free
driver : nvidia-driver-450-server - distro non-free
driver : nvidia-driver-460-server - distro non-free
driver : nvidia-driver-460 - third-party non-free
driver : nvidia-driver-465 - third-party non-free
driver : xserver-xorg-video-nouveau - distro free builtin
```
- `sudo apt install nvidia-driver-470`
##### Remove all NVIDIA driver related packages
- `sudo apt purge nvidia*`
### Common
- `sudo apt update`
- `sudo apt install build-essential`
- Settings -> Region & Language -> Formats -> ~~United States~~ -> United Kingdom
- Settings -> Power -> Blank Screen -> Never
- `sudo apt install vim htop net-tools`
#### System Upgrade
- `sudo apt update`
- `sudo apt dist-upgrade`
- reboot
- `sudo apt clean`
- `sudo apt autoremove`
#### Users
##### Add User
- `sudo adduser $USER`
##### Add User to Group `sudo`
- `sudo adduser $USER sudo`
#### SSH
- `sudo apt install ssh` or `sudo apt install openssh-server`
#### Samba
- [Install and Configure Samba](https://ubuntu.com/tutorials/install-and-configure-samb)
- `sudo apt install samba`
- Add user for Samba
`sudo smbpasswd -a $USER`
- Setting up Samba
`sudo vim /etc/samba/smb.conf`
```
[homes]
comment = Home Directories
path = /home/%S
valid users = %S
writable = yes
browseable = yes
create mask = 0644
directory mask = 0755
```
- `sudo systemctl restart smbd`
#### Timeshift
- `sudo apt update`
- `sudo apt install timeshift`
#### Development Tools
- `sudo apt install git tig`
#### LAMP
- [How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-20-04)
- [How to Install a LAMP Stack on Ubuntu 20.04](https://www.linode.com/docs/guides/how-to-install-a-lamp-stack-on-ubuntu-20-04/)
##### Install Using Tasksel
- [x] Adopt
- `sudo apt update`
- `sudo apt install tasksel`
- `sudo tasksel install lamp-server`
- `sudo mysql_secure_installation`
##### Install Packages Separately
- Apache
- `sudo apt update`
- `sudo apt install apache2`
- `sudo ufw app list`
- `sudo ufw status`
- MySQL
- `sudo apt install mysql-server`
- `sudo mysql_secure_installation`
- PHP
- `sudo apt install php libapache2-mod-php php-mysql`
#### Database managemen
##### phpMyAdmin
- [How To Install and Secure phpMyAdmin on Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-20-04)
- Install phpMyAdmin
- `sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl`
- **For the server selection, choose `apache2`**
- When the prompt appears, **apache2** is highlighted, but **not** selected
- If you do not hit `SPACE` to select Apache, the installer will not move the necessary files during installation
- Hit `SPACE`, `TAB`, and then `ENTER` to select Apache
- Select Yes when asked whether to use dbconfig-common to set up the database
- You will then be asked to choose and confirm a MySQL application password for phpMyAdmin
- Configuring password access for a dedicated MySQL user
- ***NOTICE**: please change the **USER** and **PASSWORD** in the following command*
- `sudo mysql`
- `CREATE USER 'USER'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'PASSWORD';`
- `GRANT ALL PRIVILEGES ON *.* TO 'USER'@'localhost' WITH GRANT OPTION;`
- `exit`
##### Adminer
- [How to install Adminer on Ubuntu 20.04 LTS](https://danielfelix.in/blog/how-to-install-adminer-on-ubuntu-20-04-lts/)
- Installing Adminer
- `sudo apt update`
- `sudo apt install adminer`
- Configuring Adminer
- `sudo a2enconf adminer`
- `sudo systemctl reload apache2`
### Laptop
#### Disable suspend
- `sudo vim /etc/systemd/logind.conf`
- `HandleLidSwitch=ignore`
### GPD Pocket 3
#### Dual Boot with Windows 11
- Hostname: G1621-02-Focal
#### Issue[^2][^3][^4][^5]
##### Wrong Direction of Gravity Sensor
- `sudo apt update`
- `sudo apt install git`
- `git clone https://github.com/wimpysworld/umpc-ubuntu.git`
- `sudo cp ~/umpc-ubuntu/data/61-gpd-pocket3-sensor-local.hwdb /etc/udev/hwdb.d/`
- `sudo systemd-hwdb update`
- `sudo reboot`
##### Wrong Direction of Touch Screen
- `sudo cp ~/umpc-ubuntu/data/99-gpd-pocket3-touch.rules /etc/udev/rules.d/`
- `sudo udevadm control --reload-rules`
- `sudo udevadm trigger`
- `sudo reboot`
- It still does not work after following the above instructions so we delete the configuration file `/etc/udev/rules.d/99-gpd-pocket3-touch.rules` and reboot again. However, it works suddenly.
##### No Audio
- `sudo cp ~/umpc-ubuntu/data/alsa-gpd-pocket3.conf /etc/modprobe.d/`
##### Enable Display Scaling
- Settings -> Displays -> Enbale Fractional Scaling -> 175 %
##### Time Sync with Dual Boot Windows
- `sudo timedatectl set-local-rtc 1`
### DSM
#### Focal
- `sudo hostnamectl set-hostname DSM-Focal-00`
#### Jammy
- `sudo hostnamectl set-hostname DSM-Jammy-00`
- `sudo apt update && sudo apt dist-upgrade`
- `sudo apt install qemu-guest-agent`
### MacBook
#### Arm
##### Virtualization
- [Lima](https://github.com/lima-vm/lima)[^1]
- Multipass
- Parallels Desktop
##### Native
- [Asahi Linux](https://asahilinux.org/)
---
## Ubuntu 18.04.5 LTS (Bionic Beaver)
- [64-bit PC (AMD64) desktop image](https://releases.ubuntu.com/18.04.5/ubuntu-18.04.5-desktop-amd64.iso)
- Minimal Installation
### Common
- `sudo apt update`
- `sudo apt install build-essential`
- Settings -> Region & Language -> Formats -> ~~United States~~ -> United Kingdom
- Settings -> Power -> Blank Screen -> Never
- `sudo apt install vim htop net-tools`
#### System Upgrade
- `sudo apt upgrade`
- reboot
- `sudo apt autoclean`
- `sudo apt autoremove`
#### SSH
- `sudo apt install ssh` or `sudo apt install openssh-server`
#### Samba
- [Install and Configure Samba](https://ubuntu.com/tutorials/install-and-configure-samb)
- `sudo apt install samba`
- Add user for Samba
`sudo smbpasswd -a $USER`
- Setting up Samba
`sudo vim /etc/samba/smb.conf`
```
[homes]
comment = Home Directories
path = /home/%S
valid users = %S
writable = yes
browseable = yes
create mask = 0644
directory mask = 0755
```
### VMware
- VMware Tools
- Add CD/DVD Drive
- VM -> Install VMware Tools...
- mkdir -p ~/vmware_tools
- `cp /media/${USER}/VMware\ Tools/* ~/vmware_tools`
- `cd ~/vmware_tools`
- `tar -xvf VMwareTools-10.3.22-15902021.tar.gz`
- `cd vmware-tools-distrib`
- `sudo ./vmware-install.pl`
### NVIDIA Jetson Nano
- JetPack 4.6
- `sudo apt update`
- `sudo apt upgrade`
- System Settings -> Language Support -> Regional Formats -> English (United States)
- System Settings -> Brightness & Lock -> Turn screen off when inactive for: -> Never
## Notes
- [How to remove "Ubuntu" from Boot Menu after deleting Ubuntu partition in Windows 10 (Dual Boot)](https://askubuntu.com/questions/921046/how-to-remove-ubuntu-from-boot-menu-after-deleting-ubuntu-partition-in-windows)
## Issue
### Segmentation Fault with Specific URL in Ubuntu 20.04 (arm64)
- Detected it in Ubuntu 20.04 through Parallels Desktop on MacBook Pro 2021
```
cliff@PD-Focal:~$ curl https://dl.yarnpkg.com/debian/pubkey.gpg
Segmentation fault (core dumped)
```
```
cliff@PD-Focal:~$ wget https://dl.yarnpkg.com/debian/pubkey.gpg
--2022-02-22 15:22:36-- https://dl.yarnpkg.com/debian/pubkey.gpg
Resolving dl.yarnpkg.com (dl.yarnpkg.com)... 104.16.171.99, 104.18.126.100
Connecting to dl.yarnpkg.com (dl.yarnpkg.com)|104.16.171.99|:443... connected.
Segmentation fault (core dumped)
```
- Found [issue](https://github.com/curl/curl/issues/7932) on GitHub
- According to the above issue, it's confirmed that it's a OpenSSL issue
```
cliff@PD-Focal:~$ openssl s_client -showcerts -connect graph.facebook.com:443 </dev/null
CONNECTED(00000003)
Segmentation fault (core dumped)
```
```
cliff@PD-Focal:~$ openssl version -a
OpenSSL 1.1.1f 31 Mar 2020
built on: Wed Nov 24 13:20:48 2021 UTC
platform: debian-arm64
options: bn(64,64) rc4(char) des(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -fdebug-prefix-map=/build/openssl-ibbik6/openssl-1.1.1f=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_TLS_SECURITY_LEVEL=2 -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2
OPENSSLDIR: "/usr/lib/ssl"
ENGINESDIR: "/usr/lib/aarch64-linux-gnu/engines-1.1"
Seeding source: os-specific
```
- Solution: upgrade OpenSSL from 1.1.1f to the latest (1.1.1m)
#### Upgrade OpenSSL on Ubuntu 20.04 (arm64)
- `wget https://www.openssl.org/source/openssl-1.1.1m.tar.gz`
- `tar -xvf openssl-1.1.1m.tar.gz`
- `cd openssl-1.1.1m`
- `./config --prefix=/usr --openssldir=/usr/lib/ssl --libdir=/usr/lib/aarch64-linux-gnu`
- `make -j`
- `make test`
- `sudo make install`
- ~~`make install_engines`~~
- `sudo ldconfig -v`
```
cliff@PD-Focal:~$ openssl version -a
OpenSSL 1.1.1m 14 Dec 2021
built on: Tue Feb 22 15:00:41 2022 UTC
platform: linux-aarch64
options: bn(64,64) rc4(char) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DNDEBUG
OPENSSLDIR: "/usr/lib/ssl"
ENGINESDIR: "/usr/lib/aarch64-linux-gnu/engines-1.1"
Seeding source: os-specific
```
##### Undefined Symbol Issue
`undefined symbol: EVP_mdc2, version OPENSSL_1_1_0`
```
cliff@PD-Focal:~/openssl-1.1.1m$ ldd /usr/bin/openssl
linux-vdso.so.1 (0x0000ffffa7067000)
libssl.so.1.1 => /lib/aarch64-linux-gnu/libssl.so.1.1 (0x0000ffffa6eca000)
libcrypto.so.1.1 => /lib/aarch64-linux-gnu/libcrypto.so.1.1 (0x0000ffffa6c3c000)
libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000ffffa6c0c000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffffa6a99000)
/lib/ld-linux-aarch64.so.1 (0x0000ffffa7037000)
libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffffa6a85000)
```
[^1]: [jserv posted to FB at 2021/09/01](https://www.facebook.com/groups/system.software2021/posts/974622730047450/?__cft__[0]=AZU_7MCpVTrQUXsxRUPRP8Xxi8l2aR6WiddUP1YZHcr3N4oL7UuwKzaBby_3k6MCWiQkX-V47efqYDNEd9eT9Jp9fXkQTOqVAwxPV8rbZ5MOFVoI1LMw_UnsC8jkLLXi5nThQJ3RRALHqSD_MCJXA6A0&__tn__=%2CO%2CP-R)
[^2]: [UMPC hardware configuration for Ubuntu](https://github.com/wimpysworld/umpc-ubuntu)
[^3]: [一号本 OneMix3 Pro Ubuntu屏幕校正](https://badb100d.com/2020/11/16/2020-11-16/)
[^4]: [GPD pocket3(高配版)安装ubuntu 20.04并较完美运行](https://zhuanlan.zhihu.com/p/453971854?utm_source=qq&utm_medium=social&utm_oi=1462420603491409921)
[^5]: [GPD Pocket 3 and Ubuntu 20.04.3 - so far](https://www.reddit.com/r/GPDPocket/comments/s16p9v/gpd_pocket_3_and_ubuntu_20043_so_far/)