海馬のかわり

最近記憶力に難がある、地方在住サーバエンジニアの備忘録です。

Arch Linuxインストールメモ (archlinux-2012.11.01)


######################################################################

※2013/2/15追記
archlinux-2013.02.01のインストール手順をこちらに書きました。

Arch Linuxインストールメモ (archlinux-2013.02.01)
http://extrea.hatenablog.com/entry/2013/02/15/123721

######################################################################



以下、旧文


ArchLinux 2012.11.01 インストールメモです。
なんとかsystemdの設定にも慣れてきたところ・・・rc.confが恋しい

・使用メディア
ISO: archlinux-2012.11.01-dual.iso

・メディアからのブート
上記イメージよりブート。
今回は64bit版を選択する。

f:id:extrea:20120730172626p:plain

ブート完了後、インストール用のライブOSが起動したところ。
(rootで自動ログインした状態)

f:id:extrea:20121112113441p:plain

事前準備として、まずは日本語キーボードを使えるようにする。

# loadkeys jp106


・インストール準備

[ Network ]
手動設定を行う。
(DHCP環境なら特に設定不要)

iproute2コマンドでの設定例
# ip addr show
# ip link set eth0 up
# ip addr add 10.0.18.204/24 dev eth0
# ip route add default via 10.0.18.254 dev eth0
# vi /etc/resolv.conf
# cat /etc/resolv.conf

### Google Public DNS
nameserver 8.8.8.8
nameserver 8.8.4.4

# ping google.com
PING google.com (173.194.38.78) 56(84) bytes of data.
64 bytes from nrt19s17-in-f14.1e100.net (173.194.38.78): icmp_req=1 ttl=46 time=17.2 ms
64 bytes from nrt19s17-in-f14.1e100.net (173.194.38.78): icmp_req=2 ttl=46 time=21.9 ms
64 bytes from nrt19s17-in-f14.1e100.net (173.194.38.78): icmp_req=3 ttl=46 time=14.0 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 14.006/17.750/21.997/3.285 ms

ついでに、リモートから作業できるようにsshdを起動する。

# passwd  # rootユーザのパスワードを設定
# systemctl start sshd.service


[ Disk Partition ]
ディスクパーティションの設定。
本環境では、/dev/sdaをインストール先HDDとして使用する。

Disk Size: 15GB

device mountpoint size
/dev/sda1 /boot 100MB
/dev/sda2 swap 512MB
/dev/sda3 /var 5000MB
/dev/sda4 / 残り全て

 

# fdisk /dev/sda
# fdisk -l /dev/sda

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders, total 31457280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xbd047ddc

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      206847      102400   83  Linux
/dev/sda2          206848     1255423      524288   82  Linux swap / Solaris
/dev/sda3         1255424    11741183     5242880   83  Linux
/dev/sda4        11741184    31457279     9858048   83  Linux

※bootパーティションへbootフラグの付与を忘れない事
※fdiskの使い方は このあたりを参照の事。


[ Format ]
/(root),/boot,/varパーティションをext4でフォーマットする。

# mkfs.ext4 /dev/sda1
# mkfs.ext4 /dev/sda3
# mkfs.ext4 /dev/sda4
# 

[ Mount ]
先ほど作成した/dev/sdaの各パーティションを、ライブOSの/mnt配下にマウント。

# mount /dev/sda4 /mnt		# rootパーティションのマウント
# mkdir -p /mnt/{boot,var}	# /boot,/var用マウントポイント作成
# mount /dev/sda1 /mnt/boot	# /bootパーティション
# mount /dev/sda3 /mnt/var	# /varパーティション
# df -hT
Filesystem                   Type      Size  Used Avail Use% Mounted on

~ 中略 ~

/dev/sda4                    ext4      9.4G  270M  8.7G   3% /mnt
/dev/sda1                    ext4       96M   14K   91M   1% /mnt/boot
/dev/sda3                    ext4      5.0G  203M  4.6G   5% /mnt/var


・システムのインストール

[ mirrorlist ]
一番近いミラー先を使用できるように、リストの先頭に
Score値0.1にて、日本のレポジトリを追記。

# cp -p /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.org
# vi /etc/pacman.d/mirrorlist
# diff -wb /etc/pacman.d/mirrorlist.org /etc/pacman.d/mirrorlist
6a7,8
> ## Score: 0.1, Japan
> Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch


[ System Install ]
pacstrapスクリプトにて必要なパッケージグループを指定し、インストールを行う。

今回はGUI不要の為、基本的なパッケージグループのみ選択。

- base
- base-devel
 

# pacstrap /mnt base base-devel
==> Creating install root at /mnt
==> Installing packages to /mnt
warning: database file for 'core' does not exist
warning: database file for 'extra' does not exist
warning: database file for 'community' does not exist
:: Synchronizing package databases...
 core                                      107.7 KiB   962K/s 00:00 [######################################] 100%
 extra                                    1408.3 KiB  2.12M/s 00:01 [######################################] 100%
 community                                1766.5 KiB  1532K/s 00:01 [######################################] 100%

~ 中略 ~

%
(130/132) installing make                                           [######################################] 100%
(131/132) installing patch                                          [######################################] 100%
Optional dependencies for patch
    ed: Interpret the patch as an ed script; for patch -e functionality(deprecated)
(132/132) installing pkg-config                                     [######################################] 100%
# 


[ Bootloader ]
Bootloaderは以下より選択する。

- grub-bios
- grub-efi-x86_64
- syslinux

通常はgrub-biosになるかと。

# pacstrap /mnt grub-bios
# 


・システム設定

[ fstab ]

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


[ chroot ]
以降は、新規インストールしたシステムにchrootして作業する。

# arch-chroot /mnt
# 


[ Hostname ]
適宜設定。

# echo "arch03.localdomain" >> /etc/hostname
# 


[ Timezone ]
BIOSの時間をローカルタイムにする場合は、adjtimeファイルを作成する

# ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
# 
# vi /etc/adjtime
# cat /etc/adjtime
0.0 0.0 0.0
0
LOCAL


[ Locale ]

# echo "LANG=ja_JP.UTF-8" >> /etc/locale.conf
# 
# cp -p /etc/locale.gen /etc/locale.gen.org
# vi /etc/locale.gen
# diff -wb /etc/locale.gen.org /etc/locale.gen
278c278
< #ja_JP.UTF-8 UTF-8
---
> ja_JP.UTF-8 UTF-8

# 
# locale-gen
Generating locales...
  ja_JP.UTF-8... done
Generation complete.


[ ram image ]

# mkinitcpio -p linux
# 


[ grub install ]

# grub-install --target=x86_64-pc --boot-directory=/boot --recheck --debug /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg
# 


[ Keyboard ]

# /etc/vconsole.conf
# cat /etc/vconsole.conf
KEYMAP=jp106


[ resolv.conf ]

# vi /etc/resolv.conf
# cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4


[ root passwort]
rootユーザーのパスワードを設定。

# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully


・swapの設定

# fdisk -l
# mkswap /dev/sda2
# echo "/dev/sda2 swap swap defaults 0 0" >> /etc/fstab
# 


・再起動
chroot環境より抜けインストール用ディレクトリをunmount後、システム再起動。

# exit
# umount /mnt/{boot,var,}
# reboot
# 


・初期設定
必要最低限のパッケージを追加する。

pacmanコマンドが使えるよう、まずはネットワーク周りを手動で設定する。
(ISOブート時と同じく、DHCP環境なら設定不要。)

# ip addr show
# ip link set eth0 up
# ip addr add 10.0.18.204/24 dev eth0
# ip route add default via 10.0.18.254 dev eth0
# 
# ping google.com
PING google.com (173.194.38.78) 56(84) bytes of data.
64 bytes from nrt19s17-in-f14.1e100.net (173.194.38.78): icmp_req=1 ttl=46 time=17.2 ms
64 bytes from nrt19s17-in-f14.1e100.net (173.194.38.78): icmp_req=2 ttl=46 time=21.9 ms
64 bytes from nrt19s17-in-f14.1e100.net (173.194.38.78): icmp_req=3 ttl=46 time=14.0 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 14.006/17.750/21.997/3.285 ms


[ syslog-ng,openssh ]
syslogとsshd。ついでにインストール済みのcornも自動起動設定

# pacman -Sy openssh syslog-ng
# systemctl enable syslog-ng.service
# systemctl start syslog-ng.service
# 
# systemctl enable sshd.service
# systemctl start sshd.service
#
# systemctl enable cronie.service
# systemctl start cronie.service
# 


[ net-tools,dnsutils ]
ifconfig,netstat,digなどのネットワーク系コマンドツール

# pacman -Sy net-tools dnsutils
#


[ sysstat,mlocate ]
sarなどモニタリングツールおよびlocateコマンド

# pacman -Sy sysstat mlocate
#


[ rc.local ]
ちょっとした処理で、systemdをいじるのが手間なので、rc.local相当を作成しておく

# vi /etc/rc.local
# cat /etc/rc.local
---
#!/bin/bash

touch /tmp/hoge # test

---
# 
# chmod +x /etc/rc.local
#
# vi /usr/lib/systemd/system/rc-local.service
# cat /usr/lib/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
Wants=network.target

[Service]
Type=oneshot
ExecStart=/etc/rc.local
TimeoutSec=0
#StandardInput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

# ln -s /usr/lib/systemd/system/rc-local.service /etc/systemd/system/multi-user.target.wants/
# systemctl --system daemon-reload
# systemctl enable rc-local.service


[ 固定IP設定 ]

# vi /etc/conf.d/network
# cat /etc/conf.d/network
interface=eth0
address=10.0.18.204
netmask=24
broadcast=10.0.18.255
gateway=10.0.18.254
# 
# vi /usr/lib/systemd/system/network.service
# cat vi /usr/lib/systemd/system/network.service
[Unit]
Description=Network Connectivity
Wants=network.target
Before=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}

[Install]
WantedBy=multi-user.target

# ln -s /usr/lib/systemd/system/network.service /etc/systemd/system/multi-u                                                          ser.target.wants/
# systemctl enable network.service
# 


・Yaourtのインストール
AURを使用する場合。公式パッケージ(pacman)で事足りる場合は特に不要。

# pacman -Sy diffutils gettext yajl curl wget
#
# cd /usr/local/src
# wget https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz
# tar xvzf package-query.tar.gz
#
# cd package-query
# makepkg --asroot ; echo $?
# pacman -U package-query-1.0.1-1-i686.pkg.tar.xz
#
# cd ../
# wget https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz
# tar xvzf yaourt.tar.gz
#
# cd yaourt
# makepkg --asroot ; echo $?
# pacman -U yaourt-1.1-1-any.pkg.tar.xz
# 

以上

・参照

https://wiki.archlinux.org/index.php/Installation_Guide
https://wiki.archlinux.org/index.php/Systemd
https://wiki.archlinux.org/index.php/Yaourt

tarで圧縮、展開の一括処理

tarコマンドを使い、ファイルやディレクトリ単位で一括圧縮/展開処理する場合のメモ


・複数ファイルを、個別に圧縮する

$ ls test*
testfile001  testfile002  testfile003  testfile004  testfile005
$ 
$ ls test* | xargs -n1 -i tar cvzf {}.tar.gz {}
testfile001
testfile002
testfile003
testfile004
testfile005
$ 
$ ls *.tar.gz
testfile001.tar.gz  testfile003.tar.gz  testfile005.tar.gz
testfile002.tar.gz  testfile004.tar.gz


・複数のアーカイヴを一括展開する

$ ls
testfile001.tar.gz  testfile003.tar.gz  testfile005.tar.gz
testfile002.tar.gz  testfile004.tar.gz
$ 
$ ls *.tar.gz | xargs -n1 tar xvzf
testfile001
testfile002
testfile003
testfile004
testfile005
$ 
$ ls
testfile001         testfile002.tar.gz  testfile004         testfile005.tar.gz
testfile001.tar.gz  testfile003         testfile004.tar.gz
testfile002         testfile003.tar.gz  testfile005


・複数のアーカイヴを指定のディレクトリに一括展開する

$ mkdir /tmp/hoge
$ ls
testfile001.tar.gz  testfile003.tar.gz  testfile005.tar.gz
testfile002.tar.gz  testfile004.tar.gz
$ 
$ ls *.tar.gz | xargs -n1 -i tar xvzf {} -C /tmp/hoge
testfile001
testfile002
testfile003
testfile004
testfile005
$
$ ls /tmp/hoge
testfile001  testfile002  testfile003  testfile004  testfile005

以上

スクリプト小ネタ(rrping)

WindowsでいうところのExPingみたいな複数ホストへのPingツールが欲しかったので、見かけだけそれっぽいツールを作ってみた。
使い方は引数にIPアドレスもしくは名前を付けて実行、「Ctr+C」で終了。

$ chmod u+x rrping.sh
$ ./rrping.sh 192.168.0.1 172.16.0.1 10.0.0.1


bashのブレース展開を使ったり、teeログに落としたり。

$ ./rrping.sh 192.168.0.{1,2,3,4,5} | tee hoga.log


IPアドレスを羅列したリストを読み込む

$ cat iplist.txt
192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
$ 
$ cat iplist.txt | xargs ./rrping.sh


rrping.sh

#!/bin/bash

# rrping.sh - Round Robin ping tool -
#
# Usage) ./rrping.sh ipaddr1 ipaddr2 ipaddr3 ...even more
#        ./rrping.sh 10.0.0.{1,2,3,4,5}
#

# ARGS
## Number of ping execution
count=1
## Unknown Host timeout (Sec)
timeout=1
## Interval time (Sec)
interval=0.5

# PING Status Color
## Green
ok_color=32
## Red
ng_color=31

ip_array=($@)

echo "Status/Date/Name/IPaddr/Time"
while :;do
 for (( i = 0; i < ${#ip_array[@]}; ++i ))
  do
   date=`date "+%Y/%m/%d %T"`
   ping=`/bin/ping -c $count -W $timeout ${ip_array[$i]} | grep ttl= 2>/dev/null`
   if [ -n "$ping" ]; then
        #echo -n "[OK] "
        echo -en "\033[1;${ok_color}m[OK] \033[0m"

        name_check=`echo $ping | grep \(`
        if [ -n "$name_check" ]; then
            result=(`echo $ping | awk '{print $5,$8}'`)
            echo "$date ${ip_array[$i]}: ${result[0]} ${result[1]} ms"
        else
            result=(`echo $ping | awk '{print $4,$7}'`)
            echo "$date ${ip_array[$i]}: ${result[0]} ${result[1]} ms"
        fi
   else
        #echo -n "[NG] "
        echo -en "\033[1;${ng_color}m[OK] \033[0m"
        echo "$date ${ip_array[$i]}: failed to ping."
   fi
   sleep $interval
  done
done

以上

Arch Linuxインストールメモ (archlinux-2012.07.15)


######################################################################

※2013/2/15追記
archlinux-2013.02.01のインストール手順をこちらに書きました。

Arch Linuxインストールメモ (archlinux-2013.02.01)
http://extrea.hatenablog.com/entry/2013/02/15/123721

######################################################################



以下、旧文


本バージョンよりAIFが無くなりインストール手順がますます難解になったので、メモとしてまとめてみる。

※AIF(Arch Installation Framework/いわゆるインストーラー)


・前提
ISO: archlinux-2012.07.15-netinstall-dual.iso
(Linux Kernel 3.4.4)

・メディアからのブート
上記イメージよりブート。
今回は64bit版を選択する。

f:id:extrea:20120730172626p:plain

ブート完了後、インストール用のライブOSが起動したところ。
(rootでログインした状態)

f:id:extrea:20120730172646p:plain

事前準備として、まずは日本語キーボードを使えるようにする。

# loadkeys jp106


・インストール準備

[ Network ]
手動設定を行う。
(DHCP環境なら起動時点で、ネットワークがつかえるはず)

# ifconfig eth0 up
# ifconfig eth0 netmask 255.255.255.0 10.0.18.204
# route add default gw 10.0.18.254 metric 1
# vi /etc/resolv.conf
# cat /etc/resolv.conf

### Google Public DNS
nameserver 8.8.8.8
nameserver 8.8.4.4

# ping google.com
PING google.com (173.194.38.78) 56(84) bytes of data.
64 bytes from nrt19s17-in-f14.1e100.net (173.194.38.78): icmp_req=1 ttl=46 time=17.2 ms
64 bytes from nrt19s17-in-f14.1e100.net (173.194.38.78): icmp_req=2 ttl=46 time=21.9 ms
64 bytes from nrt19s17-in-f14.1e100.net (173.194.38.78): icmp_req=3 ttl=46 time=14.0 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 14.006/17.750/21.997/3.285 ms

ついでに、リモートから作業できるようにsshdを起動する。

# passwd  # rootユーザのパスワードを設定
# /etc/rc.d/sshd start


[ Disk Partition ]
ディスクパーティションの設定。
本環境では、/dev/sdaをインストール先HDDとして使用する。

Disk Size: 15GB

device mountpoint size
/dev/sda1 /boot 100MB
/dev/sda2 swap 512MB
/dev/sda3 /var 5000MB
/dev/sda4 / 残り全て

 

# fdisk /dev/sda
# fdisk -l /dev/sda

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders, total 31457280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xbd047ddc

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      206847      102400   83  Linux
/dev/sda2          206848     1255423      524288   82  Linux swap / Solaris
/dev/sda3         1255424    11741183     5242880   83  Linux
/dev/sda4        11741184    31457279     9858048   83  Linux

※bootパーティションへbootフラグの付与を忘れない事
※fdiskの使い方は このあたりを参照の事。


[ Format ]
/(root),/varパーティションは、ext4でフォーマットする。
/bootパーティションは無難にext2がいいかな。
(Grub version0.97ってpatchを当てない限り、標準ではext4未対応のハズ)

# grub --version
grub (GNU GRUB 0.97)
# 
# mkfs.ext2 /dev/sda1
# mkfs.ext4 /dev/sda3
# mkfs.ext4 /dev/sda4
# 


[ Mount ]
先ほど作成した/dev/sdaの各パーティションを、ライブOSの/mnt配下にマウント。

# mount /dev/sda4 /mnt		# rootパーティションのマウント
# mkdir -p /mnt/{boot,var}	# /boot,/var用マウントポイント作成
# mount /dev/sda1 /mnt/boot	# /bootパーティション
# mount /dev/sda3 /mnt/var	# /varパーティション
# df -hT
Filesystem                   Type      Size  Used Avail Use% Mounted on
rootfs                       rootfs    673M  330M  343M  50% /
dev                          devtmpfs  114M     0  114M   0% /dev
run                          tmpfs     122M   21M  101M  18% /run
/dev/sr0                     iso9660   370M  370M     0 100% /run/archiso/bootmnt
cowspace                     tmpfs     183M   19M  165M  11% /run/archiso/cowspace
/dev/loop0                   squashfs   97M   97M     0 100% /run/archiso/sfs/root-image
/dev/mapper/arch_root-image  ext4      673M  330M  343M  50% /
/dev/loop3                   squashfs   35M   35M     0 100% /run/archiso/sfs/lib-modules
/dev/mapper/arch_lib-modules ext4       93M   42M   51M  46% /usr/lib/modules
/dev/loop6                   squashfs   55M   55M     0 100% /run/archiso/sfs/usr-share
/dev/mapper/arch_usr-share   ext4      415M  168M  247M  41% /usr/share
shm                          tmpfs     122M     0  122M   0% /dev/shm
tmpfs                        tmpfs     122M     0  122M   0% /tmp
/dev/sda4                    ext4      9.4G  270M  8.7G   3% /mnt
/dev/sda1                    ext2       96M   14K   91M   1% /mnt/boot
/dev/sda3                    ext4      5.0G  203M  4.6G   5% /mnt/var


・システムのインストール

[ mirrorlist ]
一番近いミラー先を使用できるように、リストの先頭に
Score値0.1にて、日本のレポジトリを追記。

# cp -p /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.org
# vi /etc/pacman.d/mirrorlist
# diff -wb /etc/pacman.d/mirrorlist.org /etc/pacman.d/mirrorlist
6a7,8
> ## Score: 0.1, Japan
> Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch


[ System Install ]
pacstrapスクリプトにて必要なパッケージグループを指定し、インストールを行う。

今回はGUI不要の為、基本的なパッケージグループのみ選択。

- base
- base-devel
 

# pacstrap /mnt base base-devel
==> Creating install root at /mnt
==> Installing packages to /mnt
warning: database file for 'core' does not exist
warning: database file for 'extra' does not exist
warning: database file for 'community' does not exist
:: Synchronizing package databases...
 core                                      107.7 KiB   962K/s 00:00 [######################################] 100%
 extra                                    1408.3 KiB  2.12M/s 00:01 [######################################] 100%
 community                                1766.5 KiB  1532K/s 00:01 [######################################] 100%

~ 中略 ~

%
(130/132) installing make                                           [######################################] 100%
(131/132) installing patch                                          [######################################] 100%
Optional dependencies for patch
    ed: Interpret the patch as an ed script; for patch -e functionality(deprecated)
(132/132) installing pkg-config                                     [######################################] 100%
# 


[ Bootloader ]
Bootloaderは以下より選択する。

- grub-bios
- grub-efi-x86_64
- syslinux

通常はgrub-biosになるかと。

# pacstrap /mnt grub-bios
# 


・システム設定

[ fstab ]

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


[ chroot ]
以降は、新規インストールしたシステムにchrootして作業する。

# arch-chroot /mnt
# 


[ Hostname ]
適宜設定。

# echo "arch03.localdomain" >> /etc/hostname
# 


[ Timezone ]

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


[ Locale ]

# echo "LANG=ja_JP.UTF-8" >> /etc/locale.conf
# 
# cp -p /etc/locale.gen /etc/locale.gen.org
# vi /etc/locale.gen
# diff -wb /etc/locale.gen.org /etc/locale.gen
278c278
< #ja_JP.UTF-8 UTF-8
---
> ja_JP.UTF-8 UTF-8

# 
# locale-gen
Generating locales...
  ja_JP.UTF-8... done
Generation complete.


[ ram image ]

# mkinitcpio -p linux
# 


[ grub install ]

# grub-install --target=i386-pc --boot-directory=/boot --recheck --debug /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg
# 


[ root passwort]
rootユーザーのパスワードを設定。

# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully


・swapの設定

# fdisk -l
# mkswap /dev/sda2
# swapon /dev/sda2
# swapon -s
# 
# echo "/dev/sda2 swap swap defaults 0 0" >> /etc/fstab
# 


・再起動
chroot環境より抜けインストール用ディレクトリをunmount後、システム再起動。

# exit
# umount /mnt/{boot,var,}
# reboot
# 


・初期設定
このままだとネットワーク系の基本コマンドすら使えないので、必要最低限のパッケージを追加する。

[ resolver ]

# echo "nameserver 8.8.8.8" >> /etc/resolv.conf
# echo "nameserver 8.8.4.4" >> /etc/resolv.conf
# 


[ network ]
ISOブート時と同じく、DHCP環境なら設定不要。
手動の場合は以下のファイルを編集する。


[ rc.conf ]

# cp -p /etc/rc.conf /etc/rc.conf.org
# vi /etc/rc.conf
# diff -wb /etc/rc.conf.org /etc/rc.conf
9,12c9,12
< HARDWARECLOCK=
< TIMEZONE=
< KEYMAP=
< CONSOLEFONT=
---
> HARDWARECLOCK="UTC"
> TIMEZONE="Asia/Tokyo"
> KEYMAP="jp106"
> CONSOLEFONT="161"
27c27
< HOSTNAME=
---
> HOSTNAME="arch03.localdomain"
29,33c29,33
< interface=
< address=
< netmask=
< broadcast=
< gateway=
---
> interface=eth0
> address=10.0.18.206
> netmask=255.255.255.0
> broadcast=10.0.18.255
> gateway=10.0.18.254
40c40
< DAEMONS=(syslog-ng network crond)
---
> DAEMONS=(syslog-ng network sshd crond sysstat)


[ package ]
個人的に最低限必要だと思うパッケージは以下の通り

# pacman -Sy dnsutils \
iana-etc \
inetutils \
iproute2 \
iptables \
kbd \
mlocate \
net-tools \
netcfg \
openssh \
openssl \
pam \
tzdata\
sysstat

# 


・Yaourtのインストール
AURを使用する場合。公式パッケージ(pacman)で事足りる場合は特に不要。

# pacman -Sy base-devel
# pacman -Sy diffutils gettext yajl curl
#
# cd /usr/local/src
# wget https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz
# tar xvzf package-query.tar.gz
#
# cd package-query
# makepkg --asroot ; echo $?
# pacman -U package-query-1.0.1-1-i686.pkg.tar.xz
#
# cd ../
# wget https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz
# tar xvzf yaourt.tar.gz
#
# cd yaourt
# makepkg --asroot ; echo $?
# pacman -U yaourt-1.1-1-any.pkg.tar.xz
# 

以上

・参照

https://wiki.archlinux.org/index.php/Arch_Install_Scripts
https://wiki.archlinux.org/index.php/GRUB2
https://wiki.archlinux.org/index.php/Yaourt

Windows Azure Platforme ベンチマーク (Linux/Smallインスタンス)

Windows Azure PlatformeにてLinux仮想マシンがサポートされた為、無償評価期間を利用して試してみる。

※登録には要クレジットカード

※現時点(2012/06/21)では、Virtual Machineの実行機能自体がPreview扱いの為、サインアップ後に[Management Portal] - [Account] - [PreviewFeatures] -[Virtual Machines & Virtual Networks] - [try it now]を選択し、アクティベートする必要があります。

・環境
Plan: S(Small) (1.6 GHz CPU、1.75 GB RAM、165 GB ストレージ)
Location: EastAsia
OS: CentOS release 6.2 (Final)

/proc/cpuinfo
意外にもAMDのCPUですね。
この型番で検索すると、HPのSL335sというスケールアウト環境向けサーバがよくヒットするので、DCにはこれらがずらりと並んでいる姿を想像してしまいました。

processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 16
model           : 8
model name      : AMD Opteron(tm) Processor 4171 HE
stepping        : 1
cpu MHz         : 2094.719
cache size      : 512 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb lm 3dnowext 3dnow up rep_good extd_apicid unfair_spinlock pni cx16 popcnt hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw
bogomips        : 4189.43
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:


/proc/meminfo

MemTotal:        1785252 kB
MemFree:         1185360 kB
Buffers:           46264 kB
Cached:           415752 kB
SwapCached:            0 kB
Active:           130032 kB
Inactive:         352104 kB
Active(anon):      20276 kB
Inactive(anon):        8 kB
Active(file):     109756 kB
Inactive(file):   352096 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:         20132 kB
Mapped:            13116 kB
Shmem:               172 kB
Slab:              78256 kB
SReclaimable:      56560 kB
SUnreclaim:        21696 kB
KernelStack:         896 kB
PageTables:         3432 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      892624 kB
Committed_AS:     149836 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       17168 kB
VmallocChunk:   34359713892 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:        6144 kB
DirectMap2M:     1763328 kB
DirectMap1G:     1048576 kB


df

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       28G  7.0G   19G  27% /
tmpfs                 872M     0  872M   0% /dev/shm
/dev/sda1             485M   64M  396M  14% /boot
/dev/sdb1              69G  5.2G   61G   8% /mnt/resource


fdisk

# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001bfeb

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3917    30943232   8e  Linux LVM

Disk /dev/sdb: 75.2 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf896a09e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        9138    73398272   83  Linux

Disk /dev/mapper/VolGroup-lv_root: 29.6 GB, 29603397632 bytes
255 heads, 63 sectors/track, 3599 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_root doesn't contain a valid partition table

Disk /dev/mapper/VolGroup-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_swap doesn't contain a valid partition table


hdparm
AWSと同じくプランに応じてI/O性能に制限をかけているのでしょう。

# hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   5920 MB in  2.00 seconds = 2965.53 MB/sec
 Timing buffered disk reads:   38 MB in  3.13 seconds =  12.14 MB/sec

# hdparm -tT /dev/sdb
/dev/sdb:
 Timing cached reads:   5612 MB in  2.00 seconds = 2810.77 MB/sec
 Timing buffered disk reads:  642 MB in 134.84 seconds =   4.76 MB/sec


dd
/dev/sdbの書き込みがとても速いのですが、Read性能と釣り合いませんね。

# dd if=/dev/zero of=./test.img bs=1024k count=5120
/dev/sda
5120+0 records in
5120+0 records out
5368709120 bytes (5.4 GB) copied, 635.012 s, 8.5 MB/s

/dev/sdb
0
5120+0 records in
5120+0 records out
5368709120 bytes (5.4 GB) copied, 10.2106 s, 526 MB/s


UnixBench

# wget http://byte-unixbench.googlecode.com/files/UnixBench5.1.3.tgz
# tar xvzf UnixBench5.1.3.tgz
# cd ./UnixBench
# make
# export LANG=C
# ./Run
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: testvm01: GNU/Linux
   OS: GNU/Linux -- 2.6.32-220.17.1.el6.x86_64 -- #1 SMP Wed May 16 00:01:37 BST 2012
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: AMD Opteron(tm) Processor 4171 HE (4189.4 bogomips)
          Hyper-Threading, x86-64, MMX, AMD MMX, Physical Address Ext, SYSCALL/SYSRET
   23:09:20 up 12:05,  1 user,  load average: 0.19, 0.40, 0.21; runlevel 3

------------------------------------------------------------------------
Benchmark Run: Wed Jun 20 2012 23:09:20 - 23:37:10
1 CPU in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       17654039.5 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     1862.7 MWIPS (8.7 s, 7 samples)
Execl Throughput                               1007.2 lps   (29.8 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        600620.9 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          180835.6 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       1088958.6 KBps  (30.0 s, 2 samples)
Pipe Throughput                             1102561.0 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 230938.4 lps   (10.0 s, 7 samples)
Process Creation                              11629.1 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   2054.8 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    279.6 lpm   (60.2 s, 2 samples)
System Call Overhead                        1392271.0 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   17654039.5   1512.8
Double-Precision Whetstone                       55.0       1862.7    338.7
Execl Throughput                                 43.0       1007.2    234.2
File Copy 1024 bufsize 2000 maxblocks          3960.0     600620.9   1516.7
File Copy 256 bufsize 500 maxblocks            1655.0     180835.6   1092.7
File Copy 4096 bufsize 8000 maxblocks          5800.0    1088958.6   1877.5
Pipe Throughput                               12440.0    1102561.0    886.3
Pipe-based Context Switching                   4000.0     230938.4    577.3
Process Creation                                126.0      11629.1    922.9
Shell Scripts (1 concurrent)                     42.4       2054.8    484.6
Shell Scripts (8 concurrent)                      6.0        279.6    465.9
System Call Overhead                          15000.0    1392271.0    928.2
                                                                   ========
System Benchmarks Index Score                                         759.7


Bonnie++

# wget http://www.coker.com.au/bonnie++/bonnie++-1.03e.tgz
# tar xvzf bonnie++-1.03e.tgz
# cd bonnie++-1.03e
# ./configure; echo $?
# cp -p bonnie.h bonnie.h.org
# sed  -i s/#define\ MinTime\ \(0.5\)/#define\ MinTime\ \(0.01\)/g bonnie.h
# diff -wb bonnie.h.org bonnie.h
# make; echo $?
#  ./bonnie++ -d /tmp -u root
Using uid:0, gid:0.
Writing with putc()...done
Writing intelligently...done
Rewriting...done
Reading with getc()...done
Reading intelligently...done
start 'em...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version 1.03e       ------Sequential Output------ --Sequential Input- --Random-
                    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
testvm01      3480M  8279  19  7364   1  6231   2 11969  43 130630  19  2090  15
                    ------Sequential Create------ --------Random Create--------
                    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 59207  82 620391  98 111536 100 79158  99 886291 102 110599  99
testvm01,3480M,8279,19,7364,1,6231,2,11969,43,130630,19,2089.9,15,16,59207,82,620391,98,111536,100,79158,99,886291,102,110599,99

#  ./bonnie++ -d /mnt/resource -u root
Using uid:0, gid:0.
Writing with putc()...done
Writing intelligently...done
Rewriting...done
Reading with getc()...done
Reading intelligently...done
start 'em...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version 1.03e       ------Sequential Output------ --Sequential Input- --Random-
                    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
testvm01      3480M 47873  93 100156  20 114472  31 58858  97 396789  41 17417  57
                    ------Sequential Create------ --------Random Create--------
                    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 78650  98 615335  97 112619 100 64659  99 895204  98 111012  98
testvm01,3480M,47873,93,100156,20,114472,31,58858,97,396789,41,17417.2,57,16,78650,98,615335,97,112619,100,64659,99,895204,98,111012,98

以上

Arch Linuxインストールメモ (archlinux-2011.08.19)


######################################################################

※2013/2/15追記
archlinux-2013.02.01のインストール手順をこちらに書きました。

Arch Linuxインストールメモ (archlinux-2013.02.01)
http://extrea.hatenablog.com/entry/2013/02/15/123721

######################################################################



以下、旧文


普段使用しているインストールパラメータは以下の通りです。


・前提
OS: archlinux-2011.08.19

・インストール

# /arch/setup
1 Select souce
	core-local

2 Set Editor
	vi

3 Set Clock
	Asia/Tokyo UTC

4 Prepare hard drive(s)
	1 Auto-Prepare
	Partition:
	 /boot	100MB
	 swap	適宜
	 /	残り全て
	 /home	100MB

	FileSystem:
	 ext4

5 Select Package
	bootloader:
	 grub
	Package Groups:
	 base

	Install Packages
	 dnsutils
	 iana-etc
	 inetutils
	 iproute2
	 iptables
	 kbd
	 mlocate
	 net-tools
	 netcfg
	 openssh
	 openssl
	 packman-mirrorlist
	 pam
	 tzdata

	 ※あとはbaseパッケージ全てと、必要に応じ適宜

6 Install packages

7 Configure system
	/etc/rc.conf
         KEYMAP="jp106"
         HOSTNAME="hoge.localdomain"
         interface=eth0
	 address=x.x.x.x
	 netmask=255.255.255.0
	 broadcast=x.x.x.255
	 gateway=x.x.x.254
         DAEMONS=(... network sshd ...)

	/etc/pacman/mirrorlist
	※「Japan」の項目をアンコメント

	Root-Password
	 適宜

8 Install bootloader
	※特にmenu.lstは編集しない

9 Exit Install

# reboot


・初回アップデート

# pacman -Sy
# pacman -S filesystem --force
※この時点ではpacman自体はアップグレードしない
# pacman -Syu
# updatedb
# pacman-key --init
gpg: /etc/pacman.d/gnupg/trustdb.gpg: trustdb created
gpg: no ultimately trusted keys found
gpg: Generating pacman keychain master key...

※この後、乱数生成の為しばらくの間、ランダムにキーを押下
※上記はコンソールでの実行が必要。ssh越しなら以下ページ末URLを参照

# pacman -Syu
※再度実行

※下記のようなエラーがでたら・・・
glibc: /usr/bin/tzselect exists in filesystem

error: failed to commit transaction (conflicting files)
glibc: /usr/bin/tzselect exists in filesystem
glibc: /usr/sbin/zdump exists in filesystem
glibc: /usr/sbin/zic exists in filesystem
Errors occurred, no packages were upgraded.

# rm /usr/bin/tzselect /usr/sbin/zdump /usr/sbin/zic
# pacman -Syu

もしくは

error: failed to commit transaction (conflicting files)
initscripts: /etc/profile.d/locale.sh exists in filesystem
Errors occurred, no packages were upgraded.

# rm /etc/profile.d/locale.sh
# pacman -Syu


・Yaourtのインストール
AURを使用する場合。公式パッケージ(pacman)で事足りる場合は特に不要。

# pacman -Sy base-devel
# pacman -Sy diffutils gettext yajl curl
#
# cd /usr/local/src
# wget https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz
# tar xvzf package-query.tar.gz
#
# cd package-query
# makepkg --asroot ; echo $?
# pacman -U package-query-1.0.1-1-i686.pkg.tar.xz
#
# cd ../
# wget https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz
# tar xvzf yaourt.tar.gz
#
# cd yaourt
# makepkg --asroot ; echo $?
# pacman -U yaourt-1.1-1-any.pkg.tar.xz

以上

・参照
https://wiki.archlinux.org/index.php/Official_Installation_Guide_%28%E6%97%A5%E6%9C%AC%E8%AA%9E%29
https://wiki.archlinux.org/index.php/Pacman-key#How_can_I_collect_entropy.3F
https://wiki.archlinux.org/index.php/Yaourt

Arch LinuxでLIOを使う(iSCSI Target)

Arch Linuxで手軽に使えるiSCSI Targetは無いかと調べていたら、Kernel 2.6.38以降ではLIOというターゲットがすでに標準で使えるらしい。

iSCSIの他にもFibre Channel (QLogic), FCoE,InfiniBandに対応していて、かなり高機能。

さらにはSCSI-3 Persistent reservationsにも対応しており、MSFC用としても良さそうなので早速試してみる。
※機能詳細は公式Web参照

LIO本体は上述の通りカーネルモジュール(target_core_mod 等)となるため、あとは設定ツールのみ用意する。

ツールには標準の「lio-util」もしくはブランチとなる「targetcli-fb」が存在し、今回は設定が容易な後者を選択する。

・環境
OS: Arch Linux (3.3.7-1-ARCH) (32-bit)
ターゲットディスク: /dev/sda4
IPアドレス(IP-SAN用): 2.2.2.1/24

・前提
各パッケージの依存関係解決が大変なので、yaouortを使用する。

・yaourtのインストール

# pacman -Sy diffutils gettext yajl
# cd /usr/local/src
# wget https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz
# tar xvzf package-query.tar.gz
# cd package-query
# makepkg --asroot ; echo $?
# pacman -U package-query-1.0.1-1-i686.pkg.tar.xz
# cd ../
# wget https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz
# tar xvzf yaourt.tar.gz
# cd yaourt
# makepkg --asroot ; echo $?
# pacman -U yaourt-1.1-1-any.pkg.tar.xz
# cd ../


・targetcli-fbのインストール

# pacman -Sy python2-distribute
# yaourt targetcli-fb
※「Edit PKGBUILD ?」は「N」、その他は「Y」で。


・LIOの起動

# /etc/rc.d/target start
:: Mounting configfs                      [DONE]
:: Starting lio targets                   [BUSY]
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
Restore file /etc/target/saveconfig.json not found
                                          [DONE]

※configはまだ作成していないのでnot foundで問題なし


・ターゲットディスクのPATH確認
ディスクの指定にPCIのパスを使用する為、事前確認。

# ls -l /dev/disk/by-path
total 0
lrwxrwxrwx 1 root root  9 Jun  2 17:42 pci-0000:00:10.0-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root 10 Jun  2 17:42 pci-0000:00:10.0-scsi-0:0:0:0-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jun  2 17:42 pci-0000:00:10.0-scsi-0:0:0:0-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Jun  2 17:42 pci-0000:00:10.0-scsi-0:0:0:0-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Jun  2 17:42 pci-0000:00:10.0-scsi-0:0:0:0-part4 -> ../../sda4


・LIO設定 - 初期状態

# targetcli
Welcome to the targetcli shell:

 Copyright (c) 2011 by RisingTide Systems LLC.

 For help on commands, type 'help'.

/>
/>
/> ls

o- / ................................ [...]
  o- backstores ..................... [...]
  | o- block ........... [0 Storage Object]
  | o- fileio .......... [0 Storage Object]
  | o- pscsi ........... [0 Storage Object]
  | o- ramdisk ......... [0 Storage Object]
  o- ib_srpt .................. [Not found]
  o- iscsi ..................... [0 Target]
  o- loopback .................. [0 Target]
  o- qla2xxx .................. [Not found]
  o- tcm_fc ................... [Not found]
/>


・LIO設定 - ターゲットブロック作成

/> cd backstores/block
/backstores/block> create block0 /dev/disk/by-path/ pci-0000:00:10.0-scsi-0:0:0:0-part4

Created block storage object block0 using /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-part4.
Entering new node /backstores/block/block0
/backstores/block>


・LIO設定 - ターゲットiqn作成

/backstores/block/block0> cd /iscsi
/iscsi>
/iscsi> create

Created target iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a.
Created TPG 1.
Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1
/iscsi/iqn.20...67a5552a/tpg1>
/iscsi/iqn.20...67a5552a/tpg1>
/iscsi/iqn.20...67a5552a/tpg1> ls
o- tpg1 .............. [enabled, auth]
  o- acls .................... [0 ACL]
  o- luns .................... [0 LUN]
  o- portals .............. [0 Portal]
/iscsi/iqn.20...67


・LIO設定 - Lun作成

/iscsi/iqn.20...67a5552a/tpg1> cd luns
/iscsi/iqn.20...52a/tpg1/luns> create /backstores/block/block0

Created LUN 0.
Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1/luns/lun0
/iscsi/iqn.20...pg1/luns/lun0>

・LIO設定 - ポータル作成(リッスンIP,ポート指定)

/iscsi/iqn.20...pg1/luns/lun0> cd ../../portals
/iscsi/iqn.20.../tpg1/portals>
/iscsi/iqn.20.../tpg1/portals> create 2.2.2.1 ip_port=3260

Using default IP port 3260
Created network portal 2.2.2.1:3260.
Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1/portals/2.2.2.1:3260
/iscsi/iqn.20...8.122.10:3260>


・LIO設定 - イニシエーターリスト作成

/iscsi/iqn.20...8.122.10:3260> cd ../../acls
/iscsi/iqn.20...52a/tpg1/acls>
/iscsi/iqn.20...52a/tpg1/acls> create iqn.2005-03.org.open-iscsi:hogehoge

Created Node ACL for iqn.2005-03.org.open-iscsi:hogehoge
Created mapped LUN 0.
Entering new node /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1/acls/iqn.2005-03.org.open-iscsi:hogehoge
/iscsi/iqn.20...scsi:hogehoge>
※必要なホストの数だけ登録する。


・LIO設定 - CHAP認証無効化
CHAP認証を使用しないため、デフォルト値より変更

/iscsi/iqn.20...scsi:hogehoge> cd /iscsi/iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a/tpg1/
/iscsi/iqn.20...67a5552a/tpg1>
/iscsi/iqn.20...67a5552a/tpg1> set attribute authentication=0

Parameter authentication is now '0'.
/iscsi/iqn.20...67a5552a/tpg1>


・LIO設定 - 設定確認

/iscsi/iqn.20...67a5552a/tpg1> cd /
/>
/> ls

o- / .................................. [...]
  o- backstores ....................... [...]
  | o- block ............. [1 Storage Object]
  | | o- block0  [/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-part4 activated]
  | o- fileio ............ [0 Storage Object]
  | o- pscsi ............. [0 Storage Object]
  | o- ramdisk ........... [0 Storage Object]
  o- ib_srpt .................... [Not found]
  o- iscsi ....................... [1 Target]
  | o- iqn.2003-01.org.linux-iscsi.arch01.i686:sn.0e7067a5552a ......... [1 TPG]
  |   o- tpg1 ..................... [enabled]
  |     o- acls ..................... [1 ACL]
  |     | o- iqn.2005-03.org.open-iscsi:hogehoge ................ [1 Mapped LUN]
  |     |   o- mapped_lun0 .......... [lun0 block/block0 (rw)]
  |     o- luns ..................... [1 LUN]
  |     | o- lun0  [block/block0 (/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-part4)]
  |     o- portals ............... [1 Portal]
  |       o- 2.2.2.1:3260 .............. [OK]
  o- loopback .................... [0 Target]
  o- qla2xxx .................... [Not found]
  o- tcm_fc ..................... [Not found]


・LIO設定 - 設定保存

/> saveconfig

Existing file /etc/target/saveconfig.json backed up to saveconfig.json.backup
Configuration saved to /etc/target/saveconfig.json
/> 
/> exit

Global pref auto_save_on_exit=true
Existing file /etc/target/saveconfig.json backed up to saveconfig.json.backup
Configuration saved to /etc/target/saveconfig.json


・起動確認

# netstat -anp | grep -i listen
tcp        0      0 0.0.0.0:22    0.0.0.0:* LISTEN 270/sshd
tcp        0      0 2.2.2.1:3260  0.0.0.0:* LISTEN -
tcp6       0      0 :::22         :::*      LISTEN 270/sshd
tcp6       0      0 :::80         :::*      LISTEN 578/httpd


・自動起動設定

# cp -p /etc/rc.conf /etc/rc.conf.20120601
# vi /etc/rc.conf
# diff -wb /etc/rc.conf.20110601 /etc/rc.conf
119c119
< DAEMONS=(hwclock syslog-ng net-profiles sshd netfs crond)
---
> DAEMONS=(hwclock syslog-ng net-profiles sshd netfs crond target)
#

以上

・参照
https://wiki.archlinux.org/index.php/ISCSI_Target