aws memo

AWS関連の備忘録 (※本ブログの内容は個人的見解であり、所属組織及び企業の意見を代弁するものではありません。1年以上古いエントリは疑ってかかってください)

CentOS6.5 HVM インスタンスを SR-IOV化する

2016.01.25 dkmsが抜けている手順のためカーネルアップデート後に正常に起動しないはずです。実際にはdkms化も加えてください。(参照)

2016.01.25 CentOS6.7, RHEL6.7はカーネルにSR-IOVドライバが入っていますのでわざわざ6.5でこのような面倒なことは避けたほうがよいです。

 

ーーー

 

素のCentOS6.5 なHVM AMIの作成方法についてはこちら。

   CentOS6.5を VM ImportでEC2にインポートする - aws memo

最近のインスタンスタイプでは、Enhanced Networking というSR-IOVによるネットワークの機能強化に対応している。(C3, I2, R3)

 

Enhanced Networkingを使うには、いくつかの条件を満たす必要がある。

ということで、素のCentOS6.5 HVM インスタンスを SR-IOV化する手順のメモ。

流れ
  1. CentOS6.5 HVM AMIから、VPC内にC3.8xlargeでインスタンス起動
  2. SR-IOVドライバをインストール
  3. udev周りの設定変更
  4. attribute変更
  5. 動作確認とAMI作成

手順

まずは CentOS6.5 HVM AMIを、VPC内に起動し、sshログイン。

SR-IOVドライバを取得する。ドライバはこちらから取得する。(2014年4月時点では2.14.2が最新)

Intel Ethernet Drivers and Utilities - Browse /ixgbevf stable at SourceForge.net

ビルド・設定する。大枠の手順はこちら(

Enabling Enhanced Networking on Linux Instances in a VPC - Amazon Elastic Compute Cloud

)

yum -y update && sudo yum -y install gcc make kernel-devel kernel-headers
yum -y install perl man pciutils
reboot
----
tar zxvf ixgbevf-2.14.2.tar.gz
cd ixgbevf-2.14.2/src
make install
echo "options ixgbevf InterruptThrottleRate=1,1,1,1,1,1,1,1" > /etc/modprobe.d/ixgbevf.conf

ここで、udevによる悪さ対策をしておく。(これをしないと、SR-IOVなNICがうまく認識されず、bootしてもsshログインできなくなる)

rm /etc/udev/rules.d/70-persistent-net.rules
cp /lib/udev/rules.d/75-persistent-net-generator.rules ~
vi /lib/udev/rules.d/75-persistent-net-generator.rules
diff  /lib/udev/rules.d/75-persistent-net-generator.rules ~/75-persistent-net-generator.rules 
93c93
< #DRIVERS=="?*", IMPORT{program}="write_net_rules"
---
> DRIVERS=="?*", IMPORT{program}="write_net_rules" 
reboot

udevで新しいeth0を認識しても そのルールを /etc/udev/rules.d/に書かないようにすることと、既存の ルールを削除しておくことの2点。

参考: SIOS "OSSよろず" ブログ出張所: CentOS 6 系で NIC 交換すると eth0 と認識されない

 次に、インスタンスをstopし、属性変更してSR-IOVを有効にする( on Mac OSX)

$ ec2-stop-instances  --region us-west-2 i-xxxxxxx 
$ ec2-modify-instance-attribute --region us-west-2 --sriov simple  i-xxxxxxx
$ ec2-describe-instance-attribute --region us-west-2 --sriov  i-xxxxxxx
sriovNetSupport     i-xxxxxxx    simple   
$ ec2-start-instances --region us-west-2 i-xxxxxxx 

その後sshでログインして確認。

# lsmod | grep ixgbevf
ixgbevf                58629  0 

# modinfo ixgbevf
ilename:       /lib/modules/2.6.32-431.11.2.el6.x86_64/kernel/drivers/net/ixgbevf/ixgbevf.ko
version:        2.14.2
license:        GPL
description:    Intel(R) 82599 Virtual Function Driver
author:         Intel Corporation, <linux.nics@intel.com>
srcversion:     50CBF6F36B99FE70E56C95A
alias:          pci:v00008086d00001515sv*sd*bc*sc*i*
alias:          pci:v00008086d000010EDsv*sd*bc*sc*i*
depends:        
vermagic:       2.6.32-431.11.2.el6.x86_64 SMP mod_unload modversions 
parm:           InterruptThrottleRate:Maximum interrupts per second, per vector, (956-488281, 0=off, 1=dynamic), default 1 (array of int)

# ethtool -i eth0 | grep driver
driver: ixgbevf

# dmesg | grep ixgbevf
ixgbevf: Intel(R) 10 Gigabit PCI Express Virtual Function Network Driver - version 2.14.2
ixgbevf 0000:00:03.0: setting latency timer to 64
ixgbevf: eth%d: ixgbevf_check_options: dynamic interrupt throttling enabled
ixgbevf 0000:00:03.0: irq 48 for MSI/MSI-X
ixgbevf 0000:00:03.0: irq 49 for MSI/MSI-X
ixgbevf 0000:00:03.0: irq 50 for MSI/MSI-X
ixgbevf 0000:00:03.0: Multiqueue Enabled: Rx Queue count = 2, Tx Queue count = 2
ixgbevf: eth0: ixgbevf_probe: Intel(R) 82599 Virtual Function
ixgbevf: eth0: ixgbevf_probe: GRO is enabled
ixgbevf: eth0: ixgbevf_probe: Intel(R) 10 Gigabit PCI Express Virtual Function Network Driver
ixgbevf 0000:00:03.0: NIC Link is Up 10 Gbps
ixgbevf: eth0: ixgbevf_change_mtu: changing MTU from 1500 to 9001

 

ここでcreate imageでHVM AMIを作成すると、SR-IOV属性が付いたHVM AMIが作成される。作成したHVM AMIを、VPC内にC3で起動すると、同じようにixgbevfドライバになっているはず。C3/I2/R3以外のタイプで起動する、or VPC外で起動すると通常のvifドライバになることを確認する。