Trying to extend emmc partition

im trying to fully extend the emmc partition but no success. im having a hard time to find guides as well, and my lack of knowlege
im using this guide: https://spotpear.com/wiki/Milk-V-Duo-S-Extend-Partition-SD-Card-eMMC.html

when i enter the fdisk command i get this:


Welcome to fdisk (util-linux 2.40.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.


Device does not contain a recognized partition table.
Created a new DOS (MBR) disklabel with disk identifier 0x41514b23.

for some reason when i try to delete mmcblk0p4 () i get this:

No partition is defined yet!

when i enter p command to view the current partition information i get this:

Disk /dev/mmcblk0: 7.28 GiB, 7818182656 bytes, 15269888 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: 0x332a05b7

tried to look for answers but i didnt find any…

any help is very much appreciated!

1 Like

update: my solution.
its a workaround. instead of expanding the root partition, i set the size of the root partition in buildroot. im no expert, and i dont know if this is the optimal way of doing this but it works.

in the menuconfig go to “filesystem images” and change the “BR2_TARGET_ROOTFS_EXT2_SIZE” size, as it sets the image size (this is not the root partition size!). this cannot be larger than 4GB. im not sure how necessary this is but whatever.

then go to /home/work/build/boards/cv181x/sg2000_milkv_duos_musl_riscv64_emmc/partition/partition_emmc.xml and change the partition value in the file to your desired emmc root partition size. this must be larger than the value you set before in BR2_TARGET_ROOTFS_EXT2_SIZE

it should look like this:

  1 <physical_partition type="emmc">
  2         <partition label="BOOT" size_in_kb="8192" file="boot.emmc" />
  3         <partition label="MISC" size_in_kb="2048" file="logo.jpg" />
  4         <!-- Beware that in emmc u-boot environment should be 0x40000 alignment     -->
  5         <partition label="ENV" size_in_kb="128" file="" />
  6         <partition label="ROOTFS" size_in_kb="7340032" file="rootfs_ext4.emmc" t    ype="ext4"/>
  7 </physical_partition>

in line 6 set the ‘size_in_kb’ in KB to your desired partition size. as you can see i set mine to 7340032 KB, which equals to 7GB.

then run

# make savedefconfig

after that go to /home/work and run:

# FORCE_UNSAFE_CONFIGURE=1

then run:

# ./build.sh milkv-duos-musl-riscv64-emmc

now your image is in the out dir

again some of these commands might be unnecessary but they dont hurt. im glad it worked and i dont feel like cleaning the process up.

enjoy!

result

[root@milkv-duo]~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
mmcblk1      179:0    0 58.2G  0 disk 
`-mmcblk1p1  179:1    0 58.2G  0 part /mnt/sd
mmcblk0      179:8    0  7.3G  0 disk 
|-mmcblk0p1  179:9    0    8M  0 part 
|-mmcblk0p2  179:10   0    2M  0 part 
|-mmcblk0p3  179:11   0  128K  0 part 
`-mmcblk0p4  179:12   0    7G  0 part /
mmcblk0boot0 179:16   0    4M  1 disk 
mmcblk0boot1 179:24   0    4M  1 disk 
zram0        254:0    0    0B  0 disk 
1 Like