LoginSignup
4
2

More than 5 years have passed since last update.

Arch Linuxインストール(無線LANで) : LUKS, LVM, UEFI

Last updated at Posted at 2016-12-30

以下のサイトを参考にしました。
https://wiki.archlinuxjp.org/
http://lespedeza93.blogspot.jp/2015/08/archlinuxuefi-gpt-lvm2_9.html
http://archlinux-blogger.blogspot.jp/2015/02/arch-linux-os-uefi-gpt-xfs-archlinux.html
http://archlinux-blogger.blogspot.jp/2016/03/arch-linux-x-gnome.html
http://mofoolog.hateblo.jp/entry/archlinux-cinnamon-gdm-setting-1602
http://d.hatena.ne.jp/defiant/20110217/1297931082
https://gist.github.com/jasonwryan/4618490
https://gist.github.com/mattiaslundberg/8620837
https://loganmarchione.com/2014/11/arch-linux-encrypted-lvm-hardware-2/

<最終動作確認日:2017/01/19>

UEFIモードか確認

# ls /sys/firmware/
apci dmi efi memmap

キーボードレイアウトを変更

# loadkeys jp106

無線LAN設定

# ip link show
# ip link set <interface> up
# iwlist <interface> scanning | grep ESSID
# wpa_supplicant -B -i <interface> -c <(wpa_passphrase <ESSID> <password>)
# dhcpcd
# ping google.com

ディスクをLUKSで暗号化している場合は復号化

# cryptsetup luksOpen <disk> <luks-disk-name>

ディスク・lvmの使用状況を確認

# lsblk
# df -h
# lvscan

【任意】ディスクをクリーン

# sgdisk --zap-all /dev/sdX
lvmを削除する場合は以下
# lvremove -f <vg-name>
# pvremove -f <pv-name>

パーティション

パーティションを作成
はESP(ef00)に設定
はlvm用(8e00)に設定

# gdisk <disk>
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Command (? for help): n
Partition number :
First sector:
Last sector: +512M
Hex code or GUID: ef00

Command (? for help): n
Partition number:
First sector:
Last sector: 
Hex code or GUID: 8e00

Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed?: y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

ちゃんとできたか確認

# lsblk

LUKS

# modprobe -a dm-mod dm_crypt

# cryptsetup -v -y -c aes-xts-plain64 -s 512 -h sha512 -i 5000 --use-random luksFormat <disk02>
# cryptsetup open <disk02> <luks-disk-name>

-v = verbose
-y = verify password, ask twice, and complain if they don’t match
-c = specify the cipher used
-s = specify the key size used
-h = specify the hash used
-i = number of milliseconds to spend passphrase processing (if using anything more than sha1, must be great than 1000)
–use-random = which random number generator to use
luksFormat = to initialize the partition and set a passphrase
/dev/sda3 = the partition to encrypt

ちゃんとできたか確認

# lvmdiskscan

LVM

lvmを作成
100%にするには -l 100%FREE

# pvcreate /dev/mapper/<luks-disk-name>
# vgcreate <vg-name> /dev/mapper/<luks-disk-name>
# lvcreate -L 8G <vg-name> -n <lv-swap-name>
# lvcreate -L 64G <vg-name> -n <lv-root-name>

ファイルシステム

ファイルシステムを作成
スワップはオンにする

# mkfs.vfat -F32 <disk01>
# mkswap /dev/<vg-name>/<lv-swap-name>
# swapon /dev/<vg-name>/<lv-swap-name>
# mkfs.ext4 /dev/<vg-name>/<lv-root-name>

マウント

# mount /dev/<vg-name>/<lv-root-name> /mnt
# mkdir -p /mnt/boot/efi
# mount <disk01> /mnt/boot/efi

ミラーの順番を変更

# vi /etc/pacman.d/mirrorlist

##
## Arch Linux repository mirrorlist
## Sorted by mirror score from mirror status page
## Generated on 2015-01-01
##

## Score: 2.4, Japan
Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch
...

ベースシステムをインストール

# pacstrap /mnt base base-devel

fstabに記述

# genfstab -U -p /mnt >> /mnt/etc/fstab

chrootする

# arch-chroot /mnt /bin/bash

ロケールの設定

# vi /etc/locale.gen
...
#en_SG ISO-8859-1  
en_US.UTF-8 UTF-8
#en_US ISO-8859-1  
...
#ja_JP.EUC-JP EUC-JP  
ja_JP.UTF-8 UTF-8
#ka_GE.UTF-8 UTF-8 
...
# locale-gen
# echo LANG=en_US.UTF-8 > /etc/locale.conf
# export LANG=en_US.UTF-8

キーボードレイアウトを変更

# loadkeys jp106
# vi /etc/vconsole.conf
KEYMAP=jp106

クロックを設定

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

ホスト名

# echo <hostname> > /etc/hostname
# vi /etc/hosts
...
#<ip-address> <hostname .domain.org=""> <hostname>
127.0.0.1 localhost.localdomain localhost <hostname>
::1  localhost.localdomain localhost <hostname>
...

initramfs

initramfsを作成

# vi /etc/mkinitcpio.conf
...
HOOKS="base udev autodetect modconf block encrypt lvm2 filesystems keyboard fsck"
...
# mkinitcpio -p linux

ユーザ設定

パスワードを設定

# passwd

一般ユーザを設定

# useradd -m -g users -G wheel -s /bin/bash <username>
# passwd <username>]

無線LANツールをインストールしておく

# pacman -S wireless_tools
# pacman -S wpa_supplicant

アーキテクチャ設定

# pacman -S intel-ucode

ブートローダ

ブートローダをインストール
lvmとluksを使用するためにはGRUBがdevice mapperをサポートする必要があります。
Then, we need to install Grub. Since we are using lvm and luks, we need Grub to support device mapper.

echo "sys-boot/grub device-mapper" >> /etc/portage/package.use/grub
emerge grub

# pacman -S grub dosfstools efibootmgr

以下を記述(GRUB_CMDLINE_LINUX項目は既存ですが、GRUB_ENABLE_CRYPTODISK項目は新しく記述します。)
cryptdeviceは通常の/dev/sdxなどでも記述可能ですが、新しいデバイスなどを追加すると順番が変更され、認識しなくなる恐れがあります。

# vi /etc/default/grub
...
GRUB_CMDLINE_LINUX="cryptdevice=/dev/disk/by-uuid/<UUId>:<luks-disk-name>"
...
GRUB_ENABLE_CRYPTODISK=y

GRUB2をESPにインストールします。

# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck

# mkdir /boot/efi/EFI/boot
# cp /boot/efi/EFI/arch_grub/grubx64.efi  /boot/efi/EFI/boot/bootx64.efi

# grub-mkconfig -o /boot/grub/grub.cfg

chrootを抜けて、すべてアンマウントしてリブート

# exit
# umount -R /mnt
# reboot
# visudo

...
## Uncomment to allow members of group wheel to execute any command
%wheel ALL=(ALL) ALL
...
無線LAN設定
# ip link show
# ip link set <interface> up
# iwlist <interface> scanning | grep ESSID
# wpa_supplicant -B -i <interface> -c <(wpa_passphrase <ESSID> <password>)
# dhcpcd
# ping google.com
CLIで使うツールのインストール
# pacman -S vim bash-completion
# timedatectl set-ntp true
# vim /etc/systemd/timesyncd.conf
...
[Time]
NTP=ntp1.jst.mfeed.ad.jp ntp2.jst.mfeed.ad.jp ntp3.jst.mfeed.ad.jp
FallbackNTP=0.arch.pool.ntp.org 1.arch.pool.ntp.org 2.arch.pool.ntp.org 3.arch.pool.ntp.org
...
# systemctl -l status systemd-timesyncd

X

Xをインストールしてstartx

# pacman -S xorg-server xorg-server-utils xorg-xinit xorg-xclock xterm xorg-twm
# lspci | grep VGA
# pacman -S xf86-video-intel

# startx

GNOME

GNOMEをインストールしてリブート
# pacman -S gnome gnome-extra

# systemctl enable gdm.service

# reboot
色々インストールしとく
# vim /etc/pacman.conf

...
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch
# pacman -Syu
# pacman -S wget git expac jshon firefox guake gimp inkscape openssh rsync yaourt
# yaourt -Syu

日本語表示のため

$ yaourt -S packer
編集するか聞かれたらNoでいいと思います。
$ packer -S otf-ipaexfont
# vim /etc/fonts/conf.avail/71-no-embedded-bitmaps.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font">
    <edit mode="assign" name="embeddedbitmap">
      <bool>false</bool>
    </edit>
    <edit mode="assign" name="hintstyle">
       <const>hintnone</const>
    </edit>
  </match>
</fontconfig>
# ln -s /etc/fonts/conf.avail/71-no-embedded-bitmaps.conf /etc/fonts/conf.d/71-no-embedded-bitmaps.conf

Fcitx-Mozcをインストール

# gsettings set org.gnome.settings-daemon.plugins.keyboard active false
# pacman -S fcitx fcitx-mozc fcitx-configtool fcitx-im

リブート
# reboot
$ vim ~/.xprofile
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export DefaultIMModule=fcitx
setxkbmap -model jp106 -layout jp
fcitx-autostart &
# vim /etc/X11/xorg.conf

Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "XkbModel" "jp106"
        Option "XkbLayout" "jp"
EndSection
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/IMModule':<'fcitx'>}"

[Fcitx configuration]を起動
[Imput Method]に[Mozc]のみ表示させる
[Appearance]の[Status Panel Hide Mode]を[Show]にする

[Settings]を起動
[Region & Language]で[Input Method]にJapaneseを設定する

リブート

# reboot
4
2
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
4
2