ArchLinux 2016.06.01: ArchLinux 2016.06.01をインストールする


Table of Contents

1 LiveDVDの取得

ArchLinuxのダウンロードページからミラーサイトを選択し、archlinux-2016.06.01-dual.isoをダウンロードします。

2 LiveDVDの起動

ArchLinuxを起動すると以下のメニューが表示されます。

ここではTABキーを押して、console=ttyS0,115200を付けています。

0001_GRUB.png

LiveDVDが起動します。

[ OK ] Listening on Load/Save RF Kill Switch Status /dev/rfkill Watch.[ OK ] Started Serial Getty on ttyS0.[ OK ] Started Getty on tty1.[ OK ] Reached target Login Prompts.[ OK ] Started Initializes Pacman keyring.[ OK ] Reached target Multi-User System.Arch Linux 4.5.4-1-ARCH (ttyS0)archiso login: rootLast login: Wed Jun 1 20:56:20 on tty1root@archiso ~ #

3 LiveDVDでの設定

chrootする前の設定について記載します。

3.1 パーティションの作成

fdisk実行前のパーティションは以下の通りです。

root@archiso ~ # cat /proc/partitionsmajor minor #blocks name 254 0 83886080 vda 11 0 761856 sr0 7 0 330856 loop0

fdiskで/dev/vdaにパーティションを作成します。

root@archiso ~ # fdisk /dev/vdaWelcome to fdisk (util-linux 2.28).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Device does not contain a recognized partition table.Created a new DOS disklabel with disk identifier 0x1a1a375b.

/boot用の領域を作成します。

Command (m for help): nPartition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions)Select (default p): pPartition number (1-4, default 1):First sector (2048-167772159, default 2048):Last sector, +sectors or +size{K,M,G,T,P} (2048-167772159, default167772159): 1026047Created a new partition 1 of type ‘Linux’ and of size 500 MiB.

LVM用の領域を作成します。

Command (m for help): nPartition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions)Select (default p): pPartition number (2-4, default 2):First sector (1026048-167772159, default 1026048):lasst sector, +sectors or +size{K,M,G,T,P} (1026048-167772159, default 167772159):Created a new partition 2 of type ‘Linux’ and of size 79.5 GiB.

/boot用の領域にbootラベルをつけます。

Command (m for help): aPartition number (1,2, default 2): 1The bootable flag on partition 1 is enabled now.

LVM用の領域にLinux LVMラベルをつけます。

Command (m for help): tPartition number (1,2, default 2): 2Partition type (type L to list all types): 8eChanged type of partition ‘Linux’ to ‘Linux LVM’.

変更を/dev/vdaに反映させます。

Command (m for help): wThe partition table has been altered.Calling ioctl() to re-read partition table.Syncing disks.

パーティションの構成は以下の通りになりました。

root@archiso ~ # fdisk -l /dev/vdaDisk /dev/vda: 80 GiB, 85899345920 bytes, 167772160 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x1a1a375bDevice Boot Start End Sectors Size Id Type/dev/vda1 * 2048 1026047 1024000 500M 83 Linux/dev/vda2 1026048 167772159 166746112 79.5G 8e Linux LVM

3.2 LVMの設定

/dev/vda2にLVM物理ボリュームを作成します。

root@archiso ~ # pvcreate /dev/vda2 Physical volume “/dev/vda2” successfully created.

/dev/vda2にvg_archlinuxというボリュームグループを作成します。

root@archiso ~ # vgcreate vg_archlinux /dev/vda2 Volume group “vg_archlinux” successfully created

vg_archlinuxに2GByteの論理ボリュームlv_swapを作成します。

root@archiso ~ # lvcreate -L 2G -n lv_swap vg_archlinux Logical volume “lv_swap” created.

vg_archlinuxに残りサイズを使った論理ボリュームlv_rootを作成します。

root@archiso ~ # lvcreate -l 100%FREE -n lv_root vg_archlinux Logical volume “lv_root” created.

論理ボリュームは以下の通りとなります。

root@archiso ~ # lvdisplay — Logical volume — LV Path /dev/vg_archlinux/lv_swap LV Name lv_swap VG Name vg_archlinux LV UUID xCzJB4-GtEf-IdaE-5zyb-C9jq-o35Q-LMH0fn LV Write Access read/write LV Creation host, time archiso, 2016-06-02 08:40:06 +0000 LV Status available # open 0 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto – currently set to 256 Block device 253:0 — Logical volume — LV Path /dev/vg_archlinux/lv_root LV Name lv_root VG Name vg_archlinux LV UUID 044QxM-XW3y-fM3Z-gO2K-m6LY-zvCp-spJUlJ LV Write Access read/write LV Creation host, time archiso, 2016-06-02 08:42:46 +0000 LV Status available # open 0 LV Size 77.51 GiB Current LE 19842 Segments 1 Allocation inherit Read ahead sectors auto – currently set to 256 Block device 253:1

3.3 ファイルシステムの作成

/dev/vda1をext4で初期化します。

root@archiso ~ # mkfs.ext4 /dev/vda1mke2fs 1.42.13 (17-May-2015)Creating filesystem with 512000 1k blocks and 128016 inodesFilesystem UUID: f9cfa9b6-e430-4401-83af-01f7d1848fffSuperblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409Allocating group tables: doneWriting inode tables: doneCreating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: done

/dev/vg_archlinux/lv_rootをext4で初期化します。

root@archiso ~ # mkfs.ext4 /dev/vg_archlinux/lv_rootmke2fs 1.42.13 (17-May-2015)Creating filesystem with 20318208 4k blocks and 5087232 inodesFilesystem UUID: 9370cab0-2929-4c99-8e11-4c50a35f00b9Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632,2654208, 4096000, 7962624, 11239424Allocating group tables: doneWriting inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done

/dev/vg_archlinux/lv_swapをスワップ領域として初期化します。

root@archiso ~ # mkswap /dev/vg_archlinux/lv_swapSetting up swapspace version 1, size = 2 GiB (2147479552 bytes)no label, UUID=d9f73db0-770f-4d29-a209-ebfc01080bc7

各種ファイルシステムをマウントします。

root@archiso ~ # mount -t ext4 /dev/vg_archlinux/lv_root /mntroot@archiso ~ # mkdir /mnt/bootroot@archiso ~ # mount -t ext4 /dev/vda1 /mnt/bootroot@archiso ~ # swapon /dev/vg_archlinux/lv_swap

3.4 パッケージのインストール

pacstrapでbase、sudo、grub、lvm2、opensshをインストールします。

gdmとlightdmは上手く動かなかったので、lxdmをインストールします。

gnome-terminalが上手く動かなかったので、xfce4をインストールします。

root@archiso ~ # pacstrap /mnt base xfce4 xfce4-goodies lxdm sudo grub lvm2 openssh==> Creating install root at /mnt==> Installing packages to /mnt:: Synchronizing package databases…

base等のパッケージグループの詳細についてはこちらを御覧ください。

3.5 fstabの作成

genfstabで/etc/fstabを作成します。

root@archiso ~ # genfstab -p /mnt >> /mnt/etc/fstabroot@archiso ~ # cat /mnt/etc/fstab## /etc/fstab: static file system information## <file system> <dir> <type> <options> <dump> <pass># UUID=9370cab0-2929-4c99-8e11-4c50a35f00b9/dev/mapper/vg_archlinux-lv_root / ext4rw,relatime,data=ordered 0 1# UUID=f9cfa9b6-e430-4401-83af-01f7d1848fff/dev/vda1 /boot ext4rw,relatime,data=ordered 0 2# UUID=d9f73db0-770f-4d29-a209-ebfc01080bc7/dev/mapper/vg_archlinux-lv_swap none swapdefaults 0 0

4 chrootでの設定

arch-chrootで作成したルートファイルシステムにchrootします。

root@archiso ~ # arch-chroot /mntsh-4.3#

4.1 ホスト名の設定

/etc/hostnameにホスト名を記載します。

sh-4.3# echo “archlinux” > /etc/hostname

4.2 localeの作成

/etc/locale.genと/etc/locale.confを作成します。

sh-4.3# locale-genGenerating locales…Generation complete.sh-4.3# echo “LANG=ja_JP.UTF-8” > /etc/locale.conf

4.3 sudoの設定

visudoで/etc/sudoersを編集します。以下の%wheel前の#を消します。

sh-4.3# EDITOR=nano visudosh-4.3# diff -uprN /etc/sudoers{.org,}— /etc/sudoers.org 2016-06-02 20:42:43.913333333 +0000+++ /etc/sudoers 2016-06-02 20:43:28.186666661 +0000@@ -82,7 +82,7 @@ root ALL=(ALL) ALL # %wheel ALL=(ALL) ALL ## Same thing without a password-# %wheel ALL=(ALL) NOPASSWD: ALL+%wheel ALL=(ALL) NOPASSWD: ALL ## Uncomment to allow members of group sudo to execute any command # %sudo ALL=(ALL) ALL

4.4 rootのパスワード設定

rootのパスワードを設定します。

sh-4.3# passwdEnter new UNIX password:Retype new UNIX password:passwd: password updated successfully

4.5 ユーザの作成

sudoが使えるユーザを作成します。

sh-4.3# useradd -m hiroom2sh-4.3# gpasswd -a hiroom2 wheelAdding user hiroom2 to group wheelsh-4.3# passwd hiroom2Enter new UNIX password:Retype new UNIX password:passwd: password updated successfully sh-4.3# su – hiroom2[hiroom2@archiso ~]$ ls -latotal 20drwx—— 2 hiroom2 hiroom2 4096 Jun 2 09:37 .drwxr-xr-x 3 root root 4096 Jun 2 09:37 ..-rw-r–r– 1 hiroom2 hiroom2 21 Nov 23 2015 .bash_logout-rw-r–r– 1 hiroom2 hiroom2 57 Nov 23 2015 .bash_profile-rw-r–r– 1 hiroom2 hiroom2 141 Nov 23 2015 .bashrc[hiroom2@archiso ~]$ sudo ls -a /root. .. .bash_history .gnupg[hiroom2@archiso ~]$ exit

4.6 GRUBの設定

カーネル起動パラメータroot=にUUID=xxxではなく/dev/xxxを用いるようにします。

sh-4.3# diff -uprN /etc/default/grub{.
org,}— /etc/default/grub.org 2016-06-02 21:05:42.826666637 +0000+++ /etc/default/grub 2016-06-02 21:05:56.266666657 +0000@@ -27,7 +27,7 @@ GRUB_GFXPAYLOAD_LINUX=keep # Uncomment if you want GRUB to pass to the Linux kernel the old # parameter # format “root=/dev/xxx” instead of “root=/dev/disk/by-uuid/xxx”-#GRUB_DISABLE_LINUX_UUID=true+GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries GRUB_DISABLE_RECOVERY=true

ArchLinuxのgrub-installには若干問題があり、適切なroot=の場所を探すことができないようです。

grub-mkconfigでgrub.cfgを作成し直す必要があります。

sh-4.3# grub-install –boot-directory=/boot /dev/vdaInstalling for i386-pc platform.Installation finished. No error reported.sh-4.3# grub-mkconfig -o /boot/grub/grub.cfg

4.7 initramfsの設定

initramfsでlvm2のスクリプトを読み込むようにします。

sh-4.3# diff -uprN /etc/mkinitcpio.conf{.org,}— /etc/mkinitcpio.conf.org 2016-06-02 21:10:11.310000004 +0000+++ /etc/mkinitcpio.conf 2016-06-02 21:10:39.563333326 +0000@@ -49,7 +49,7 @@ FILES=”” # ## NOTE: If you have /usr on a separate partition, you MUST include the # usr, fsck and shutdown hooks.-HOOKS=”base udev autodetect modconf block filesystems keyboard fsck”+HOOKS=”base udev autodetect modconf block filesystems keyboard fsck lvm2″ # COMPRESSION # Use this to compress the initramfs image. By default, gzip compression

mkinitcpioでinitramfsを作成します。

sh-4.3# mkinitcpio -p linux==> Building image from preset: /etc/mkinitcpio.d/linux.preset:

LiveDVDを再起動して、インストールしたArchLinuxを起動します。

sh-4.3# exitroot@archiso ~ # umount /mnt/bootroot@archiso ~ # umount /mntroot@archiso ~ # reboot

5 インストールしたArchLinuxでの設定

インストールしたArchLinuxを起動して、ログインします。

lxdmが動いていないので、ttyの画面が表示されます。

 

dhcpcdでDHCPサーバからIPアドレス、経路情報、DNS情報を取得します。

[root@archlinux ~]# systemctl enable dhcpcd

sshdを有効にします。

[root@archlinux ~]# systemctl enable sshd

lxdmを有効にします。

[root@archlinux ~]# systemctl enable lxdm

再起動します。

[root@archlinux ~]# reboot

lxdmのログイン画面が表示されました。

0002_LXDM.png

Xfceでログインできました。

0003_Xfce.png

Android | Linux | SDL - Narrow Escape