CentOS 7.1.1503 armv7hl PoC (pre-alpha) for Raspberry Pi 2 Setup Toolを書いてみた

出すのが5ヶ月ぐらい遅い気がしますが、タイトルの通り”CentOS 7.1.1503 armv7hl PoC for Raspberry Pi 2“用のセットアップスクリプトを書いてみましたん。

例のごとく自分が楽するために書いたものなので、使うには不便なところもありますが、使えなくもないのでせっかくだから公開しておこうかと。
スクリプトはいつものようにGistで公開しています。

実行に必要な要件としては、Linuxが稼働するマシンで、作業領域として使用する “/tmp” が存在するパーティションの空き領域が最低6GBあり、root権限(sudoも可)で実行できることかな。
一応CentOS 6.7とDebian 8.1でスクリプトの動作確認をしていますが、保証はしません。
実行するとこんな感じ。

[root@localhost ~]# ./rpi2-centos-setup
rpi2-centos-setup Ver.0.0.1 pre-alpha
CentOS 7.1.1503 armv7hl PoC (pre-alpha) for Raspberry Pi setup tool

checking use commands: 
 wget                            :OK
 sha256sum                       :OK
 sed                             :OK
 python                          :OK
 xz                              :OK

 all comannd exists.

setup work environment
create directory: /tmp/rpi2-centos, /tmp/rpi2-centos/mnt
Are you sure you want to run?(y/n):
y
makedir: /tmp/rpi2-centos/mnt
*---------- Main menu ----------*
*) exit: type "exit"

1) All process execute
2) Sub menu
Select Option: 1
You selected 1) All process execute
Are you sure you want to run?(y/n):
y
download file: rpi2-centos-image.img.xz
--2015-11-26 02:02:13--  http://people.centos.org/hughesjr/armv7hl/rpi2/images/rpi2-centos-image.img.xz
Resolving people.centos.org... 50.28.24.115
Connecting to people.centos.org|50.28.24.115|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 240457036 (229M) [application/x-xz]
Saving to: `rpi2-centos-image.img.xz'

100%[==========================================================================================================================================>] 240,457,036 4.08M/s   in 61s

2015-11-26 02:03:15 (3.77 MB/s) - `rpi2-centos-image.img.xz' saved [240457036/240457036]

download file: succeeded. "rpi2-centos-image.img.xz"
download file: sha256sum.txt
--2015-11-26 02:03:15--  http://people.centos.org/hughesjr/armv7hl/rpi2/images/sha256sum.txt
Resolving people.centos.org... 50.28.24.115
Connecting to people.centos.org|50.28.24.115|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 180 [text/plain]
Saving to: `sha256sum.txt'

100%[==========================================================================================================================================>] 180         --.-K/s   in 0s

2015-11-26 02:03:16 (37.7 MB/s) - `sha256sum.txt' saved [180/180]

download file: succeeded. "sha256sum.txt"
decompress image: rpi2-centos-image.img.xz
rpi2-centos-image.img.xz (1/1)
    3.2 %                 7.3 MiB / 195.4 MiB = 0.037                     0:01
    3.3 %                7.5 MiB / 1341.9 MiB = 0.006   121 MiB/s   5 min 30 s
   65.0 %              149.1 MiB / 1998.1 MiB = 0.075    95 MiB/s         15 s
   99.8 %              229.1 MiB / 2774.9 MiB = 0.083    89 MiB/s          1 s
   99.9 %              229.3 MiB / 3653.9 MiB = 0.063    88 MiB/s          1 s
decompress image: succeeded. rpi2-centos-image.img
You must set cylinders.
You can do this from the extra functions menu.
mount image: succeeded. "rpi2-centos-image.img"
create homedir: succeeded copying of skel to "/tmp/rpi2-centos/mnt/home/pi"
create homedir: succeeded changing owner of "/tmp/rpi2-centos/mnt/home/pi"
create homedir: succeeded changeing mode of "/tmp/rpi2-centos/mnt/home/pi"
New password:
Retype new password:
compare password: succeeded.
passwd setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/passwd"
shadow setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/shadow"
group setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/group"
gshadow setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/gshadow"
sudoers setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/sudoers"
firewalld setting: succeeded changeing value to "/tmp/rpi2-centos/mnt/etc/firewalld/firewalld.conf"
sshd_config setting: succeeded value changeing of "/tmp/rpi2-centos/mnt/etc/ssh/sshd_config"
remove repo files: succeeded deleteing files "/tmp/rpi2-centos/mnt/etc/yum.repos.d/CentOS-*.repo"
unmount image: succeeded unmount "/tmp/rpi2-centos/mnt"
compless disk image: "rpi2-centos-image-mod.img"
rpi2-centos-image-mod.img (1/1)
    0.1 %                   3.0 MiB / 4.3 MiB = 0.689
    1.8 %                  7.3 MiB / 75.8 MiB = 0.096   6.9 MiB/s   9 min 50 s
    4.6 %                 7.3 MiB / 190.5 MiB = 0.038   9.1 MiB/s   7 min 10 s
    7.4 %                 7.3 MiB / 305.3 MiB = 0.024   9.8 MiB/s   6 min 30 s
   10.2 %                 7.3 MiB / 419.7 MiB = 0.017    10 MiB/s    6 min 0 s
   13.0 %                 7.4 MiB / 534.1 MiB = 0.014    10 MiB/s   5 min 40 s
   15.8 %                 7.4 MiB / 648.7 MiB = 0.011    11 MiB/s   5 min 30 s
   18.6 %                 7.4 MiB / 763.0 MiB = 0.010    11 MiB/s   5 min 10 s
   21.4 %                 7.4 MiB / 878.0 MiB = 0.008    11 MiB/s    5 min 0 s
   24.2 %                 7.4 MiB / 992.0 MiB = 0.007    11 MiB/s   4 min 50 s
   27.0 %                7.4 MiB / 1107.0 MiB = 0.007    11 MiB/s   4 min 40 s
   29.8 %                7.5 MiB / 1221.9 MiB = 0.006    11 MiB/s   4 min 30 s
   32.6 %                7.5 MiB / 1336.4 MiB = 0.006    11 MiB/s   4 min 10 s
   35.4 %                7.5 MiB / 1451.4 MiB = 0.005    11 MiB/s    4 min 0 s
   37.6 %                7.7 MiB / 1541.7 MiB = 0.005    11 MiB/s    4 min 0 s
   40.3 %                7.9 MiB / 1652.2 MiB = 0.005    11 MiB/s   3 min 50 s
   41.0 %               16.4 MiB / 1682.2 MiB = 0.010    10 MiB/s    4 min 0 s
   41.6 %               22.7 MiB / 1705.2 MiB = 0.013    10 MiB/s    4 min 0 s
   42.0 %               26.6 MiB / 1723.6 MiB = 0.015   9.5 MiB/s   4 min 10 s
   42.6 %               37.6 MiB / 1747.5 MiB = 0.022   9.1 MiB/s   4 min 20 s
   43.2 %               55.9 MiB / 1771.6 MiB = 0.032   8.8 MiB/s   4 min 30 s
   43.8 %               72.9 MiB / 1797.1 MiB = 0.041   8.5 MiB/s   4 min 30 s
   44.4 %               88.6 MiB / 1821.3 MiB = 0.049   8.2 MiB/s   4 min 40 s
   45.2 %              100.1 MiB / 1851.8 MiB = 0.054   8.0 MiB/s   4 min 40 s
   45.8 %              117.3 MiB / 1879.4 MiB = 0.062   7.8 MiB/s   4 min 50 s
   46.6 %              128.8 MiB / 1908.6 MiB = 0.067   7.6 MiB/s   4 min 50 s
   47.2 %              135.8 MiB / 1934.4 MiB = 0.070   7.4 MiB/s    5 min 0 s
   47.7 %              141.2 MiB / 1956.9 MiB = 0.072   7.2 MiB/s    5 min 0 s
   48.4 %              146.7 MiB / 1982.8 MiB = 0.074   7.1 MiB/s    5 min 0 s
   48.9 %              151.2 MiB / 2005.4 MiB = 0.075   6.9 MiB/s   5 min 10 s
   49.5 %              156.8 MiB / 2028.5 MiB = 0.077   6.7 MiB/s   5 min 10 s
   50.1 %              162.7 MiB / 2055.1 MiB = 0.079   6.6 MiB/s   5 min 10 s
   50.7 %              166.4 MiB / 2077.3 MiB = 0.080   6.5 MiB/s   5 min 20 s
   51.3 %              169.3 MiB / 2104.4 MiB = 0.080   6.4 MiB/s   5 min 20 s
   52.0 %              183.5 MiB / 2131.6 MiB = 0.086   6.2 MiB/s   5 min 20 s
   52.6 %              186.5 MiB / 2157.9 MiB = 0.086   6.1 MiB/s   5 min 20 s
   53.4 %              188.6 MiB / 2189.3 MiB = 0.086   6.1 MiB/s   5 min 20 s
   54.2 %              189.7 MiB / 2220.5 MiB = 0.085   6.0 MiB/s   5 min 20 s
   54.6 %              199.2 MiB / 2239.8 MiB = 0.089   5.9 MiB/s   5 min 20 s
   55.2 %              204.0 MiB / 2263.4 MiB = 0.090   5.8 MiB/s   5 min 20 s
   56.0 %              210.8 MiB / 2294.4 MiB = 0.092   5.7 MiB/s   5 min 20 s
   56.5 %              213.8 MiB / 2315.3 MiB = 0.092   5.6 MiB/s   5 min 20 s
   57.0 %              217.2 MiB / 2335.9 MiB = 0.093   5.5 MiB/s   5 min 20 s
   57.6 %              221.6 MiB / 2360.9 MiB = 0.094   5.5 MiB/s   5 min 20 s
   58.1 %              226.4 MiB / 2383.6 MiB = 0.095   5.4 MiB/s   5 min 20 s
   59.6 %              228.4 MiB / 2442.3 MiB = 0.094   5.4 MiB/s   5 min 10 s
   61.8 %              228.4 MiB / 2533.9 MiB = 0.090   5.5 MiB/s   4 min 50 s
   63.0 %              228.8 MiB / 2585.0 MiB = 0.089   5.5 MiB/s   4 min 40 s
   64.8 %              229.1 MiB / 2657.4 MiB = 0.086   5.5 MiB/s   4 min 20 s
   66.8 %              229.1 MiB / 2737.1 MiB = 0.084   5.6 MiB/s   4 min 10 s
   69.5 %              229.1 MiB / 2848.5 MiB = 0.080   5.7 MiB/s   3 min 40 s
   71.8 %              229.1 MiB / 2943.5 MiB = 0.078   5.8 MiB/s   3 min 20 s
   74.2 %              229.1 MiB / 3040.4 MiB = 0.075   5.8 MiB/s    3 min 0 s
   76.5 %              229.2 MiB / 3135.1 MiB = 0.073   5.9 MiB/s   2 min 50 s
   79.0 %              229.2 MiB / 3238.2 MiB = 0.071   6.0 MiB/s   2 min 30 s
   81.6 %              229.2 MiB / 3345.1 MiB = 0.069   6.1 MiB/s   2 min 10 s
   84.2 %              229.2 MiB / 3454.2 MiB = 0.066   6.2 MiB/s   1 min 50 s
   86.9 %              229.2 MiB / 3563.5 MiB = 0.064   6.2 MiB/s   1 min 30 s
   89.7 %              229.2 MiB / 3677.4 MiB = 0.062   6.3 MiB/s   1 min 10 s
   92.4 %              229.2 MiB / 3790.4 MiB = 0.060   6.4 MiB/s         50 s
   94.2 %              229.3 MiB / 3863.1 MiB = 0.059   6.4 MiB/s         40 s
   96.9 %              229.3 MiB / 3972.8 MiB = 0.058   6.5 MiB/s         20 s
   99.4 %              229.3 MiB / 4077.5 MiB = 0.056   6.6 MiB/s          2 s
compless disk image: succeeded. "rpi2-centos-image-mod.img.xz"
all process completed.
[root@localhost ~]#

出力しているログはこんな感じ。

[root@localhost ~]# tail -f /tmp/rpi2-centos/rpi2-centos-setup.log 
2015-11-26 02:02:01 [info]: rpi2-centos-setup start.
2015-11-26 02:02:12 [info]: You selected 1) All process execute
2015-11-26 02:02:13 [info]: download file: rpi2-centos-image.img.xz
2015-11-26 02:03:15 [info]: download file: succeeded. "rpi2-centos-image.img.xz"
2015-11-26 02:03:15 [info]: download file: sha256sum.txt
2015-11-26 02:03:16 [info]: download file: succeeded. "sha256sum.txt"
2015-11-26 02:03:16 [info]: decompress image: rpi2-centos-image.img.xz
2015-11-26 02:05:14 [info]: decompress image: succeeded. rpi2-centos-image.img
2015-11-26 02:05:14 [info]: mount image: succeeded. "rpi2-centos-image.img"
2015-11-26 02:05:14 [info]: create homedir: succeeded copying of skel to "/tmp/rpi2-centos/mnt/home/pi"
2015-11-26 02:05:14 [info]: create homedir: succeeded changing owner of "/tmp/rpi2-centos/mnt/home/pi"
2015-11-26 02:05:14 [info]: create homedir: succeeded changeing mode of "/tmp/rpi2-centos/mnt/home/pi"
2015-11-26 02:05:39 [info]: compare password: succeeded.
2015-11-26 02:05:39 [info]: passwd setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/passwd"
2015-11-26 02:05:39 [info]: shadow setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/shadow"
2015-11-26 02:05:39 [info]: group setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/group"
2015-11-26 02:05:39 [info]: gshadow setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/gshadow"
2015-11-26 02:05:39 [info]: sudoers setting: succeeded adding value to "/tmp/rpi2-centos/mnt/etc/sudoers"
2015-11-26 02:05:39 [info]: firewalld setting: succeeded changeing value to "/tmp/rpi2-centos/mnt/etc/firewalld/firewalld.conf"
2015-11-26 02:05:39 [info]: sshd_config setting: succeeded value changeing of "/tmp/rpi2-centos/mnt/etc/ssh/sshd_config"
2015-11-26 02:05:39 [info]: remove repo files: succeeded deleteing files "/tmp/rpi2-centos/mnt/etc/yum.repos.d/CentOS-*.repo"
2015-11-26 02:05:39 [info]: unmount image: succeeded unmount "/tmp/rpi2-centos/mnt"
2015-11-26 02:05:39 [info]: compless disk image: "rpi2-centos-image-mod.img"
2015-11-26 02:16:20 [info]: compless disk image: succeeded. "rpi2-centos-image-mod.img.xz"
2015-11-26 02:16:20 [info]: all process completed.

これで作成したイメージをmicroSDにライティングして、Raspberry Pi 2にセットして起動したら これで居場所でも探しつつ、このスクリプト中で入力したパスワードを使い、sshクライアントからpiユーザでログインしたら使えるかと思います。
rootはデフォルトでは使えないので、root権限が必要なコマンドはsudoを使えば良いと思います。(スクリプトでpiユーザはパスワードフリーにしてあります)

ちなみにログインした後は “yum” も使える状態になっています。(実は5ヶ月前から使えた気がする…)
再起動とかすると時刻が1970年1月1日になるので、下記の通りchronyを入れておくと若干幸せになるかも。

  1. sudo yum install chrony
  2. sudo systemctl enable chronyd
  3. sudo systemctl start chronyd
  4. sudo timedatectl set-timezone Asia/Tokyo
  5. reboot
  6. sudo yum check-update
  7. sudo yum update

「CentOS 7.1.1503 armv7hl PoC (pre-alpha) for Raspberry Pi 2 Setup Toolを書いてみた」への1件のフィードバック

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト / 変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト / 変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト / 変更 )

Google+ フォト

Google+ アカウントを使ってコメントしています。 ログアウト / 変更 )

%s と連携中