2013年4月25日木曜日

Raspberry Pi の Arch Linux で使用領域を拡張する

 

 

Raspberry Piにsshで接続するところまでできたわけですが、ディスクが1.7GBしか認識されていなかったため、拡張することにします。

OSにRaspbianを選択していると、Raspi-configで簡単に設定できるようですが、ArchLinuxではちょっと手間がかかります。

今回は、8GBのSDカードを使用しているので、限界まで拡張したいと思います。

まずは、拡張前の df -hの結果です。

[root@alarmpi ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.7G 665M 924M 42% /
devtmpfs 83M 0 83M 0% /dev
tmpfs 231M 0 231M 0% /dev/shm
tmpfs 231M 244K 231M 1% /run
tmpfs 231M 0 231M 0% /sys/fs/cgroup
tmpfs 231M 0 231M 0% /tmp
/dev/mmcblk0p1 90M 25M 66M 28% /boot

 
それでは、拡張手順です。
まず、

fdisk mmcbblk0

を実行し、Commandにpをタイプし、パーティションリストを表示します。

[root@alarmpi dev]# fdisk mmcblk0
Welcome to fdisk (util-linux 2.22.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk mmcblk0: 7948 MB, 7948206080 bytes, 15523840 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: 0x0004f23a
Device Boot Start End Blocks Id System
mmcblk0p1 * 2048 186367 92160 c W95 FAT32 (LBA)
mmcblk0p2 186368 3667967 1740800 83 Linux

二番目のパーティションを削除します。

Command (m for help): d
Partition number (1-4): 2
Partition 2 is deleted

新たにパーティションを作成します。

Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (186368-15523839, default 186368):
Using default value 186368
Last sector, +sectors or +size{K,M,G} (186368-15523839, default 15523839):
Using default value 15523839
Partition 2 of type Linux and of size 7.3 GiB is set

編集結果を書き込みます。

Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.


ここで一回再起動をかけます。

reboot


起動したら、再度sshで接続し、resize2fsで拡張します。

[root@alarmpi ~]# resize2fs /dev/mmcblk0p2
resize2fs 1.42.7 (21-Jan-2013)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p2 is now 1917184 blocks long.


また再起動します。

reboot


ここまで問題なく設定できていれば、/が拡張されているはずです。
そして拡張後のdf -hの結果です。

[root@alarmpi ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 7.3G 667M 6.3G 10% /
devtmpfs 83M 0 83M 0% /dev
tmpfs 231M 0 231M 0% /dev/shm
tmpfs 231M 236K 231M 1% /run
tmpfs 231M 0 231M 0% /sys/fs/cgroup
tmpfs 231M 0 231M 0% /tmp
/dev/mmcblk0p1 90M 25M 66M 28% /boot


ばっちり拡張されています。

0 件のコメント:

コメントを投稿