LoginSignup
6
8

More than 5 years have passed since last update.

2018年 ArchLinuxで開発環境を作る完全版 (UEFI + GNOME3 + GRUB) - 開発環境構築編

Last updated at Posted at 2018-05-28

タイムゾーンを変更する

sudo timedatectl set-timezone Asia/Tokyo

ディレクトリの日本語を英語に変える (変えたい人だけ)

LANG=C
xdg-user-dirs-gtk-update
exec $SHELL -l

GNOMEの画面端でウィンドウが拡大するのを無効にする

gsettings set org.gnome.shell.overrides edge-tiling false

Git, rxvt, chrome, firefoxなど色々インストール

sudo pacman -S colordiff git tmux rake zip unrar wget rxvt-unicode
yaourt -S google-chrome firefox-i18n-ja alsa-utils flashplugin jdk xclip urxvt-perls

pacaurの導入

gpg --recv-keys 487EACC08557AD082088DABA1EB2638FF56C0C53
yaourt -S pacaur

GNOME Shell Extensionsインストール

GNOME 標準ブラウザのWEBでアクセスしてインストールしてください

SSDの設定

TRIM のサポートを確認する

sudo hdparm -I /dev/sda |grep TRIM
#        *    Data Set Management TRIM supported (limit 1 block)
#        *    Deterministic read data after TRIM

マウントフラグで TRIM を有効にする

  • /etc/fstab のエントリで discard オプションを使うことで TRIM コマンドが有効になります
  • /etc/fstab のエントリで noatimeオプションを使うことで ファイルに関連付けられた atime 情報の更新によるファイルシステムの読み込みアクセスの記録が止められます
sudo vim /etc/fstab

# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/sda2
UUID=d9077062-b419-4870-929e-7a7811e5d2c2   /           ext4        rw,noatime,discard,data=ordered 0 1

# /dev/sda1
UUID=A1E3-304D          /boot       vfat        rw,noatime,discard,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 2

# /dev/sda3
UUID=5e14d79a-a492-40b9-b11a-38a6dff81343   /home       ext4        rw,noatime,discard,data=ordered 0 2

SSD のスワップ領域

sudo vim /etc/sysctl.d/99-sysctl.conf

vm.swappiness=1
vm.vfs_cache_pressure=50

頻繁に使うファイルを RAM に移動する

yaourt -S profile-sync-daemon

Jetbrains-toolbox のインストール

yaourt -S jetbrains-toolbox 

Neovim のインストール

sudo pacman -S neovim
sudo pacman -S python2-neovim python-neovim python-pip
mkdir -pv ~/.config/nvim
sudo pacman -S ctags
pacaur -S global

指紋認証の設定 (Thinkpad X250 の指紋認証を有効にする)

指紋認証機能搭載ノートPCをお使いの方も

lsusb
sudo pacman -S fprintd
sudo fprintd-enroll username # usernameは各自のユーザー名へ置き換え
sudo systemctl enable fprintd
sudo systemctl start fprintd

DropboxとOnedriveのインストール

sudo pacman -S dropbox
yaourt -S onedrive-git

ユーザー用の設定ファイルをディレクトリ掘ってセットする

mkdir -pv ~/.config/onedrive
# 初回起動。単純に以下のコマンドを実行。
onedrive
  • すると以下のような感じで一旦ブラウザから認証する必要がある。
  • Authorize this app visiting: に表示されてるURLにアクセスする。
  • 別のURLにリダイレクトされるので、アドレスバーからコピー。
  • コピーしたURLを Enter the response url: のところに入力する
  • というながれ。認証が通ればそのまま同期が開始される。ただこの時点では同期されたことが確認できたら一旦 Ctrl+C とかで一旦中断する。

最後に自動起動の設定。
AUR経由で入れた場合、既に /usr/lib/systemd/user/ 配下に onedrive.service ファイルが設置されるので素直に systemd でやるのが良さそう。
以下の用にユーザーのサービスとして有効にして自動起動するようにする。

systemctl --user enable onedrive
systemctl --user start onedrive

起動したかどうかも一応確認しておくと安心感がありそう。

journalctl --user-unit onedrive -f

overGrive(GoogleDrive)のインストール

有料、https://www.thefanclub.co.za/overgrive

sudo pacman -S libnotify python python2-pyinotify python2-pip python2-gobject
yaourt -S libappindicator-gtk3
sudo /usr/bin/pip2.7 install --upgrade google-api-python-client # /usr/bin/pip2.7としているのはanyenv/pyenvでpythonをインストールしている為。
# https://www.thefanclub.co.za/overgrive へアクセスして最新版を確認してダウンロードする
wget https://www.thefanclub.co.za/sites/default/files/public/overgrive/overgrive-3.2.*-0-any.pkg.tar.xz
sudo pacman -U overgrive-3.2.*-0-any.pkg.tar.xz
sudo glib-compile-schemas /usr/share/glib-2.0/schemas

設定ファイルをGitから持ってくる (自前で持っている人は不要)

zshの設定など

git clone https://github.com/bubbkis/LinuxSettings ~/LinuxSettings

urxvt用に.Xresourcesをコピーする

cp $(cd $(dirname ${BASH_SOURCE:-$0}); pwd)/LinuxSettings/.Xresources ~/.Xresources

Powerline のインストール

git clone https://github.com/bhilburn/powerlevel9k.git ~/powerlevel9k
git clone https://github.com/powerline/fonts.git ~/fonts
~/fonts/install.sh

dotfiles system のインストール

sh -c "`curl -fsSL https://raw.githubusercontent.com/skwp/dotfiles/master/install.sh`"
#  私の設定ファイル持ってきた人だけ
cp $(cd $(dirname ${BASH_SOURCE:-$0}); pwd)/LinuxSettings/zsh/private.zsh ~/.yadr/zsh/private.zsh
source ~/.zshrc

zsh-autosuggestionsのインストール (最初にインストールしたzsh-syntax-highlightingの設定も入れる)

pacaur -S zsh-autosuggestions
# Add the following to your .zshrc: or ~/.yadr/zsh/private.zsh
# 私の設定ファイル持ってきた人は不要
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

VMware Workstation のインストール

sudo pacman -S fuse2 gtkmm linux-headers libcanberra
sudo vim /etc/pacman.conf
# 以下を追記
[bpiotrowski]
Server = https://pkgbuild.com/~bpiotrowski/repo
yaourt -S vmware-workstation ncurses5-compat-libs gksu
sudo pacman -S open-vm-tools
cat /proc/version > /etc/arch-release
sudo modprobe -a vmw_vmci vmmon
systemctl enable vmware-networks
systemctl start vmware-networks
systemctl enable vmware-usbarbitrator
systemctl start vmware-usbarbitrator
systemctl enable vmware-hostd
systemctl start vmware-hostd
vmware-hgfsclient

TeamViewer のインストール

yaourt -S teamviewer-beta
sudo systemctl start teamviewerd
sudo systemctl enable teamviewerd

ランチャー rofi のインストール

sudo pacman -S rofi

コマンドラインツール のインストール

  • tree: ファイルやディレクトリの構成をグラフィカルに見たい場合に使えるコマンド
  • tig: Gitのためのテキストユーザインタフェース。Gitリポジトリ内の変更内容をVimライクな操作で高速に閲覧することができます
  • the_silver_searcher: ファイルに対して再帰的に文字列検索を行なうコマンド。要はスゴイ grep 。Silver だから ag というコマンド名
  • lsof: PortやPID、プロセス名からファイルがオープンしている情報を表示するコマンド
  • dstat: パフォーマンスのモニタリングを行うコマンド
  • iotop: プロセス毎のディスクI/Oを監視するコマンド
  • jq: JSONから簡単に値を抜き出したり、集計したり、整形して表示したりできるJSON用のgrepとかawkみたいなコマンド
sudo pacman -S tree tig the_silver_searcher lsof source-highlight dstat iotop
yaourt -S jq

GUIツール のインストール

sudo pacman -S terminator libreoffice libreoffice-ja gimp vlc htop hardinfo

conky のインストール

sudo pacman -S conky hdparm hddtemp lm_sensors

hddtemp の設定

sudo mkdir /etc/systemd/system/hddtemp.service.d
sudo vim /etc/systemd/system/hddtemp.service.d/customexec.conf
# 以下の内容で作成 /dev/sd* はPCに搭載しているHDDに沿って記述
[Service]
ExecStart=
ExecStart=/usr/bin/hddtemp -dF /dev/sda /dev/sdb /dev/sdc /dev/sdd
systemctl --system daemon-reload
systemctl restart hddtemp
systemctl enable hddtemp

lm_sensors の設定

sudo sensors-detect
#yes | sudo sensors-detect # 全てYESで設定終わらせる場合
mkdir -p ~/.config/conky
conky -C > ~/.config/conky/conky.conf

conky の設定

  • 私の設定ファイル持ってきた人はこっち
    • ~/LinuxSettings/conky/ の中の conky_hp_z820.conf か conky_thinkpad_x250.conf を参考に ~/.config/conky/conky.conf を編集する
    • 自動起動の設定
cp ~/LinuxSettings/autostart/conky.desktop ~/.config/autostart/conky.desktop
  • 私の設定ファイル持ってきてない人はこっち
vim ~/.config/autostart/conky.desktop
# 以下の内容で作成
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=conky
Comment=
Exec=conky -d
StartupNotify=false
Terminal=false
Hidden=false

dunst のインストール (デスクトップ通知)

sudo pacman -S dunst
mkdir ~/.config/dunst
sudo cp /usr/share/dunst/dunstrc ~/.config/dunst/
vim ~/.xinitrc
# ~/.xinitrcには以下を記述。
dunst &

compton のインストール

デスクトップ視覚効果(透過) # nvidia gefoce10*0環境でcomptonを起動するとCPU使用率が100%になってしまうので使っていない。
なら載せんな。

yaourt -S compton
mkdir ~/.config/compton
#  私の設定ファイル持ってきた人だけ
cp ~/LinuxSettings/compton/compton.conf ~/.config/compton
vim ~/.xinitrc
# ~/.xinitrcには以下を記述。
compton &

comptonを起動したり、CPU 100%とかになってcomptonを切りたかったら

sh ~/LinuxSettings/compton/toggle_composite.sh

するとOn / Off 出来ます。

arcテーマ のインストール

yaourt -S arc-icon-theme-git
sudo pacman -S arc-gtk-theme archlinux-wallpaper

sshfs をインストール

sudo pacman -S sshfs
sudo vim /etc/fuse.conf
# user_allow_other 行をアンコメントして root 以外のユーザーが allow_other マウントオプションを使えるようにしてください。

ntfs-3g をインストール

sudo pacman -S ntfs-3g

exFAT-utils をインストール

sudo pacman -S exfat-utils

dnsutils をインストール(dig, nslookupなど)

sudo pacman -S dnsutils

Netgear ReadyNasマウント用にnfsをインストール (不要な人は無視してください)

sudo pacman -S nfs-utils
sudo mkdir /mnt/nas
sudo mount -t nfs 192.168.0.2:/data/Documents /mnt/nas
sudo vim /etc/fstab
# 以下を追記
# ReadyNas
192.168.0.2:/data/Documents     /mnt/nas     nfs     rsize=8192,wsize=8192,timeo=14,_netdev 0 0

docker のインストール

php apache nginx mysql postgresql等の開発環境はlaradockにて構築する
https://github.com/laradock/laradock

sudo pacman -S docker docker-compose
sudo tee /etc/modules-load.d/loop.conf <<< "loop"
sudo modprobe loop
sudo systemctl start docker
sudo systemctl enable docker
# 現行ユーザをdockerグループに所属させる ($USER は自分のユーザー名に変更)
sudo gpasswd -a $USER docker
# dockerデーモンを再起動する
sudo systemctl restart docker
# reboot or logout&login 再起動 or ログインしなおすと反映される
docker info

heroku のインストール

yaourt -S heroku-cli
heroku login

heroku Docker Pluginをインストールする

heroku plugins:install heroku-container-registry
heroku container
heroku container:login

heroku-accounts Pluginをインストールする

heroku plugins:install heroku-accounts
heroku accounts:add personal # personalという名称で個人利用目的アカウント追加
heroku accounts:add work --sso # workという名称で仕事用アカウント追加 ※認証はsingle sign-on (SSO) SSOはオプションなのでpersonal同様に普通の認証でアカウント登録可能
## 使い方
# アカウント切り替え:
heroku accounts:set personal
# アカウント一覧表示:
heroku accounts
# 現在のアカウント表示:
heroku accounts:current
# アカウント除外:
heroku accounts:remove personal

unison (バックアップ) をインストール

sudo pacman -S unison

Linux kernel lts版をインストール

通常のカーネルは頻繁にアップデートされます。
もし、そのカーネルで起動不能になった場合の緊急時用にLTS版をインストールします。

sudo pacman -S linux-lts linux-lts-headers
sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak
sudo grub-mkconfig -o /boot/grub/grub.cfg
  • grub.cfgを生成するとbootメニューのエントリーがLinux-ltsがメインになり、通常のLinuxカーネルでのブートエントリーがサブメニュー内に隠れてしまう。
  • ので、/boot/grub/grub.cfgを編集します。
sudo vim /boot/grub/grub.cfg

メインエントリーになっているlinux-ltsエントリー箇所を下記の様にすべてコメントアウトする

# ### BEGIN /etc/grub.d/10_linux ###
# menuentory 'Arch Linux' ~~~ {
# ~~~
# 'Linux linux-lts をロード中...'
# ~~~
# }

次にその直下に、

submenu ~~~ {

と記載されている中に、Linux-ltsではなく、'Linux linux をロード中...'と記載されているエントリーがあるので、

menuentry 'Arch Linux, with Linux linux' ~~~ {~~~}

まで全てコピーして、コメントアウトしたlinux-ltsブートエントリーの下にペーストする。(シンタックスのズレは修正して下さい)

sudo vim /etc/default/grub
# 以下を編集
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

pacman-contrib をインストール(paccache, pactreeなど)

sudo pacman -S pacman-contrib
6
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
8