ArchLinuxの標準配布イメージはルートパーティションが1.7GBしかありません。
もっと容量があるのに使えない!という場合にはfdisk
コマンドでリサイズします。
状況の確認
[root@alarmpi ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.7G 563M 978M 37% /
devtmpfs 214M 0 214M 0% /dev
tmpfs 218M 0 218M 0% /dev/shm
tmpfs 218M 292K 218M 1% /run
tmpfs 218M 0 218M 0% /sys/fs/cgroup
tmpfs 218M 0 218M 0% /tmp
/dev/mmcblk0p1 90M 26M 65M 28% /boot
tmpfs 44M 0 44M 0% /run/user/0
手順
fdiskコマンドでパーティションテーブルを編集する
fdiskを起動。
[root@alarmpi ~]# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.24.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
p
コマンドでパーティションテーブルを確認。
/dev/mmcblk0p2
に拡張パーティションがあるのが解ります。
Command (m for help): p
Disk /dev/mmcblk0: 14.4 GiB, 15476981760 bytes, 30228480 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
Disklabel type: dos
Disk identifier: 0x417ee54b
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA)
/dev/mmcblk0p2 186368 3667967 1740800 5 Extended
/dev/mmcblk0p5 188416 3667967 1739776 83 Linux
パーティション削除
おもむろに拡張パーティションを削除。
Command (m for help): d
Partition number (1,2,5, default 5): 2
Partition 2 has been deleted.
パーティションの作成
新しい拡張パーティションを作成。
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
Partition number (2-4, default 2):
First sector (186368-30228479, default 186368):
Last sector, +sectors or +size{K,M,G,T,P} (186368-30228479, default 30228479):
Created a new partition 2 of type 'Extended' and of size 14.3 GiB.
新しい論理パーティションを作成。
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (188416-30228479, default 188416):
Last sector, +sectors or +size{K,M,G,T,P} (188416-30228479, default 30228479):
Created a new partition 5 of type 'Linux' and of size 14.3 GiB.
もう一度パーティションテーブルを確認。
Command (m for help): p
Disk /dev/mmcblk0: 14.4 GiB, 15476981760 bytes, 30228480 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
Disklabel type: dos
Disk identifier: 0x417ee54b
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA)
/dev/mmcblk0p2 186368 30228479 15021056 5 Extended
/dev/mmcblk0p5 188416 30228479 15020032 83 Linux
パーティションテーブルの書き込み
パーティションテーブルの書き込み。
Device or resource busy
エラーが出るけど気にしない。
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: 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).
再起動とリサイズ
リブートします。
[root@alarmpi ~]# reboot
Connection to 192.168.0.17 closed by remote host.
Connection to 192.168.0.17 closed.
resize2fsでパーティションを拡張。
[root@alarmpi ~]# resize2fs /dev/mmcblk0p5
resize2fs 1.42.10 (18-May-2014)
Filesystem at /dev/mmcblk0p5 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p5 is now 3755008 blocks long.
最後の確認
df
コマンドで確認して喜びを噛み締めます。
[root@alarmpi ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 564M 13G 5% /
devtmpfs 214M 0 214M 0% /dev
tmpfs 218M 0 218M 0% /dev/shm
tmpfs 218M 292K 218M 1% /run
tmpfs 218M 0 218M 0% /sys/fs/cgroup
tmpfs 218M 0 218M 0% /tmp
/dev/mmcblk0p1 90M 26M 65M 28% /boot
tmpfs 44M 0 44M 0% /run/user/0
Available 13GB!ヒャッハー!
参考