MISC-TN-031: Using gparted for modifying an SD card

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box



History
Issue Date Notes
2024/07/02 DESK-MX-L 4.x.x release


Introduction[edit | edit source]

The size of rootfs created by Yocto may be too small to install custom applications. So we need to extend the root file system partition. To do that we use, for example, MVM of DESK-MX6UL-L-4.0.0-MVM and install gparted.

Extend rootfs[edit | edit source]

On target we have the following partition and free space

root@desk-mx6ul-axelulite:~# fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 14.84 GiB, 15931539456 bytes, 31116288 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: 0xfe9755a5

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *     8192   58385   50194 24.5M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      65536 9266947 9201412  4.4G 83 Linux
root@desk-mx6ul-axelulite:~# 
root@desk-mx6ul-axelulite:~# df -h    
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       4.2G 1011M  3.0G  26% /
devtmpfs        118M     0  118M   0% /dev
tmpfs           119M     0  119M   0% /dev/shm
tmpfs            48M  8.7M   39M  19% /run
tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
tmpfs           119M     0  119M   0% /tmp
tmpfs           119M  120K  119M   1% /var/volatile
root@desk-mx6ul-axelulite:~# 

To increase rootfs size you need to perform the command below.

First of all you need to connect your microSD with MVM, as show image below. In this case we use microSD created for desk-mx6ul-l-4.1.0.

Connect microSD to MVM

With fdisk command we can check size of partition about microSD created with Yocto

dvdk@vagrant:~$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 14.86 GiB, 15931539456 bytes, 31116288 sectors
Disk model: Storage Device  
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: 0xfe9755a5

Device     Boot Start     End Sectors  Size Id Type
/dev/sdb1  *     8192   58385   50194 24.5M  c W95 FAT32 (LBA)
/dev/sdb2       65536 9266947 9201412  4.4G 83 Linux

We have that first partition has 24.5MB of size, while second partition has 4.4GB of size. We want increase size of rootfs until it reach the max size avaible of microSD. To do this we use gparted.

After run gparted we need to choose the correct disk to resize

Select microSD from gparted

In this case we can see that there are 10GB of free space not allocated. This free space can be allocated on rootfs. To do this we need to umount rootfs partition as shown in the image below

Umount rootfs partition with gparted

To resize partition right click on rootfs partition, then click Resize/Move.

Resize/Move partition with gparted

Move rootfs partition to the end of storage, right click on rootfs partition, then click Resize/Move. The following window will be open. In this case drag the square and move it to the right end. To confirm new partition click on Resize/Move

Change partition size with gparted

After this changes we have the following window

Screen after rootfs partition changes

To Apply changes you need to click check mark icon and follow the step below

Apply changes on rootfs partition
Apply operation on device warning
Apply pending operations
Completed Operation

After resize of rootfs partition with gparted we check that chenges was correctly applied with fdisk

dvdk@vagrant:~$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 14.86 GiB, 15931539456 bytes, 31116288 sectors
Disk model: Storage Device  
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: 0xfe9755a5

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1  *     8192    58385    50194 24.5M  c W95 FAT32 (LBA)
/dev/sdb2       65536 31116287 31050752 14.8G 83 Linux
dvdk@vagrant:~$ 

On target we have the following partition and free space

root@desk-mx6ul-axelulite:~# fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 14.84 GiB, 15931539456 bytes, 31116288 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: 0xfe9755a5

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1 *     8192    58385    50194 24.5M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      65536 31116287 31050752 14.8G 83 Linux
root@desk-mx6ul-axelulite:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G 1000M   13G   8% /
devtmpfs        118M     0  118M   0% /dev
tmpfs           119M     0  119M   0% /dev/shm
tmpfs            48M  8.7M   39M  19% /run
tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
tmpfs           119M     0  119M   0% /tmp
tmpfs           119M  120K  119M   1% /var/volatile
root@desk-mx6ul-axelulite:~#