なんか書いていこうぜー .com

Let's write something good

ThinkPad X1 Carbon に Arch Linux をインストールした

2016-11-08
  • Share on Facebook
  • Tweet
  • Add to Pocket

以前使っていた Macbook Air に入れていた Arch が動かなくなったのと、そろそろ新しい PC を買っても良さそうということで購入した。 全部ではないものの、備忘録として実行したコマンドを書いておく。

予め SD カードに Arch Linux のイメージを書き込んでおいて、USB 接続のカードリーダから起動している。

BIOS

起動時に Enter を押して BIOS 設定画面を呼び出す

  • secure bootを外す
  • boot の順番を変える

インストーラ挿して起動

$ ls /sys/firmware/efi/efivars

$ wifi-menu
# パスワードを入力してwifiに接続する
$ ping -c 3 google.co.jp

$ fdisk -l
# lsblk だと /dev/... が出ないので fdisk -l にした

$ gdisk /dev/sda
Command (? for help): o
Command (? for help): n
Permission number: 何も押さずエンター
First sector     : 何も押さずエンター
Last sector      : +512M
Hex code or GUID : EF00

# http://server.etutsplus.com/allocate-swap-space/ をみて 16 + 2 = 18Gに
Command (? for help): n
Permission number: 何も押さずエンター
First sector     : 何も押さずエンター
Last sector      : +18G
Hex code or GUID : 8200

Command (? for help): n
Permission number: 何も押さずエンター
First sector     : 何も押さずエンター
Last sector      : 何も押さずエンター
Hex code or GUID : 8300

Command (? for help): w
Do you want to proceed? (Y/N) Y
The operation has completed successfully.

# パーティション作成
$ mkfs.fat -F32 /dev/sda1
$ mkswap /dev/sda2
$ swapon /dev/sda2
$ mkfs.ext4 /dev/sda3

# パーティションのマウント
$ mkdir /mnt/boot
$ mount /dev/sda1 /mnt/boot
$ mount /dev/sda3 /mnt

# paclist の編集
$ vim  /etc/pacman.d/mirrorlist
# Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch を一番上にコピーした

# ベースシステムの導入
$ pacstrap /mnt base base-devel

# fstab の生成
$ genfstab -U /mnt >> /mnt/etc/fstab
# /,  /boot のオプションの最後に `, discard` を追加

$ ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
$ hwclock --systohc --utc

$ vi /etc/locale.gen
# en_US.UTF-8 UTF-8 と ja_JP.UTF-8 UTF-8 を uncomment
$ locale-gen 

# ホスト名の設定
$ echo muryoimpl-arch-tp > /etc/hostname
$ vi /etc/hosts
# 127.0.0.1 をコピーして、hostname の部分を↑のhostname に書き換える

# wifi-menu できるようにする
$ pacman -S dialog wpa_supplicant
$ pacman -S wpa_actiond

# root のパスワードを変更する
$ passwd

$ pacman -S grub efibootmgr
$ grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub --recheck
$ grub-mkconfig -o /boot/grub/grub.cfg

# マイクロコードのアップデートを有効にする
$ pacman -S intel-ucode
# マイクロコード自動アップデートに grub-mkconfig が対応しているらしいので再生成する
$ grub-mkconfig -o /boot/grub/grub.cfg

一般的なものをインストール

# yaourt 追加
$ vi /etc/pacman.conf
# [archlinuxfr]
# SigLevel = Never
# Server = http://repo.archlinux.fr/$arch
$ pacman --sync --refresh yaourt

$ pacman -S openssh
$ vi /etc/ssh/sshd_config
# PermitRootLogin no
# PasswordAuthentication no
$ systemctl start sshd.service
$ systemctl enable sshd.service

# systemd-journald のログサイズの制限
$ vim /etc/systemd/journald.conf
# SystemMaxUse=40M に書き換え
$ systemctl restart systemd-journald

$ pacman -S dkms
$ pacman -S zsh

$ useradd -m -G wheel -s /usr/bin/zsh muryoimpl
$ usermod -aG users muryoimpl # users グループに追加
$ passwd muryoimpl

$ pacman -S sudo
$ EDITOR=vim visudo
# %wheel      ALL=(ALL) ALL
$ chown -c root:root /etc/sudoers
$ chmod -c 0440 /etc/sudoers

$ yaourt linux-headers

$ ip addr # 無線インターフェースが出るか確認
$ sudo systemctl enable netctl-auto@wlp4s0.service

$ yaorut arandr

$ yaourt fprint
$ yaourt fingerprint-gui
$ sudo gpasswd -a muryoimpl plugdev

$  yaourt xf86-video-intel
# ↓のようなことを書くとよいと出た
# /etc/X11/xorg.conf.d/20-intel.conf
# Section "Device"
#    Identifier  "Intel Graphics"
#    Driver      "intel"
#    Option "DRI" "2"
#    # Option "AccelMethod"  "sna" # default
#    # Option "AccelMethod"  "uxa" # fallback
# EndSection

$ yaourt libxss

$ yaourt alsa-utils

# 電源管理
$ yaourt tlp 
$ yaourt tpacpi-bat
$ yaourt acpi_call
$ sudo systemctl start tlp.service
$ sudo systemctl enable tlp.service

# Bluetooth
$ yaourt bluez
$ yaourt bluez-utils
$ sudo modprobe btusb
$ sudo gpasswd -a muryoimpl lp

GUIの導入とか

$ yaourt tmux
$ yaourt lm_sensors

# ハイバネートとかサスペンドとか
$ sudo mkdir /etc/systemd/logind.conf.d/
$ sudo cp /etc/systemd/logind.conf /etc/systemd/login.conf.d/
$ sudo vim  /etc/systemd/login.conf.d/logind.conf
# HandleLidSwitch=hybrid-sleep

# swapへのSSDの書き込み回数を減らす
$ su -
$ echo 10 > /proc/sys/vm/swappiness

# lightdm
$ yaourt xorg-server
$ yaourt lightdm
$ yaourt lightdm-gtk-greeter
$ sudo vim /etc/lightdm/lightdm.conf
# [Seat:*]
# …
# greeter-session=lightdm-gtk-greeter
$ sudo systemctl enable lightdm.service

# awesome-wm
$ yaourt awesome
$ yaourt xorg-xinit
$ cp /etc/X11/xinit/xinitrc ~/.xinitrc
$ mkdir -p ~/.config/awesome/
$ cp /etc/xdg/awesome/rc.lua ~/.config/awesome/

$ yaourt ibus-mozc
$ yaourt ibus-uniemoji
$ yaourt fcitx-gtk2
$ yaourt fcitx-gtk3
$ yaourt fcitx-configtool

$ vim ~/.xprofile
# export GTK_IM_MODULE=fcitx
# export QT_IM_MODULE=fcitx
# export XMODIFIERS="@im=fcitx"
# export DefaultIMModule=fcitx
# fcitx &

$ yaout grub2-theme-archlinux
$ sudo vim /etc/defaults/grub
# GRUB_THEME="/boot/grub/themes/Archlinux/theme.txt"
$ sudo grub-mkconfig -o /boot/grub/grub.cfg

# その他
$ yaourt atom-editor-bin
$ yaourt xorg-xbacklight
$ yaourt xbindkeys

# 日本語フォント
$ yaourt ttf-ricty
$ echo LANG=ja_JP.UTF-8 > /etc/locale.conf
$ export LANG=ja_JP.UTF-8

# 時刻合わせ
$ yaourt ntp
$ sudo systemctl enable ntpd
$ sudo systemctl restart ntpd

# タッチパッドの設定
$ sudo vim /etc/X11/xorg.conf.d/70-synaptics.conf
# Section "InputClass"
#   Identifier "touchpad"
#   Driver "synaptics"
#   MatchIsTouchpad "on"
#
#   Option "VertTwoFingerScroll"  "on"
#   Option "HorizTwoFingerScroll" "on"
#   Option "EmulateTwoFingerMinZ" "40"
#   Option "EmulateTwoFingerMinW" "8"
#   Option "CoastingSpeed"        "0"
#   Option "FingerLow"            "30"
#   Option "FingerHigh"           "50"
#   Option "MaxTapTime"           "125"
#
#   # natural scroll
#   Option "VertScrollDelta"  >-"-111"
#   Option "HorizScrollDelta" >-"-111"
#
#   # 右クリックのエリアを拡大
#   Option "SoftButtonArea" "70% 0 50% 0 0 0 0 0"
# EndSection

ちょこちょこ弄っているのではあるけど、こんな感じで。 (無線LAN使うのに、dkms でドライバ入れる必要ないのは楽だなぁ…)