顯示具有 Gentoo 的使用 標籤的文章。 顯示所有文章
顯示具有 Gentoo 的使用 標籤的文章。 顯示所有文章

2023年11月29日 星期三

Gentoo 安裝 -- 2023

 ** 切記,裝好 kernel 和 grub 後,重開機前,一定要記得更改 root 的密碼。

從 1994 左右開始,自己的桌機,就一直是安裝 Gentoo Linux,至今快 20年了。這 20年中,硬體的效能進步好幾十倍,以前完全裝好要兩三天至一個星期,現在縮短到一兩天左右。

使用 Gentoo 的特點,每個 package 都要自行編譯後,才安裝,要花很多時間。這樣做有沒有必要呢? 到後來變成單純是樂趣吧,且可以透過它在編譯的過程中,學到許多 Linux 和 Open source 的作法,在效能上並不會有太大的影響。這次 (2023年 12月) 安裝,最顯著的差異是有所謂的 Distribution Kernel,不用自己設定 kernel 的選項。自己設定 kernel,常常會設定不正確,無法開機,或某些應用程式無法安裝或使用。

首先,要找個可開機的系統來進行安裝。例如使用 Ubuntu,在進入圖形的環境下,可以一邊上網看安裝指引,一邊進行安裝。

安裝前,要先規畫安裝 Gentoo Linux 的硬碟分割。以下是目前自己在用的系統,硬碟的使用情形。

# df -h
檔案系統             容量   已用  可用  已用% 掛載點
/dev/root           98G   48G   46G   52% / 
/dev/nvme1n1p4     354G  167G  169G   50% /home

使用 500GB PCIe SSD 的分割情形 

                               Disk: /dev/nvme0n1
             Size: 477 GiB, 512110190592 bytes, 1000215216 sectors
          Label: gpt, identifier: FEA1EFAE-49CD-45B9-A15B-5A5EF9069055

    所用裝置              Start        結束       磁區    Size 類型
    /dev/nvme0n1p1         2048        6143       4096      2M BIOS boot        
    /dev/nvme0n1p2         6144      313343     307200    150M EFI System
    /dev/nvme0n1p3       313344    21284863   20971520     10G Linux swap
    /dev/nvme0n1p4     21284864   231000063  209715200    100G Linux filesystem
    /dev/nvme0n1p5    231000064  1000215182  769215119  366.8G Linux filesystem

目前大部份的 Linux 都使用 systemd,使用  "eselect profile" 選擇 profile 時,可以只選擇 "systemd",儘快裝好一個空的系統,確認可以重新開機。merged-usr,是指 bin, lib, lib64, sbin 等目錄都和 usr 下的目錄合併,不再分開。

雖然現在的 SSD 很快,如 nvme ssd 更是快,但和 DRAM 比起來,仍然比較慢。為了提昇 emerge 套件的速度,並且避免頻繁寫入 SSD,在記憶體也夠大時,在安裝過程可以使用 tmpfs 。emerge 過程,檔案是放在 /var/tmp/portage 的目錄下,在 chroot 中,需手動 mount tmpfs,指令如下。注意,tmpfs 的大小,一般不宜超過一半的記憶體。

# mount -t tmpfs -o size=4G,uid=portage,gid=portage,mode=755 /var/tmp/portage
有時,要暫時修改 tmpfs 的大小,可以執行下面的指令。
# mount -o remount,size=4G,noatime /tmp

在圖形界面,目前都用 lightdm 登入,並且在 USE flags 加上 "cjk",讓它支援中文。這時候,大概得等到裝好一個輕量級的 Xfce 桌面,才能比較方便的使用新裝好的 OS。這過程,大概要一天吧,還是先用 Ubuntu,進 chroot 繼續後面的安裝步驟,直到有 xfce 可用。

在開機前,要裝好 grub,編好 kernel,更改管理者密碼。常常忘了設定管理者密碼,又要重新 chroot 一次,設定密碼。

更改 host name 的方式如下,便於分辨在那台機器上。

hostnamectl set-hostname aj-i9

裝好的系統,可以在 /etc/fstab 中,加上 tmpfs 的掛載,可以自行參考網路資料。https://wiki.gentoo.org/wiki/Portage_TMPDIR_on_tmpfs

可以安裝 app-portage/cpuid2cpuflags,來偵測 CPU_FLAGS_X86 flags,然後將其加入 /etc/portage/make.conf 中。

在 /etc/portage/make.conf 中,我會加的設定。
ABI_X86="64 32";同時支援 64位元和32位元的程式庫,因為我會用 32 位元的 WINE。
GRUB_PLATFORMS="efi-64 pc";grub 同時安裝 efi 和 dos。

LINGUAS="zh_TW";中文的環境
L10N="zh-TW zh-CN"

INPUT_DEVICES="evdev keyboard mouse";X window 的設定
VIDEO_CARDS="vesa nouveau nv"
ALSA_CARDS="hda-intel"

設定時區

# echo "Asia/Taipei" > /etc/timezone
# emerge --config sys-libs/timezone-data
再來,修改 /etc/locale.gen,然後執行 locale-gen,產生 locale。
en_US ISO-8859-1
en_US.UTF-8 UTF-8
 zh_TW.UTF-8 UTF-8

zh_TW BIG5
zh_CN.UTF-8 UTF-8
zh_CN GB2312

IP 設定

注意,要先執行 systemd-machine-id-setup,建立 machine ID,journal 才會正常運作,service 才會正常起動,網路也才會起來。

建立檔案 /etc/systemd/network/50-wired.network

[Match]
Name=eno1
[Network]
Address=10.61.86.133/20
Gateway=10.61.80.1

[Address]
Label=eno1:1
Address=10.161.86.133/20
DHCP
[Match]
Name=enp*

[Network]
DHCP=yes

然後,設定服務
systemctl enable systemd-networkd.service
systemctl start systemd-networkd.service

Note that systemd-networkd does not update resolv.conf by default. To have systemd manage the DNS settings, replace resolv.conf with a symlink and start systemd-resolved.

ln -snf /run/systemd/resolve/resolv.conf /etc/resolv.conf
systemctl enable systemd-resolved.service
systemctl start systemd-resolved.service 

設定時區 (使用 systemd)
# timedatectl set-timezone Asia/Taipei
# timedatectl set-ntp yes
# timedatectl set-local-rtc no


大概就這些吧。

手動設定 IP:
ip addr add 10.1.1.2/16 dev eth1
ip link set eth1 up

安裝 kernel 及設置 grub2

先安裝 sys-kernel/gentoo-kernel-bin,可以很快的裝系統重新開機。假如要重裝 sys-kernel/gentoo-kernel,必須要先 emerge -W gentoo-kernel-bin,再 emerge -av gentoo-kernel。這樣會先移除 gentoo-kernel-bin,因為兩者不能同時安裝。

 * Messages for package sys-kernel/gentoo-kernel-6.1.60:

 * Your configuration for sys-kernel/gentoo-kernel-6.1.60 has been saved in 
 * "/etc/portage/savedconfig/sys-kernel/gentoo-kernel-6.1.60" for your editing pleasure.
 * You can edit these files by hand and remerge this package with
 * USE=savedconfig to customise the configuration.
 * You can rename this file/directory to one of the following for
 * its configuration to apply to multiple versions:
 * ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/
 * [${CTARGET}|${CHOST}|""]/${CATEGORY}/[${PF}|${P}|${PN}]


grub,參考 https://wiki.centos.org/zh-tw/HowTos/Grub2

使用 BIOS 時,執行 grub-install --target=i386-pc /dev/nvme0n1 安裝 bootloader。使用 EFI 的話,有點小複雜,就先不折騰了。

產生選單前,可以設定 /etc/default/grub,我習慣的設定如下。

# 預設的開機,儲存在 /boot/grub/grubenv 中的 saved_entry
GRUB_DEFAULT=saved
# 顯示全部的開機選項
GRUB_DISABLE_SUBMENU=y
# 不要建立復原開機選項
GRUB_DISABLE_RECOVERY="true"
# Boot with systemd instead of sysvinit (openrc)
GRUB_CMDLINE_LINUX="init=/usr/lib/systemd/systemd"

其中,GRUB_CMDLINE_LINUX 那一行一定要設,不然使用 lightdm 登入 xfce 後,會不正常。

在 kernel 建好之後,直接下 make install 指令,即可將 kernel 的 image複製到 /boot 下。執行指令 grub-mkconfig -o /boot/grub/grub.cfg,建立開機選單。

注意,假如是把硬碟拔到別的電腦上 install 或 update,一定要在使用的機器上執行此指令,才能建立正確的 grub.cgf,不然會抓到不正確的硬碟資訊,重新開機時,會無法 mount root disk。

執行 awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub/grub.cfg,列出開機時顯示的選單列表。
0 : Gentoo GNU/Linux,採用 Linux 4.9.16-gentoo
1 : Gentoo GNU/Linux,採用 Linux 4.9.16-gentoo.old
2 : Gentoo GNU/Linux,採用 Linux 4.4.52-gentoo.good
3 : Gentoo GNU/Linux,採用 Linux 4.4.52-gentoo
4 : Gentoo GNU/Linux,採用 Linux 4.4.52-gentoo.old

執行 grub-set-default 3,設定預設開機選項為 3。
執行 grub-editenv list,顯示儲存的設定如下
saved_entry=3

假如是升級 kernel,在使用 eselect 設定新的 kernel 後,要重新安裝相關的 package,不然會進不了圖形界面和 VM。

emerge -av x11-drivers/nvidia-drivers app-emulation/vmware-modules

其他安裝

確定可以正常開機後,先裝個基本的圖形介面,emerge -av xorg-server xterm twm,就可以進入 X window。這樣,只需幾個小時,就有視窗可用了,然後再裝其他的 package。

若是已有可用的視窗系統,就不用急,把所有的東西都裝好,再切換過去。

常用小工具

xfce4-notes-plugin
The notes are stored as text files in $XDG_DATA_HOME/notes/ (~/.local/share/notes by default).
The settings are in $XDG_CONFIG_HOME/xfce4 (~/.config/xfce4/xfce4-notes.*).
xfce4-clipman-plugin, 要安裝 x11-themes/gnome-icon-theme, 才會出現圖示

x11-themes/gnome-icon-theme 的 icon,還被一些應用程式使用,如 smb4k 及 krusader 等,不能隨便移除。

Brave browser 的 overlay -- another-brave-overlay

修改 tmpfs 的大小

How to change tmpfs partition size in Linux ( RHEL / CentOS 7 )

原來的 tmpfs 大小,把 RAM 都吃光了,要調小一點。
----------------
檔案系統        容量  已用  可用 已用% 掛載點
/dev/root        98G   28G   66G   30% /
devtmpfs        5.8G     0  5.8G    0% /dev
tmpfs           5.8G  507M  5.3G    9% /dev/shm
tmpfs           5.8G  1.2M  5.8G    1% /run
tmpfs           5.8G     0  5.8G    0% /sys/fs/cgroup
tmpfs           5.8G  140K  5.8G    1% /tmp
/dev/nvme0n1p5  361G   53G  290G   16% /home
none            4.0G     0  4.0G    0% /var/tmp/portage
tmpfs           1.2G   28K  1.2G    1% /run/user/1000
----------------

在 /etc/fstab 加入
tmpfs /tmp tmpfs rw,nosuid,noatime,nodev,size=4G,mode=1777 0 0

然後下指令
mount -o remount /tmp

LightDM 無法啟動

Create a new file called nvidia.conf in the /etc/modules-load.d directory. It should contain the NVIDIA module name:

FILE /etc/modules-load.d/nvidia.conf
nvidia
nvidia_modeset
nvidia_drm
確保在啟動 lightdm 之前,載入 nvidia_drm 的 kernel module

連接網芳

使用 gvfs,可在 Thunar 使用 "smb://servername/share" 來連接網芳的分享磁碟。

修改 /etc/samba/smb.conf,才能連 Windows 2003 ~ 2019 的網芳,不然會出現 "Failed to mount Windows share" 的訊息

----------------------------------------
  client min protocol=NT1
  client max protocol=SMB3
  ntlm auth = yes
----------------------------------------

在安裝 gnome-base/gvfs,use flag 要加上 fuse (Enables fuse mount points in $HOME/.gvfs for legacy application access)。Gentoo 則是放在 $XDG_RUNTIME_DIR/gvfs 的目錄下,其中 XDG_RUNTIME_DIR=/run/user/1000。

------------------------------------------------
 $ ls /run/user/1000/gvfs
'smb-share:server=10.161.86.149,share=wwwroot'
------------------------------------------------

音效

必須以普通使用者的身份,啟動 pulseaudio.service。控制界面,需安裝 media-sound/pavucontrol (Pulseaudio Volume Control, GTK based mixer for Pulseaudio)。

$ systemctl --user start pulseaudio
$ systemctl --user status pulseaudio

$ systemctl --user enable pulseaudio
Created symlink /home/ajax/.config/systemd/user/default.target.wants/pulseaudio.service → /usr/lib/systemd/user/pulseaudio.service.
Created symlink /home/ajax/.config/systemd/user/sockets.target.wants/pulseaudio.socket → /usr/lib/systemd/user/pulseaudio.socket.
2026-01-23,改用 PipeWire 了。
要完全停用 pulseaudio.socket pulseaudio.service,和啟用 pipewire-pulse.socket , pipewire.service,wireplumber。

無法開機 error: file /boot/intel-uc.img not found

Immediate Fix (Temporary Boot)

  • When the GRUB menu appears, highlight your desired boot entry and press the e key to edit it.
  • Navigate to the line that contains /boot/intel-uc.img or a similar microcode reference. It often looks like "initrd /boot/intel-uc.img /boot/initramfs-...."
  • Delete the part of the line that refers to the missing microcode file, leaving only the reference to your main initramfs file (e.g., initrd /boot/initramfs-5.4-x86_64.img).
  • Press Ctrl+X or F10 to boot with the modified entry. 

Permanent Fix

1. Install or Reinstall the Microcode Package
------
sudo emerge --ask sys-firmware/intel-microcode
 (Ensure the 'initramfs' USE flag is enabled for the package if you want it in a separate image file.)

------
2. Update Your Bootloader Configuration 
---------
sudo grub-mkconfig -o /boot/grub/grub.cfg
---------

VMware-Workstation

gentoo ~ # emerge --config vmware-workstation


Configuring pkg...

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.12/emerge", line 57, in main
    retval = emerge_main()
             ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/_emerge/main.py", line 1308, in emerge_main
    return run_action(emerge_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/_emerge/actions.py", line 3876, in run_action
    return action_config(
           ^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/_emerge/actions.py", line 758, in action_config
    retval = portage.doebuild(
             ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/portage/package/ebuild/doebuild.py", line 1218, in doebuild
    rval = _prepare_env_file(mysettings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/portage/package/ebuild/doebuild.py", line 1686, in _prepare_env_file
    env_extractor.start()
  File "/usr/lib/python3.12/site-packages/_emerge/AsynchronousTask.py", line 34, in start
    self._start()
  File "/usr/lib/python3.12/site-packages/_emerge/BinpkgEnvExtractor.py", line 43, in _start
    env=self.settings.environ(),
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/portage/package/ebuild/config.py", line 3378, in environ
    raise AssertionError(
AssertionError: LC_ALL=zh_TW.UTF-8 for posixish locale. It seems that split_LC_ALL was not called for phase config?
gentoo ~ # unset LC_ALL
gentoo ~ # emerge --config vmware-workstation


Configuring pkg...

Network settings database seems to be invalid,configuring default settings
Configuring Bridged network vmnet0
Configuring hostonly network vmnet1, probing for unused subnet ...
Configuring NAT network vmnet8, probing for unused subnet ...
Configured default networks - Bridged, Hostonly, NAT

gentoo ~ # 


V




2023年7月19日 星期三

Linux - 透過 Flatpak 使用 Application

Gentoo,參考 https://wiki.gentoo.org/wiki/Flatpak,ArchLinux,也差不多。系統更新後,flatpak 也要 update,不然有的程式,如 PrusaSlicer 會怪怪的。

按照 Wiki 的說明安裝完成,重新開機後,試著安裝和執行 Package。

----------------

$ flatpak update
正在尋找更新...

無事可做。
$ gsettings get org.gnome.desktop.interface gtk-theme
'HighContrast'

$ flatpak install flathub org.gtk.Gtk3theme.HighContrast
正在尋找符合項目…
錯誤: No remote refs found for ‘flathub’

$  flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

$ flatpak install flathub org.gtk.Gtk3theme.HighContrast正在尋找符合項目…
錯誤: flathub 遠端沒有項目符合 org.gtk.Gtk3theme.HighContrast

$ flatpak install flathub com.prusa3d.PrusaSlicer
正在尋找符合項目…
com.prusa3d.PrusaSlicer/x86_64/stable (runtime/org.freedesktop.Platform/x86_64/21.08) 所要求的執行時期環境在 flathub 遠端中有找到
您想要安裝嗎? [Y/n]: 

com.prusa3d.PrusaSlicer permissions:
    ipc               network          x11                devices
    file access [1]   dbus access [2]  bus ownership [3]  system dbus access [4]

    [1] /media, /run/media, home, xdg-run/gvfs
    [2] com.prusa3d.prusaslicer.InstanceCheck.*,
        org.freedesktop.DBus.Introspectable.*
    [3] com.prusa3d.prusaslicer.*
    [4] org.freedesktop.UDisks2


        ID                                            分支   Op 遠端    下載
 1. [✓] com.prusa3d.PrusaSlicer.Locale                stable i  flathub  10.6 MB / 10.6 MB
 2. [✓] org.freedesktop.Platform.GL.default           21.08  i  flathub 129.6 MB / 129.8 MB
 3. [✓] org.freedesktop.Platform.GL.nvidia-525-125-06 1.4    i  flathub 415.2 MB / 415.2 MB
 4. [✓] org.freedesktop.Platform.Locale               21.08  i  flathub 144.0 MB / 326.8 MB
 5. [✓] org.freedesktop.Platform.VAAPI.Intel          21.08  i  flathub  11.8 MB / 11.9 MB
 6. [✓] org.freedesktop.Platform.openh264             2.0    i  flathub   1.5 MB / 1.5 MB
 7. [✓] org.freedesktop.Platform                      21.08  i  flathub 155.8 MB / 202.3 MB
 8. [✓] com.prusa3d.PrusaSlicer                       stable i  flathub  67.5 MB / 68.5 MB

安裝完成。

$ flatpak run com.prusa3d.PrusaSlicer
--------------------------------------------------------------------------
Message: 10:29:15: Starting PrusaSlicer flatpak with entrypoint script
--------------------------------------------------------------------------

$ [2023-07-20 10:29:15.408172] [0x00007f7f4c22dd40] [trace]   Initializing StaticPrintConfigs
Gtk-Message: 10:29:15.416: Failed to load module "canberra-gtk-module"
[2023-07-20 10:29:17.494827] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Zonestar.idx when loading bundle Zonestar. Going to search for it in cache folder.
[2023-07-20 10:29:17.498202] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/BIBO.idx when loading bundle BIBO. Going to search for it in cache folder.
[2023-07-20 10:29:17.503602] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Snapmaker.idx when loading bundle Snapmaker. Going to search for it in cache folder.
[2023-07-20 10:29:17.506831] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Trimaker.idx when loading bundle Trimaker. Going to search for it in cache folder.
[2023-07-20 10:29:17.509011] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Anker.idx when loading bundle Anker. Going to search for it in cache folder.
[2023-07-20 10:29:17.510935] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/RatRig.idx when loading bundle RatRig. Going to search for it in cache folder.
[2023-07-20 10:29:17.514338] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/MakerGear.idx when loading bundle MakerGear. Going to search for it in cache folder.
[2023-07-20 10:29:17.524208] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Artillery.idx when loading bundle Artillery. Going to search for it in cache folder.
[2023-07-20 10:29:17.528303] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Voron.idx when loading bundle Voron. Going to search for it in cache folder.
[2023-07-20 10:29:17.564913] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Templates.idx when loading bundle Templates. Going to search for it in cache folder.
[2023-07-20 10:29:17.579916] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/gCreate.idx when loading bundle gCreate. Going to search for it in cache folder.
[2023-07-20 10:29:17.586573] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Print4Taste.idx when loading bundle Print4Taste. Going to search for it in cache folder.
[2023-07-20 10:29:17.587819] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Elegoo.idx when loading bundle Elegoo. Going to search for it in cache folder.
[2023-07-20 10:29:17.591829] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/TriLAB.idx when loading bundle TriLAB. Going to search for it in cache folder.
[2023-07-20 10:29:17.605191] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Ultimaker.idx when loading bundle Ultimaker. Going to search for it in cache folder.
[2023-07-20 10:29:17.607750] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Geeetech.idx when loading bundle Geeetech. Going to search for it in cache folder.
[2023-07-20 10:29:17.631185] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Creality.idx when loading bundle Creality. Going to search for it in cache folder.
[2023-07-20 10:29:17.667837] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Rigid3D.idx when loading bundle Rigid3D. Going to search for it in cache folder.
[2023-07-20 10:29:17.672664] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Anycubic.idx when loading bundle Anycubic. Going to search for it in cache folder.
[2023-07-20 10:29:17.687543] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/BIQU.idx when loading bundle BIQU. Going to search for it in cache folder.
[2023-07-20 10:29:17.690856] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/INAT.idx when loading bundle INAT. Going to search for it in cache folder.
[2023-07-20 10:29:17.695248] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Jubilee.idx when loading bundle Jubilee. Going to search for it in cache folder.
[2023-07-20 10:29:17.697763] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Infinity3D.idx when loading bundle Infinity3D. Going to search for it in cache folder.
[2023-07-20 10:29:17.702944] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/LulzBot.idx when loading bundle LulzBot. Going to search for it in cache folder.
[2023-07-20 10:29:17.704932] [0x00007f7f4c22dd40] [error]   Missing index /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/FLSun.idx when loading bundle FLSun. Going to search for it in cache folder.

(prusa-slicer:8): Gtk-WARNING **: 10:29:18.334: Negative content width -8 (allocation 10, extents 9x9) while allocating gadget (node entry, owner GtkEntry)

(prusa-slicer:8): Gtk-WARNING **: 10:29:18.334: Negative content width -8 (allocation 10, extents 9x9) while allocating gadget (node entry, owner GtkEntry)

(prusa-slicer:8): Gtk-CRITICAL **: 10:29:18.379: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar

(prusa-slicer:8): Gtk-WARNING **: 10:29:18.390: Negative content width -8 (allocation 10, extents 9x9) while allocating gadget (node entry, owner GtkEntry)

(prusa-slicer:8): Gtk-WARNING **: 10:29:18.390: Negative content width -8 (allocation 10, extents 9x9) while allocating gadget (node entry, owner GtkEntry)

** (prusa-slicer:8): WARNING **: 10:29:41.583: atk-bridge: get_device_events_reply: unknown signature
sh: 列 1: xdg-mime:指令找不到
[2023-07-20 10:29:45.510275] [0x00007f7f4c22dd40] [error]   Couldn't locate idx file /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/PrusaResearch.idx when performing updates.
[2023-07-20 10:29:45.510724] [0x00007f7f4c22dd40] [error]   Couldn't locate idx file /home/ajax/.var/app/com.prusa3d.PrusaSlicer/config/PrusaSlicer/cache/vendor/Templates.idx when performing updates.
-----------------

執行結果如下圖。

執行效果比使用 AppImage 好一些,會安裝相關的檔案,不用自己亂試少了什,或有什麼不相容的。原在在 Xfce 下執行 gtk3 的 Prusa Slicer 的 AppImage,半透明部分會整個透空,無法使用。如下圖,畫面整個亂掉。


-------------------
$ flatpak install flathub com.microsoft.Edge
正在尋找符合項目…
com.microsoft.Edge/x86_64/stable (runtime/org.freedesktop.Platform/x86_64/22.08) 所要求的執行時期環境在 flathub 遠端中有找到
您想要安裝嗎? [Y/n]: 

com.microsoft.Edge permissions:
    ipc             network         cups              pcsc
    pulseaudio      wayland         x11               devices
    file access [1] dbus access [2] bus ownership [3] system dbus access [4]
    tags [5]

    [1] /run/.heim_org.h5l.kcm-socket, host-etc, xdg-desktop, xdg-documents,
        xdg-download, xdg-music, xdg-run/pipewire-0, xdg-videos,
        ~/.local/share/applications:create, ~/.local/share/icons:create
    [2] com.canonical.AppMenu.Registrar, org.freedesktop.FileManager1,
        org.freedesktop.Notifications, org.freedesktop.ScreenSaver,
        org.freedesktop.secrets, org.gnome.Mutter.IdleMonitor.*,
        org.gnome.SessionManager, org.kde.kwalletd5
    [3] org.mpris.MediaPlayer2.edge.*
    [4] org.freedesktop.Avahi, org.freedesktop.UPower
    [5] proprietary


        ID                                        分支            Op     遠端        下載
 1. [✓] org.freedesktop.Platform.GL.default       22.08           i      flathub     142.9 MB / 143.1 MB
 2. [✓] org.freedesktop.Platform.GL.default       22.08-extra     i      flathub      16.2 MB / 143.1 MB
 3. [✓] org.freedesktop.Platform.Locale           22.08           i      flathub      38.2 MB / 333.4 MB
 4. [✓] org.freedesktop.Platform.VAAPI.Intel      22.08           i      flathub      13.3 MB / 13.4 MB
 5. [✓] org.freedesktop.Platform.openh264         2.2.0           i      flathub     887.2 kB / 944.3 kB
 6. [✓] org.freedesktop.Platform                  22.08           i      flathub     156.3 MB / 214.4 MB
 7. [✓] com.microsoft.Edge                        stable          i      flathub     154.8 MB / 153.9 MB

安裝完成。
-------------------

在 Visual Studio Code 啟動 OpenSCAD

要預覽 scad 檔,無法啟動 flatpak 下的 openscad,必須另建一個 shell 檔,openscad_flatpak.sh

--------------
#!/bin/bash
flatpak run org.openscad.OpenSCAD "$@"
--------------

另外,flatpak 的沙箱機制,程式無法讀到其他根目錄下的檔案,必須特別授權。

例如在 openscad 要開啟 /home2 目錄下的檔,會出錯

---------
Failed to open file /home2/ajax/3d-print/ikea_leg_stable.scad: No such file or directory
---------

要針對 home2 執行下列指令

---------
flatpak override --user org.openscad.OpenSCAD --filesystem=/home2
---------

可安裝 Flatseal 來管理

--------
flatpak install com.github.tchx84.Flatseal
---------

中文輸入,倉頡輸入法

https://forum.gamer.com.tw/C.php?bsn=60599&snA=45335







2022年12月21日 星期三

新電腦安裝 (Gentoo) - 2022年12月


----------------------
比較執行 time emerge  portage 所花的時間

## 原來的電腦
CPU: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (family: 0x6, model: 0x9e, stepping: 0xc)

real 0m32.807s
user 0m23.179s
sys 0m12.093s

## 新的電腦
CPU: 11th Gen Intel(R) Core(TM) i7-11700 @ 2.50GHz (family: 0x6, model: 0xa7, stepping: 0x1)

real 0m12.307s
user 0m9.705s
sys 0m3.753s
----------------------


2022年5月15日 星期日

改用中文輸入法

 gtk3 改了一堆東西,gcin 無法編譯,我可沒能力修改啊。只好找其他的輸入工具了。

比較了幾種,fcitx 是比較好的,但是倉頡輸入沒辦法看到輸入的字根,只好放棄。

​fictx

https://wiki.gentoo.org/wiki/Fcitx


emerge -av app-i18n/fcitx


export XMODIFIERS="@im=fcitx"

export QT_IM_MODULE=fcitx

export GTK_IM_MODULE=fcitx

您正在 GUI 下執行 Fcitx,但找不到 fcitx-configtool,該套件名稱通常為 fcitx-config-gtx、fcitx-config-gtk3 或 fcitx-configtool。現在將使用預設文字編輯器開啟設定檔。

安裝設定工具

emerge -av app-i18n/fcitx-configtool  

安裝新酷音

emerge -av app-i18n/fcitx-chewing

安裝一堆輸入法,包括倉頡3代和倉頡5代

emerge -av app-i18n/fcitx-table-extra


ibus

https://wiki.gentoo.org/wiki/IBus

 emerge -av app-i18n/ibus

export XMODIFIERS=@im=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus

ibus-daemon -drx

emerge -av app-i18n/ibus-cangjie

masked
app-i18n/ibus-chewing

注音包含在拼音裡,但是會當掉,以後再來試吧
emerge -av app-i18n/ibus-pinyin

切換至注音,按鍵之後,會出現下面的錯誤,然後就變成英文了
(mousepad:291507): IBUS-WARNING **: 17:03:24.648: Process Key Event failed: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code18: 這個連線已關閉.

改装這個就可以了
emerge -av app-i18n/ibus-libpinyin

其實要能顯示輸入的字根,必須要另有程式處理。fictx 直接用 table 對應,就無法顯示字根了。而這部分,中國大陸沒在用,也很難溝通的樣子,就沒有人做了。

2021年4月16日 星期五

使用 scrcpy 操作手機 (Gentoo)

先來張擷圖,可以透過電腦來操作手機,是蠻方便的,而且可以在 Linux 下使用。

Gentoo 官方的 portage 沒有 scrcpy 這軟體,必須找 overlay 的 ebuild。

安裝好後,第一次執行

ajax@aj-i7 ~ $ scrcpy
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
exec: No such file or directory
ERROR: Command not found: [adb], [push], [/usr/share/scrcpy/scrcpy-server], [/data/local/tmp/scrcpy-server.jar]
ERROR: (make 'adb' accessible from your PATH or define its fullpath in the ADB environment variable)
INFO: You may install 'adb' by "apt install adb"
ERROR: Could not execute "adb push"

找不到 adb 指令,關於 Gentoo 的 adb 說明: Android/adb

安裝 dev-util/android-tools package 之後再執行

ajax@aj-i7 ~ $ scrcpy
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
* daemon not running; starting now at tcp:5037
* daemon started successfully
adb: error: failed to get feature set: no devices/emulators found
ERROR: "adb push" returned with value 1

需要在手機開啟 USB debug,這個無需 root,一般是在 [系統資訊] 的某個項目上點 7下,就會出現開發者選項。

再次執行

ajax@aj-i7 ~ $ scrcpy
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
/usr/share/scrcpy/scrcpy-server: 1 fil...shed. 1.3 MB/s (34930 bytes in 0.025s)
[server] INFO: Device: samsung SM-A315G (Android 10)
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.IllegalStateException
	at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
	at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2789)
	at com.genymobile.scrcpy.ScreenEncoder.encode(ScreenEncoder.java:113)
	at com.genymobile.scrcpy.ScreenEncoder.internalStreamScreen(ScreenEncoder.java:94)
	at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:60)
	at com.genymobile.scrcpy.Server.scrcpy(Server.java:80)
	at com.genymobile.scrcpy.Server.main(Server.java:252)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:342)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 460.56
INFO: Trilinear filtering enabled
INFO: Initial texture: 1080x2400
WARN: Device disconnected

還是不行,但只差一步了,指令要加解析度

ajax@aj-i7 ~ $ scrcpy -m 1080
INFO: scrcpy 1.17 <https://github.com/Genymobile/scrcpy>
/usr/share/scrcpy/scrcpy-server: 1 fil...shed. 5.6 MB/s (34930 bytes in 0.006s)
[server] INFO: Device: samsung SM-A315G (Android 10)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 460.56
INFO: Trilinear filtering enabled
INFO: Initial texture: 488x1080
  ==> 連上手機,開啟手機螢幕視窗
....
  ==> 關閉手機螢幕視窗
WARN: Killing the server...


旋轉90度的指令 "scrcpy -m 1080  --lock-video-orientation 1"


使用 appimage

 media-sound/jack2





2021年3月6日 星期六

Gentoo 與 GeForce 9500 GT

[  189.317025] nvidia-nvlink: Nvlink Core is being initialized, major device number 245
[  189.317618] NVRM: The NVIDIA GeForce 9500 GT GPU installed in this system is
               NVRM:  supported through the NVIDIA 340.xx Legacy drivers. Please
               NVRM:  visit http://www.nvidia.com/object/unix.html for more
               NVRM:  information.  The 455.28 NVIDIA driver will ignore
               NVRM:  this GPU.  Continuing probe...
[  189.317642] NVRM: No NVIDIA graphics adapter found!
[  189.317927] nvidia-nvlink: Unregistered the Nvlink Core, major device number 245


 [I] x11-drivers/nvidia-drivers
     Available versions:  ~390.132-r4(0/390)^mtd 390.138-r4(0/390)^mtd 435.21-r6(0/435)^mtd 440.100-r2(0/440)^mtd 450.80.02(0/450)^mtd 455.28(0/455)^mtd ~455.38(0/455)^mtd {+X compat +driver gtk3 +kms +libglvnd multilib static-libs +tools uvm wayland ABI_MIPS="n32 n64 o32" ABI_S390="32 64" ABI_X86="32 64 x32" KERNEL="FreeBSD linux"}
     Installed versions:  455.28(0/455)^mtd(03時17分06秒 西元2020年11月13日)(X driver gtk3 kms libglvnd multilib tools wayland -compat -static-libs -uvm ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="32 64 -x32" KERNEL="linux -FreeBSD")
     Homepage:            https://www.nvidia.com/Download/Find.aspx
     Description:         NVIDIA Accelerated Graphics Driver


[I] sys-firmware/nvidia-firmware
     Available versions:  (~)340.32-r1^md
     Installed versions:  340.32-r1^md(17時50分07秒 西元2021年02月15日)
     Homepage:            https://nouveau.freedesktop.org/wiki/VideoAcceleration/
     Description:         Kernel and mesa firmware for nouveau (video accel and pgraph)

2020年5月10日 星期日

Gentoo - 安裝在 ASUS VivoBook 14

辦公室為了疫情異地辦公買了筆電,ASUS VivoBook 14 - x412f。現在的筆電都強迫中獎,安裝微軟的 OS,這年代是裝 Windows 10。其實微軟早就強迫學校按人頭買了 Windows 作業系統的授權,這等於是剝兩次皮。

不過,我只想用 Linux,只有在用 Words 文件才回 Windows。

備份原 Windows OS

以前都用 Ghost 來備份/還原系統,現在找不到 Ghost 了。在網路上找到使用 Linux 備份磁碟的分割區的作法,使用的是 Ubuntu 20。

原來筆電的分割區
                          Disk: /dev/nvme0n1
         Size: 476.96 GiB, 512110190592 bytes, 1000215216 sectors
       Label: gpt, identifier: 709EF8B9-4D28-4BF4-8326-A960661C0460

Device         Start    End   Sectors  Size Type
/dev/nvme0n1p1  2048 534527 532480  260M EFI System  
/dev/nvme0n1p2 534528 567295 32768   16M Microsoft reserved
/dev/nvme0n1p3 567296  998881934 998314639  476G Microsoft basic data
/dev/nvme0n1p4 998883328 1000214527 1331200  650M Windows recovery environ

首先要備份磁碟的 patition table,此磁碟採用 gpt 分割表,備份說明如下
## Backup GPT table
dd if=/dev/sda of=GPT_TABLE bs=1 count=A

## Restore GPT table
dd if=GPT_TABLE of=/dev/sdb bs=1 count=A
partprobe /dev/sdb 
其中 A 為:
A=(128*B)+1024
# B 為分割區的數目
B=parted -ms /dev/sda print |tail -1|cut -b1

# parted -ms /dev/nvme0n1 print | tail -1 | cut -b1
=> 4 => B (總共4個分割區)

A = 128*4+1024 = 1536 (計算出的 count 值)

實際備份的指令
# 備份 GPT partition table
dd if=/dev/nvme0n1  of=GPT_TABLE bs=1 count=1536
# 依續備份4個分割區,使用 lz4 壓縮
dd if=/dev/nvme0n1p1 bs=1M status=progress | lz4 > ./nvme0n1p1.lz4
## 列出備份的檔案 # ls -lh
total 38G
-rw-r--r-- 1 root root 1.5K May  4 04:01 GPT_TABLE
-rw-r--r-- 1 root root  18M May  4 04:03 nvme0n1p1.lz4
-rw-r--r-- 1 root root  17M May  4 04:04 nvme0n1p2.lz4
-rw-r--r-- 1 root root  37G May  4 04:27 nvme0n1p3_nz.lz4
-rw-r--r-- 1 root root 494M May  4 06:00 nvme0n1p4.lz4


安裝 Gentoo Linux

BIOS 有做一些修改
Security boot,改 disable,不然 EFI 會無法啟動
SATA mode ,改ACHI,不然在 Linux 下看不到硬碟

原打算從頭安裝,照著說明,安裝到可以啟動 OS,也裝好 Xorg Server,這樣一天就過去了,離可以正常使用還好久。

後來把筆電帶回家,依照上述方法,把家裡使用的 Gentoo Linux 的 partition table 和 root system 備份出來,然後還原到筆電。還原指令如下,
lz4 -dc nvme0n1p4.lz4 | dd of=/dev/nvme0n1p4 bs=1M status=progress
nvme0n1p4 為主要的系統分割區,壓縮檔約 70GB,還好 copy 到隨身碟的速度夠快,搞到半夜終於可以進入系統了。

不過,因為只複製主系統的分割區,啟動區的 kernel,在主系統上沒有對應的 driver module,因此無法正常開機。重新編譯後就可以正常了。

為此特別買了 USB 的網卡,使用的晶片為 Realtek 的螃蟹卡 RTL 8153,產品描述「Integrated 10/100/1000m Ethernet controller for usb applications」,是專為 USB 開發的晶片。要 enable Kernel 的設定 CONFIG_USB_RTL8152,資訊如下


CONFIG_USB_RTL8152:

This option adds support for Realtek RTL8152 based USB 2.0
10/100 Ethernet adapters and RTL8153 based USB 3.0 10/100/1000
Ethernet adapters.

To compile this driver as a module, choose M here: the
module will be called r8152.

Symbol: USB_RTL8152 [=y]
Type : tristate
Prompt: Realtek RTL8152/RTL8153 Based USB Ethernet Adapters
Location:
-> Device Drivers
-> Network device support (NETDEVICES [=y])
-> USB Network Adapters (USB_NET_DRIVERS [=y])
Defined at drivers/net/usb/Kconfig:99
Depends on: NETDEVICES [=y] && USB_NET_DRIVERS [=y]
Selects: MII [=y]


無線網路的晶片為 "Realtek Semiconductor Co., Ltd. RTL8822CE 802.11ac PCIe Wireless Network Adapter",其 driver 為 rtw88 和 rtwpci。


Touchpad 的驅動

已經習慣使用 Trackpoint 當滑鼠,所以使用外接的 ThinkPad 鍵盤。但筆電攜帶方便,不想一直使用外接鍵盤。直到某天沒外接鍵盤,發現滑鼠竟然不會動,花了好久的功夫才弄起來。在 Ubuntu 下可以正常運作,就互相比對,看是那裡的問題。後來發現 Asus 是使用 Elan (義隆) 的 TouchPad 模組,透過 I2C 界面連接。除了要有 Touchpad 的 driver,還必須有 I2C 的 driver。

使用 lspci -k 來檢視PCI界面使用的驅動程式,在我的 Gentoo 中,這個裝置沒有對應的 driver。
00:15.0 Serial bus controller [0c80]: Intel Corporation Serial IO I2C Host Controller
        Subsystem: ASUSTeK Computer Inc. Serial IO I2C Host Controller
00:15.1 Serial bus controller [0c80]: Intel Corporation Device 02e9
        Subsystem: ASUSTeK Computer Inc. Device 1de1


在 Ubuntu 中的 driver 如下
00:15.0 Serial bus controller [0c80]: Intel Corporation Serial IO I2C Host Controller
        Subsystem: ASUSTeK Computer Inc. Serial IO I2C Host Controller
        Kernel driver in use: intel-lpss
        Kernel modules: intel_lpss_pci
00:15.1 Serial bus controller [0c80]: Intel Corporation Comet Lake Serial IO I2C Host Controller
        Subsystem: ASUSTeK Computer Inc. Device 1de1
        Kernel driver in use: intel-lpss
        Kernel modules: intel_lpss_pci

在 Kernel 中把 intel_lpss_pci enable 之後,就成功驅動 i2c 控制器,Touchpad 可以正常運作了。後面的設定就較簡單了。

Touchpad 的 tap-to-click

Many users will desire the native 'tap-to-click" behavior for laptops with modern touchpads. Add the following Option lines to Xorg's libinput configuration section.
修改 /etc/X11/xorg.conf.d/40-libinput.conf
Section "InputClass" Identifier "libinput touchpad catchall" MatchIsTouchpad "on" MatchDevicePath "/dev/input/event*" Option "NaturalScrolling" "True" (scroll 方向同手指方向) Option "Tapping" "True" Option "TappingDrag" "True" Option "TappingButtonMap" "lmr" (enable middle click) Driver "libinput" EndSection


網誌存檔