|
ext2, ext3, ext4パーティションを拡大する 注:この作業前には必ず dd for windows などでsdメモリのバックアップを行うこと。 変更前 †
第2パーティションは ext4 rootfsとしてマウントされているとする。 第2パーティションを拡大する。 変更作業 †デバイス名 /dev/mmcblk0 とする。 作業全体 fdiskを起動する。 # fdisk /dev/mmcblk0 コマンドp で現在のパーティション情報を表示 Command (m for help): p Disk /dev/mmcblk0: 1.9 GiB, 1977614336 bytes, 3862528 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: 0x889103f2 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 1048575 1046528 511M 83 Linux /dev/mmcblk0p2 1048576 1908735 860160 420M 83 Linux 第2パーティションの開始セクタ番号「1048576」が重要なのでメモする 第2パーティションを消してしまう(deleteコマンド、マウント中であるが消してしまう) Command (m for help): d Partition number (1,2, default 2): 2 Partition 2 has been deleted. 即座に新規パーティションを作る (newコマンド) Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): p Partition number (2-4, default 2): 2 セクタ開始番号を指定する。上記でメモした消去前の第2パーティションと必ず同じにする。 最終セクタ番号はデフォルト値でok First sector (1048576-3862527, default 1048576): 1048576 Last sector, +sectors or +size{K,M,G,T,P} (1048576-3862527, default 3862527): Created a new partition 2 of type 'Linux' and of size 1.4 GiB. 書き込みコマンド(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 partp robe(8) or kpartx(8). いったん再起動 # reboot 再起動後ファイルシステムサイズ変更を通知する # resize2fs -p /dev/mmcblk0p2 resize2fs 1.42.12 (29-Aug-2014)E XT4-fs (mmcblk0p2): resizing filesystem from 430080 to 1406976 blocks Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 6 EXT4-fs (mmcblk0p2): resized filesystem to 1406976 The filesystem on /dev/mmcblk0p2 is now 1406976 (1k) blocks long. 変更後 †関連 † |