pi@raspberrypi:~ $ sudo fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
pコマンドで現在の状態を確認
Command (m for help): p
Disk /dev/mmcblk0: 59 GiB, 63383273472 bytes, 123795456 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: 0xea0e7380
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 131071 122880 60M c W95 FAT32 (LBA)
/dev/mmcblk0p2 131072 7684095 7553024 3.6G 83 Linux
dコマンドで隠し部分のパーティションを削除。
Command (m for help): d
2番目のパーティションが対象なので2を選択する。
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
pコマンドで今の状態を確認。
Command (m for help): p
Disk /dev/mmcblk0: 59 GiB, 63383273472 bytes, 123795456 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: 0xea0e7380
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 131071 122880 60M c W95 FAT32 (LBA)
nコマンドで新規パーティションを作成
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
First sector (2048-123795455, default 2048): 131072
何も入力せずにエンター
Last sector, +sectors or +size{K,M,G,T,P} (131072-62453759 , default 62453759):
pコマンドでパーティションの領域が大きくなっていることを確認する。
Disk /dev/mmcblk0: 29.8 GiB, 31976325120 bytes, 62453760 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: 0xe6a544c8
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 131071 122880 60M c W95 FAT32 (LBA)
/dev/mmcblk0p2 131072 62453759 62322688 29.7G 83 Linux
wコマンドで書き込み。(書き込むと元には戻れません)
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).
pi@raspberrypi:~ $ sudo resize2fs /dev/mmcblk0p2resize2fs 1.42.12 (29-Aug-2014)Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing requiredold_desc_blocks = 1, new_desc_blocks = 4The filesystem on /dev/mmcblk0p2 is now 15458048 (4k) blocks long.