機械革命無界16
安裝Debian
一 選擇合適的Linux發行版
鑒於機械革命是一家PC二線小廠,硬件也比較新,所以選擇合適的Linux發行版較為困難,經過多種發行版的淺嘗輒止[安裝卸載]之后,筆者作為一個半路出家的小白,仍然選擇了Debian
這么一個發行版來學習,盡管它由於配置上的難度,一度勸退了我,兜兜轉轉之后筆者有了解決問題的信心,選擇了這個眾多發行版的基石版本,因為它的軟件包豐富,很多軟件都有deb
包,但缺乏rpm
包。詳細的版本是:Debian non-free 11.3(amd64)
,在中科大源下載的。
二 基本配置
2.1 換國內源
使用中科大鏡像源替換
# http://mirrors.ustc.edu.cn/help/debian.html
# http://mirrors.ustc.edu.cn/help/debian-security.html
# 備份一下 /etc/apt/sources.list
# 修改 /etc/apt/sources.list 的內容為如下內容
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
deb http://mirrors.ustc.edu.cn/debian-security/ stable-security main non-free contrib
# deb-src http://mirrors.ustc.edu.cn/debian-security/ stable-security main non-free contrib
# 最后更新一下,有問題按照提示解決問題。
sudo apt update
sudo apt upgrade
2.2 配置中文環境及輸入法
最開始安裝的時候,選的英文,所以后續需要配置中文環境,設置中文輸入法fcitx5並配置自動啟動。
fcitx5 im-config
fcitx5 可以設置在 i3 的配置文件中去啟動
配置中文環境
# 重新配置中文環境
➤ sudo dpkg-reconfigure locales
2.3 自動掛載win的硬盤
1)# 查看當前系統磁盤信息
➤ sudo fdisk -l 11:01:10
Disk /dev/nvme1n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: INTEL SSDPEKNW512G8
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0EFF2D18-CCB3-4C3B-8452-83499C9D8A99
Device Start End Sectors Size Type
/dev/nvme1n1p1 2048 1000215182 1000213135 476.9G Microsoft basic data
Disk /dev/nvme0n1: 953.87 GiB, 1024209543168 bytes, 2000409264 sectors
Disk model: ZHITAI PC005 Active 1TB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 657B17D6-761D-4976-B29D-9B39A9116A62
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 616447 614400 300M EFI System
/dev/nvme0n1p2 616448 649215 32768 16M Microsoft reserved
/dev/nvme0n1p3 649216 322682879 322033664 153.6G Microsoft basic data
/dev/nvme0n1p4 322682880 1371260927 1048578048 500G Microsoft basic data
/dev/nvme0n1p5 1371260928 1375455231 4194304 2G Linux filesystem
/dev/nvme0n1p6 1375455232 1564198911 188743680 90G Linux filesystem
/dev/nvme0n1p7 1564198912 1595656191 31457280 15G Linux filesystem
/dev/nvme0n1p8 1595656192 1679542271 83886080 40G Linux filesystem
/dev/nvme0n1p9 1679542272 1757136895 77594624 37G Linux filesystem
/dev/nvme0n1p10 1757136896 1790691327 33554432 16G Linux filesystem
2)# 去目標掛載目錄設置掛載點
tom@ccf:/m/tom
➤ ls
winc/ wind-soft/ wine-data/
3)# 手動掛載
sudo mount -t ntfs /dev/nvme0n1p3 /media/tom/winc
sudo mount -t ntfs /dev/nvme0n1p4 /media/tom/wind-soft
sudo mount -t ntfs /dev/nvme1n1p1 /media/tom/wine-data
# 報錯
NTFS signature is missing.
Failed to mount '/dev/nvme0n1p2': Invalid argument
The device '/dev/nvme0n1p2' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
# 安裝 fuse ntfs-3g
sudo apt install fuse
sudo apt install ntfs-3g
4)# 開機自動掛載磁盤 sudo vim /etc/fstab 可以使用 UUID 和 設備目錄兩種方式
# /media/tom/winc was on /dev/nvme0n1p3 during installation
/dev/nvme0n1p3 /media/tom/winc ntfs defaults 0 0
# /media/tom/wind-soft was on /dev/nvme0n1p4 during installation
/dev/nvme0n1p4 /media/tom/wind-soft ntfs defaults 0 0
# /media/tom/wine-data was on /dev/nvme1n1p1 during installation
/dev/nvme1n1p1 /media/tom/wine-data ntfs defaults 0 0
2.4 高分屏設置
sudo vim ~/.Xresources
# 寫入如下內容:
Xft.dpi: 200
屏幕設置的一些問題
# 筆者后來采用了 Xft.dpi: 200, 通過xrandr來設置屏幕的縮放比,在fish終端里面設置兩個別名
alias 85 'xrandr --output eDP-1 --scale 0.85x0.85'
alias 95 'xrandr --output eDP-1 --scale 0.95x0.95'
# 這么做的原因是遇到了BUG且筆者無法解決,只能繞行,BUG是設置在i3和fish終端的配置文件中,均會導致開機進入桌面黑屏只顯示光標,在查閱了諸多資料后均無法解決
# 設置別名之后,在終端輸入 85 之后,亦會導致黑屏,但是再開一個i3窗口[super+enter]就可以解決此問題。
三 驅動問題解決
3.1 升級內核
# 當前版本的Debian使用的內核比較老,不更新內核又不能適配我這個機器的無線網卡,那么就離線更新一下內核吧,從ubuntu內核離線更新的方法那邊借鑒了一下,於是乎去中科大的鏡像源[https://mirrors.ustc.edu.cn/debian/pool/main/l/linux/]下載了內核deb包,如下:
linux-headers-5.16.0-5-amd64_5.16.14-1_amd64.deb
linux-image-5.16.0-5-amd64-unsigned_5.16.14-1_amd64.deb
linux-headers-5.16.0-5-common_5.16.14-1_all.deb
# 然后手動安裝,重啟就完事了
sudo dpkg -i linux*
3.2 查看有那些驅動問題
查看內核信息,有哪些報錯,針對性的解決。
sudo dmesg | grep Error
sudo dmesg | grep Failed
3.3 解決無線網驅動問題
# 系統提示我,無線網卡缺少 iwlwifi-so-a0-hr-b0-xx.ucode
# 於是我就去了 https://www.kernel.org/ 找到了 https://mirrors.edge.kernel.org/pub/linux/kernel/firmware/
# 去下載一個新版的固件包,找到你想缺失的固件,比如:
iwlwifi-so-a0-hr-b0-64.ucode
# 把這個固件拷貝到 /lib/firmware 這個文件夾下面,重啟系統就好了
3.4 解決音頻/藍牙驅動問題
[ 7.645724] bluetooth hci0: firmware: failed to load intel/ibt-0040-4150.sfi (-2)
[ 7.645730] Bluetooth: hci0: Failed to load Intel firmware file intel/ibt-0040-4150.sfi (-2)
...
[ 7.767583] sof-audio-pci-intel-tgl 0000:00:1f.3: firmware: failed to load intel/sof/sof-adl.ri (-2)
[ 7.767599] sof-audio-pci-intel-tgl 0000:00:1f.3: Direct firmware load for intel/sof/sof-adl.ri failed with error -2
[ 7.767612] sof-audio-pci-intel-tgl 0000:00:1f.3: error: sof firmware file is missing, you might need to
[ 7.767619] sof-audio-pci-intel-tgl 0000:00:1f.3: download it from https://github.com/thesofproject/sof-bin/
[ 7.767624] sof-audio-pci-intel-tgl 0000:00:1f.3: error: failed to load DSP firmware -2
[ 7.767905] sof-audio-pci-intel-tgl 0000:00:1f.3: error: sof_probe_work failed err: -2
# 我這台機器缺少音頻以及藍牙驅動,先去找音頻,因為已經給出解決方案了,
# 注意!!!:一定要把我們下載的文件,放到指定目錄里,筆者一開始放到了 /lib/firmware 中,結果進不了桌面環境,然后從 recovery 模式,把文件重新放到了 /lib/firmware/intel/sof/ 下面就好了。
sudo cp sof-adl.ri /lib/firmware/intel/sof/
# 藍牙驅動文件,我們在之前下載好的固件包里面能找到,找不到就多去下載幾個包,總能找得到的,按照提示去放到 /lib/firmware/intel/ 下面
# 注意:筆者這邊也遇到了一個BUG,就是外接顯示器啟動的時候,進入桌面失敗了,后來拿下來外接顯示器之后,就成功了,雖然不知道為啥,但是問題不大。
3.5 解決intel
核顯驅動問題
# 查看 i915
tom@ccf:~$ sudo dmesg | grep i915
[ 2.040123] i915 0000:00:02.0: Your graphics device 4626 is not properly supported by the driver in this
kernel version. To force driver probe anyway, use i915.force_probe=4626
[ 68.656795] sof-audio-pci-intel-tgl 0000:00:1f.3: init of i915 and HDMI codec failed
# 參考 https://github.com/intel-gpu/documentation/issues/14
# 編輯 /etc/default/grub,添加如下內容
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.force_probe=4626"
# Then regenerate your grub boot loader:
# sudo grub2-mkconfig 如果是 紅帽 系使用這條命令,咱們 debian 使用下面這個
sudo update-grub
嘗試過多個發行版及桌面之后,最放不下的還是Debian
,最終也發現,還是這個debian cinnamon
解決了高分屏以及雙屏的問題,並且可以分別給雙屏設置縮放比,設置筆記本屏幕縮放比不為100%之后,也解決了之前高分屏主屏幕會有抖動現象的情況。解決了以上驅動問題之后,我們基本就可以愉快的使用Debian
了。
四 軟件之日常
4.1 瀏覽器Edge
不錯的瀏覽器,但是目前發現Linux版本的同步功能不行,win版本上的書簽不能完全同步,還是用優化更好的firefox吧。
## 安裝微軟的簽名密鑰和 sources.lst
sudo wget https://packages.microsoft.com/keys/microsoft.asc
sudo gpg --dearmor microsoft.asc
sudo mv microsoft.asc.gpg microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-stable.list'
sudo rm microsoft.asc microsoft.gpg
## 開始安裝 Micorsoft Edge Stable
sudo apt update
sudo apt install microsoft-edge-stable
4.2 截圖軟件 flameshot
# https://github.com/flameshot-org/flameshot
# 安裝
sudo apt install flameshot
# 基本使用之 Capture with GUI:
flameshot gui
# 用法有很多,github主頁都有介紹,或者使用 man 命令查看,咱們也可以設置一下快捷鍵
4.3 筆記軟件組合
使用堅果雲+obsidian+typora+騰訊雲COS
堅果雲
配置堅果雲
# https://www.jianguoyun.com/s/downloads/linux
# 咱們選擇 Debian 64-bit 然后按照官方教程來就好了
sudo dpkg -i nautilus_nutstore_amd64.deb
# 下面的命令我沒使用,應該是用來解決報錯的
sudo apt-get install -f
命令行啟動堅果雲
# 在更換了 i3 桌面之后,筆者的堅果雲就不能開機自動啟動了,咱們需要知道先知道在 fish 終端命令行如何啟動堅果雲
➤ bash -c "python3 ~/.nutstore/dist/bin/nutstore-pydaemon.py &"
# 咱們可以給他設置一個快捷鍵,輸入快捷鍵啟動
➤ alias nutstore 'bash -c "python3 ~/.nutstore/dist/bin/nutstore-pydaemon.py &"'
# 來個保存,以后就可以愉快的命令行使用堅果雲了
➤ funcsave nutstore
obsidian
強大的obsidian,用於在多平台、手機端方便的查看
# https://obsidian.md/
# 這個就不多說了,下載AppImage,設置為可執行文件,直接使用就好了
typora
易用的可視化markdown編輯器
# 這個不多說,現在是收費軟件了,免費的老版本請自行尋找。
# 捎帶提一句,筆者一開始使用英文版的時候,Image Uploader 選項是沒有app這個選項的,語言換成了漢語之后,出現了這個選項。
picgo
使用Picgo+騰訊雲圖床,避免免費的圖床突然不能使用
# 參考 https://zhuanlan.zhihu.com/p/119250383
4.4 錄屏軟件simplescreenrecorder
sudo apt install simplescreenrecorder
4.5 鍵盤捕捉screenkey
sudo apt install screenkey
五 軟件之開發
5.1 fish
# 安裝fish
sudo apt install fish
# 查看fish的位置
tom@ccf:~$ which fish
/usr/bin/fish
# 修改默認的終端,從bash改為fish
tom@ccf:~$ chsh -s /usr/bin/fish
# 安裝 fish 的插件 oh-my-fish # https://github.com/oh-my-fish/oh-my-fish#getting-started
curl -L https://get.oh-my.fish | fish
# 這樣fish就可以很容易修改終端樣式,在瀏覽器中就可以修改
fish_config
fish的使用
# fish下的好多操作都很便捷,比如可以直接命令行使用 alias
➤ alias c clear
# funcsave 給臨時設置的 alias 保存,下次啟動fish終端就可以使用了
➤ funcsave c
# 設置 l 為 ls -la
➤ alias l "ls -la"
➤ funcsave l
# 設置 sudo 為 "sudo -E",注:保存當前用戶的變量不被 sudo 所覆蓋
➤ alias sudo "sudo -E"
➤ funcsave sudo
fish兼容bash腳本
# 有很多腳本都是在bash下可以執行,fish不兼容,筆者網上找到了一個解決找辦法,https://segmentfault.com/a/1190000015253899
# 舉個栗子,比如,安裝rust之后,需要執行一句source 命令:
➤ source $HOME/.cargo/env
~/.cargo/env (line 4): 'case' builtin not inside of switch block
case ":${PATH}:" in
^
from sourcing file ~/.cargo/env
source: Error while reading file “/home/tom/.cargo/env”
# 咱們可以使用下面的命令來實現 fish 里面執行 bash 腳本
➤ bash -c "source $HOME/.cargo/env"
fish終端alias
➤ alias
alias 85 'xrandr --output eDP-1 --scale 0.85x0.85'
alias 95 'xrandr --output eDP-1 --scale 0.95x0.95'
alias c clear
alias l 'ls -la'
alias nutstore 'bash -c "python3 ~/.nutstore/dist/bin/nutstore-pydaemon.py &"'
alias sudo 'sudo -E'
alias typora /home/tom/Software/Typora-linux-x64/Typora
alias vpn /opt/cisco/anyconnect/bin/vpn
5.2 i3桌面環境
i3wm:窗口管理器
feh:設置桌面
compton:窗口透明化
polybar:狀態欄
# 安裝 i3 桌面環境
➤ sudo apt install i3
# 進入桌面配置
vim ~/.config/i3/config
feh
圖片查看器、設置桌面壁紙
# 安裝
➤ sudo apt install feh
# i3 config 中設置
compton
窗口透明化
# 安裝
➤ sudo apt install compton
# i3 config 中設置
exec compton -b
# 透明設置需要在終端中調整,這邊在alacritty中去設置
polybar
代替 i3 bar
# 安裝
➤ sudo apt install polybar
# i3 config 中設置
5.3 alacritty
5.3.1 安裝 rust
前提:安裝rust
➤ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 19:35:54
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
/home/tom/.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory located at:
/home/tom/.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
/home/tom/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile files located at:
/home/tom/.profile
/home/tom/.bashrc
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
warning: Updating existing toolchain, profile choice will be ignored
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
stable-x86_64-unknown-linux-gnu unchanged - rustc 1.59.0 (9d1b2106e 2022-02-23)
Rust is installed now. Great!
To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run:
source $HOME/.cargo/env
5.3.2 安裝 alacritty
# debian 的倉庫里面沒有 alacritty ,咱們去 github 上面
# https://github.com/alacritty/alacritty/blob/master/INSTALL.md#clone-the-source-code
# 根據文檔依次安裝,注意!!!!:一定要跟文檔的步驟和命令一致,筆者犯了一個低級錯誤,在 git clone 文件的時候,使用了 sudo 提權,導致文件全是root屬主和屬組,無法編譯
配置alacritty
# 如何在i3桌面中設置默認的終端為 alacritty 呢?
# 編輯 i3 配置文件
vim ~/.config/i3/config
"""
# start a terminal
# bindsym $mod+Return exec i3-sensible-terminal
bindsym $mod+Return exec alacritty
"""
5.4 ranger 終端文件管理器
# 非常好用的終端文件管理器,使用 hjkl 就可以輕松的管理鍵盤
sudo apt install ranger
基本使用
六 軟件之其他
6.1 Docker
docker 安裝
# 參考 https://yeasy.gitbook.io/docker_practice/install/debian
# 卸載舊版本
sudo apt-get remove docker docker-engine docker.io
# 使用 APT 安裝
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
# 添加國內源/軟件源的 GPG 密鑰
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# 向 sources.list 中添加 Docker 軟件源:
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 更新 apt 軟件包緩存,並安裝 docker-ce。
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
docker 配置
# 啟動 Docker
sudo systemctl enable docker
sudo systemctl start docker
# 建立 docker 用戶組
sudo groupadd docker
# 將當前用戶加入 docker 組:
sudo gpasswd -a $USER docker
# 更新docker用戶組
newgrp docker
七 尾聲
# 使用無界16安裝linux已基本可用,這東西就是會者不難,Linux不熟悉的小白撓頭,希望筆者半吊子的水平,能對苦苦搜索非主流PC/筆記本安裝linux的人有幫助。
# 筆者在折騰過程中對Arch產生了興趣,也對其他許多東西產生了興趣,借着疫情延遲入職失業在家的機會,正在學習vim和其他知識,早日給無界16裝上Arch。