ブログタイトル募集中の新人SE記

ネットの片隅で非力を嘆く

【Mac】Raspberry Pi 3 に CentOS7 を入れてみた ③ 〜CentOS起動〜

f:id:SH000N:20161026015640j:plain

今回やること

背景

僕が馬鹿すぎて「よっしゃ遊べるドン!」と思ったら・・・

  • 変なシグナルビンビンwなんぞwww
    • コマンド打つ隙がないorz
    • マウス抜いたら直った
  • とりあえずREADME開く
    • :q!が打てぬ
    • 閉じれぬ
  • パーティション拡張muzui(; ;)
  • なぬ?もしやwifi拾えない???

...etc

とにかくいろいろ困ったので

起動から初期設定まで一気にやります

手順

Raspberry Pi起動

起動準備

機器接続

  1. USBキーボード接続
  2. LANケーブル接続
  3. HDMIケーブルとディスプレイ接続
  4. microSDをRaspberry Piに差し込む
  5. USBアダプタ接続

※USBアダプタを接続したらスグ電源が入ります

※必要のないもの(主にマウス)刺しとくと後でビビりますよ(笑)

ログイン

電源が入ると

  • デイスプレイにラズパイのアイコン出現
  • その下に英字がバーー
  • しばらく待つと下記が表示される
CentOS Linux 7 (Core)
centos-rpi3 login: 

上記が表示されたら

ユーザ名 root
パスワード centos

でログインできます

[root@centos-rpi3 ~]#

と表示されてればログイン成功

キーボード設定

09キー日本語レイアウトのキーボードの設定

# localectl set-keymap jp106
# localectl set-keymap jp-OADG109A

System Localeも変更

(コンソールに日本語表記が欲しい方のみ)

# localectl set-locale LANG=ja_JP.utf8

確認

# localectl

System Locale: LANG=ja_JP.utf8
       VC Keymap: jp-OADG109A
      X11 Layout: jp
       X11 Model: jp106
     X11 Options: terminate:ctrl_alt_bksp

上記のようになっていればおk

パーティション拡張

Rootパーティションのサイズ拡張

現状を確認

# df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       2.0G  682M  1.2G  38% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M  6.2M  457M   2% /run
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  300M   66M  235M  22% /boot
tmpfs            93M     0   93M   0% /run/user/0

2Gしかない( ;´Д`)

ので、拡張していく

1.partedコマンドを叩く

# parted /dev/mmcblk0

GNU Parted 3.1
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) 

2.pと打つ

(parted) p

Model: SD SA64G (sd/mmc)
Disk /dev/mmcblk0: 61.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  316MB   315MB   primary  fat16           lba
 2      316MB   852MB   537MB   primary  linux-swap(v1)
 3      852MB   3000MB  2147MB  primary  ext4

(parted)

3.rm 3と打つ

(parted) rm 3 

Error: Partition(s) 3 on /dev/mmcblk0 have been written, but we have been unable to inform the kernel of the change,
probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now
before making further changes.

Ignore/Cancel?

4.iと打つ

Ignore/Cancel? i

(parted)

5.pと打つ

(parted) p                                                                

Model: SD SA64G (sd/mmc)
Disk /dev/mmcblk0: 61.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End    Size   Type     File system     Flags
 1      1049kB  316MB  315MB  primary  fat16           lba
 2      316MB   852MB  537MB  primary  linux-swap(v1)

(parted)

6.mkpart primary 852M 32Gと打つ

61.9Gと記載されているサイトしか見つからなかったが、今回僕が使ったmicroSDが32Gだからか、ずっとエラー返ってきてて、32Gにしたら通りました

(parted) mkpart primary 852M 32G

Error: Partition(s) 3 on /dev/mmcblk0 have been written, but we have been unable to inform the kernel of the change,
probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now
before making further changes.

Ignore/Cancel?

7.iと打つ

Ignore/Cancel? i                                                          

(parted)

8.pと打つ

(parted) p                                                                

Model: SD SA64G (sd/mmc)
Disk /dev/mmcblk0: 61.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  316MB   315MB   primary  fat16           lba
 2      316MB   852MB   537MB   primary  linux-swap(v1)
 3      852MB   61.9GB  61.1GB  primary  ext4

(parted)

9.quitと打つ

(parted) quit                                                             

Information: You may need to update /etc/fstab.

再起動

# reboot

※まだ完了ではありません

ファイルシステム拡張

# resize2fs /dev/mmcblk0p3

resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mmcblk0p3 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 8
The filesystem on /dev/mmcblk0p3 is now 14910208 blocks long.

拡張されたか確認

# df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/root        32G  689M   53G   2% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M  6.1M  457M   2% /run
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  300M   66M  234M  22% /boot
tmpfs            93M     0   93M   0% /run/user/0

rootのとこのサイズが2Gから変わっていればおk

NTP設定

時間を調整する

NTPをインストール

# yum install -y ntp

vi でntp.confを変更

# vi /etc/ntp.conf 

既存の設定をコメントアウトして下記の感じで追記

#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org
server -4 ntp.nict.jp
server -4 ntp1.jst.mfeed.ad.jp
server -4 ntp2.jst.mfeed.ad.jp
server -4 ntp3.jst.mfeed.ad.jp

ntpdを有効化して、タイムゾーンを変更

# systemctl enable ntpd
# systemctl start ntpd
# cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
cp: overwrite '/etc/localtime'? y

# date
  <現在の時刻が出力される>

出力された時刻があっていればおk

Wifi設定

Wifiを拾う準備

現状確認

# nmcli d

DEVICE  TYPE      STATE         CONNECTION 
eth0    ethernet  connected     eth0       
lo      loopback  unmanaged     -- 

wlan0というのが認識されていれば接続可能

当然この時点では認識されていない

まずgitをインストール

# yum -y install git

githubから必要なFirmwareをダウンロード

# git clone https://github.com/RPi-Distro/firmware-nonfree.git

適切な場所へ配置

# mv /lib/firmware/brcm{,.org}
# cp -R firmware-nonfree/brcm80211/brcm /lib/firmware/brcm

rpi-updateをダウンロード

# curl -L --output /usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update

ダウンロードしたファイルの権限変更

# chmod +x /usr/bin/rpi-update

rpi-update実行

# rpi-update

再起動

# reboot

確認

# nmcli d

DEVICE  TYPE      STATE         CONNECTION 
eth0    ethernet  connected     eth0       
wlan0   wifi      disconnected  --         
lo      loopback  unmanaged     -- 

wlan0が認識されていればおk

wifi設定

アクセスポイント検索

# nmcli d wifi
  <アクセスポイント一覧が出力>

接続

# nmcli d wifi connect <アクセスポイント名> password <アクセスポイントのパスワード>

確認

# nmcli d

DEVICE  TYPE      STATE      CONNECTION 
eth0    ethernet  connected  eth0       
wlan0   wifi      connected  <アクセスポイント名>    
lo      loopback  unmanaged  --  

wlan0のステータスがconnectedになっていればおk

初期設定完了

じゃなかたです

sshで接続してない

てことで

次回は・・・

sshMacからアクセスします

次の記事

==作成中==

前の記事

shon-blo.hatenablog.com