Re-sizing the root filesystem of microSD card on Cubietruck =========================================================== Reference: http://www.raspberrypi.org/forums/viewtopic.php?f=51&t=45265 Check the size: [root@cubietruck lib]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mmcblk0p3 ext4 1.3G 1.3G 0 100% / devtmpfs devtmpfs 995M 0 995M 0% /dev tmpfs tmpfs 1008M 0 1008M 0% /dev/shm tmpfs tmpfs 1008M 196K 1008M 1% /run tmpfs tmpfs 1008M 0 1008M 0% /sys/fs/cgroup /dev/mmcblk0p1 ext3 457M 166M 287M 37% /boot tmpfs tmpfs 202M 0 202M 0% /run/user/0 [root@cubietruck lib]# ----------------------------------------------------------------------- Check the size via `fdisk`: [root@cubietruck ~]# fdisk /dev/mmcblk0 Welcome to fdisk (util-linux 2.25.1-rc1). 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 /dev/mmcblk0: 7.4 GiB, 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 Disklabel type: dos Disk identifier: 0x56a88b1d Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 1001471 999424 488M 83 Linux /dev/mmcblk0p2 1001472 1251327 249856 122M 83 Linux /dev/mmcblk0p3 1251328 3985407 2734080 1.3G 83 Linux Command (m for help): q [root@cubietruck ~] NOTES: The disk has 15523840 sectors, and last used sector is 3985407 -------------------------------------------------------------- Invoke GNU `parted` for the microSD card: [root@cubietruck lib]# parted /dev/mmcblk0 GNU Parted 3.2 Using /dev/mmcblk0 Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) unit chs (parted) print Model: SD SU08G (sd/mmc) Disk /dev/mmcblk0: 966,80,9 Sector size (logical/physical): 512B/512B BIOS cylinder,head,sector geometry: 966,255,63. Each cylinder is 8225kB. Partition Table: msdos Disk Flags: Number Start End Type File system Flags 1 0,32,32 62,86,23 primary ext3 2 62,86,24 77,227,21 primary linux-swap(v1) 3 77,227,22 248,20,27 primary ext4 (parted) NOTES: So, disk ends at 966,255,63 cylinder,head,sector. And, the root partition ends at 248,20,27. -------------------------------------------------------------- Let's remove the linux-swap (2) and root partitions (3). (parted) rm 2 Warning: Partition /dev/mmcblk0p2 is being used. Are you sure you want to continue? Yes/No? Yes Error: Partition(s) 2 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? Cancel (parted) rm 3 Warning: Partition /dev/mmcblk0p3 is being used. Are you sure you want to continue? Yes/No? Yes Error: Partition(s) 2, 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? i (parted) print Model: SD SU08G (sd/mmc) Disk /dev/mmcblk0: 966,80,9 Sector size (logical/physical): 512B/512B BIOS cylinder,head,sector geometry: 966,255,63. Each cylinder is 8225kB. Partition Table: msdos Disk Flags: Number Start End Type File system Flags 1 0,32,32 62,86,23 primary ext3 (parted) ** IMPORTANT NOTE **: DO NOT REBOOT AT THIS POINT, BEFORE RECREATING THE ROOT PARTITION!! ----------------------------------------------------------------------- Let's create the root partition. The new root partition *must* start at the *same* position where the old root partition did: 77,227,22 And it ends where you prefer. It must have at-least the same size as current partition and it may not exceed the end of the disk (in my case: 966,255,63). Via `parted', the BIOS cylinder,head,sector geometry is: 966,255,63. We deleted the Fedora root partition (on a Cubietruck) that started at position: 77,227,22. Now, while trying to re-recreate the partition to extend the root filesystem, we get: (parted) mkpart primary 77,227,22 966,255,63 Error: The maximum head value is 254. So, change the head and sector values to 254 and 62: (parted) mkpart primary 77,227,22 966,254,62 Error: The location 966,254,62 is outside of the device /dev/mmcblk0. Still no dice. So, let's try a different value for the END partition value to 766,254,62: (parted) mkpart primary 77,227,22 766,254,62 Error: Partition(s) 2, 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? i (parted) Print the partition table again: (parted) print Model: SD SU08G (sd/mmc) Disk /dev/mmcblk0: 966,80,9 Sector size (logical/physical): 512B/512B BIOS cylinder,head,sector geometry: 966,255,63. Each cylinder is 8225kB. Partition Table: msdos Disk Flags: Number Start End Type File system Flags 1 0,32,32 62,86,23 primary ext3 2 77,227,22 766,254,62 primary lba (parted) quit ----------------------------------------------------------------------- NOTES: The Kernel is not yet aware of the change, so reboot the Cubietruck. [root@cubietruck ~]# init 6 ----------------------------------------------------------------------- Check the new partition size after the reboot: [root@cubietruck ~]# fdisk /dev/mmcblk0 Welcome to fdisk (util-linux 2.25.1-rc1). 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 /dev/mmcblk0: 7.4 GiB, 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 Disklabel type: dos Disk identifier: 0x56a88b1d Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 1001471 999424 488M 83 Linux /dev/mmcblk0p2 1251328 12321854 11070527 5.3G 83 Linux Command (m for help): NOTES: The partition size is larger, but the root filesystem has still the old size. Re-size the root filesystem. ----------------------------------------------------------------------- Re-size the root filesystem: [root@cubietruck ~]# resize2fs /dev/mmcblk0p2 resize2fs 1.42.11 (09-Jul-2014) Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing r[ 1354.854765] EXT4-fs (mmcblk0p2): resizing filesystem from 341760 to 1383815 blocks equired old_desc_blocks = 1, new_desc_blocks = 1 [ 1355.346782] EXT4-fs (mmcblk0p2): resized filesystem to 1383815 The filesystem on /dev/mmcblk0p2 is now 1383815 blocks long. [root@cubietruck ~]# ----------------------------------------------------------------------- Check the size again: [root@cubietruck ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mmcblk0p2 ext4 5.2G 1.3G 4.0G 24% / devtmpfs devtmpfs 995M 0 995M 0% /dev tmpfs tmpfs 1008M 0 1008M 0% /dev/shm tmpfs tmpfs 1008M 188K 1008M 1% /run tmpfs tmpfs 1008M 0 1008M 0% /sys/fs/cgroup /dev/mmcblk0p1 ext3 457M 166M 287M 37% /boot tmpfs tmpfs 202M 0 202M 0% /run/user/0 [root@cubietruck ~]# ----------------------------------------------------------------------- So, the root filesystem is successfully extended! * * *