fix post
This commit is contained in:
@@ -8,10 +8,14 @@ draft: false
|
||||
|
||||
## 最小構成
|
||||
|
||||
まずはdiskの設定から。
|
||||
|
||||
```sh
|
||||
# cgdisk /dev/sda
|
||||
# cfdisk /dev/sda
|
||||
```
|
||||
|
||||
次にdiskのフォーマットなど。それをmountしてarchlinuxを入れます。bootloaderも設定しておきましょう。
|
||||
|
||||
```sh
|
||||
$ mkfs.vfat /dev/sda1
|
||||
$ mkfs.ext4 /dev/sda2
|
||||
@@ -20,6 +24,7 @@ $ mount /dev/sda2 /mnt
|
||||
$ mount --mkdir /dev/sda1 /mnt/boot
|
||||
|
||||
$ pacstrap /mnt base base-devel linux linux-firmware linux-headers
|
||||
$ genfstab -U /mnt >> /mnt/etc/fstab
|
||||
|
||||
$ arch-chroot /mnt
|
||||
$ pacman -S dhcpcd grub os-prober efibootmgr
|
||||
@@ -27,14 +32,57 @@ $ grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
|
||||
$ grub-mkconfig -o /boot/grub/grub.cfg
|
||||
```
|
||||
|
||||
これだけで`exit;reboot`すると起動できます。
|
||||
これで`exit;reboot`すると起動できます。
|
||||
|
||||
## networkの設定
|
||||
## よく使うもの
|
||||
|
||||
```sh
|
||||
$ pacman -S git vim tmux zsh openssh
|
||||
$ pacman -S openssh zsh vim git tmux cargo
|
||||
```
|
||||
|
||||
## userの作成
|
||||
|
||||
```sh
|
||||
$ passwd
|
||||
$ useradd -m -G wheel ${USER}
|
||||
$ passwd ${USER}
|
||||
```
|
||||
|
||||
```sh
|
||||
$ chsh -s /bin/zsh ${USER}
|
||||
or
|
||||
$ useradd -m -G wheel -s /bin/zsh ${USER}
|
||||
```
|
||||
|
||||
```sh
|
||||
$ HOSTNAME=archlinux
|
||||
$ echo "$HOSTNAME" > /etc/hostname
|
||||
```
|
||||
|
||||
## sudoの使い方
|
||||
|
||||
1. `/etc/sudoers`は編集を間違えると起動できなくなります。安全のため`visudo`が推奨されています。
|
||||
2. `vim`では`:w!`で保存します。
|
||||
|
||||
```sh
|
||||
$ sudo visudo
|
||||
or
|
||||
$ vim /etc/sudoers
|
||||
```
|
||||
|
||||
```sh:/etc/sudoers
|
||||
%wheel ALL=(ALL:ALL) ALL
|
||||
%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syu --noconfirm
|
||||
```
|
||||
|
||||
よく`update`する人はpasswordなしで特定のコマンドをsudoを実行できるようにしておいたほうが良いでしょう。
|
||||
|
||||
```sh
|
||||
$ sudo pacman -Syu --noconfirm
|
||||
```
|
||||
|
||||
## networkの設定
|
||||
|
||||
次にnetworkです。ここでは`systemd-networkd`を使用します。`dhcpcd`を使ったほうが簡単ではあります。もし安定しないようなら`dhcpcd`を使用。
|
||||
|
||||
```sh
|
||||
@@ -86,7 +134,7 @@ $ systemctl restart getty@tty1
|
||||
|
||||
## window-manager
|
||||
|
||||
`xorg`でdesktop(window-manager)を作ります。`i3`を使うことにしましょう。`xorg`は`wayland`に切り替えたほうがいいかも。
|
||||
`xorg`でdesktop(window-manager)を作ります。`i3`を使うことにしましょう。`xorg`は`wayland`に乗り換えたほうがいいかも。その場合は`sway`がおすすめ。
|
||||
|
||||
```sh
|
||||
$ pacman -S xorg xorg-xinit i3 xterm
|
||||
@@ -117,7 +165,7 @@ PasswordAuthentication no
|
||||
$ systemctl restart sshd
|
||||
```
|
||||
|
||||
基本的にlanで使う場合はdefaultで問題ありませんが、wanで使う場合は変更します。とはいえ、lanでもport, passwordは変えておいたほうがいいでしょう。
|
||||
基本的にlanから使う場合はdefaultで問題ありませんが、wanから使う場合は変更します。とはいえ、lanでもport, passwordは変えておいたほうがいいでしょう。
|
||||
|
||||
次に接続側でkeyを作ってserverに登録します。
|
||||
|
||||
@@ -179,3 +227,86 @@ bindkey '^[[B' history-substring-search-down
|
||||
```
|
||||
|
||||
`powerline`は重いのでコメントしています。
|
||||
|
||||
## archlinuxの作り方
|
||||
|
||||
archlinuxはシンプルなscriptと言えるでしょう。なので色々と便利です。ここでは、`img.sh`, `install.sh`を作ります。
|
||||
|
||||
### img.sh
|
||||
|
||||
```sh:img.sh
|
||||
#!/bin/bash
|
||||
pacman -Syuu --noconfirm git base-devel archiso
|
||||
git clone https://gitlab.archlinux.org/archlinux/archiso
|
||||
./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
|
||||
|
||||
# mkdir -p root.x86_64/var/lib/machines/arch
|
||||
# pacstrap -c root.x86_64/var/lib/machines/arch base
|
||||
# arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
|
||||
# arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
|
||||
# tar -zcvf archlinux.tar.gz root.x86_64/
|
||||
```
|
||||
|
||||
例えば、`pacstrap`で自分の好きなツールを指定すれば、独自のimgを作成できます。これは`docker-img`にもできます。
|
||||
|
||||
```sh
|
||||
$ docker import archlinux.tar.gz archlinux:syui
|
||||
```
|
||||
|
||||
### install.sh
|
||||
|
||||
最小構成のinstall scriptです。どこかのurlに置いて、install時にcurlして実行するようにすれば便利です。
|
||||
|
||||
```sh
|
||||
$ curl -sLO arch.example.com/install.sh
|
||||
$ chmod +x install.sh
|
||||
$ ./install.sh
|
||||
```
|
||||
|
||||
```sh:install.sh
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# 変数定義
|
||||
DISK="/dev/sda"
|
||||
HOSTNAME="ai-arch"
|
||||
USERNAME="ai"
|
||||
|
||||
# パーティション作成(自動)
|
||||
parted $DISK mklabel gpt
|
||||
parted $DISK mkpart ESP fat32 1MiB 1GiB
|
||||
parted $DISK set 1 esp on
|
||||
parted $DISK mkpart primary linux-swap 1GiB 5GiB
|
||||
parted $DISK mkpart primary ext4 5GiB 100%
|
||||
|
||||
# ファイルシステム作成
|
||||
mkfs.fat -F32 ${DISK}1
|
||||
mkswap ${DISK}2
|
||||
mkfs.ext4 ${DISK}3
|
||||
|
||||
# マウント
|
||||
mount ${DISK}3 /mnt
|
||||
mkdir -p /mnt/boot
|
||||
mount ${DISK}1 /mnt/boot
|
||||
swapon ${DISK}2
|
||||
|
||||
# インストール
|
||||
pacstrap -K /mnt base linux linux-firmware base-devel vim networkmanager grub efibootmgr
|
||||
|
||||
# 設定
|
||||
genfstab -U /mnt >> /mnt/etc/fstab
|
||||
|
||||
arch-chroot /mnt /bin/bash << EOF
|
||||
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
|
||||
hwclock --systohc
|
||||
echo "ja_JP.UTF-8 UTF-8" >> /etc/locale.gen
|
||||
locale-gen
|
||||
echo "LANG=ja_JP.UTF-8" > /etc/locale.conf
|
||||
echo "$HOSTNAME" > /etc/hostname
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ARCH
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
systemctl enable NetworkManager
|
||||
useradd -m -G wheel $USERNAME
|
||||
EOF
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user