Make changes for U-boot to change partition sizes (just for testing)

Post Reply
andnovator
Posts: 24
Joined: Wed Oct 28, 2020 4:38 am
languages_spoken: russian,english
ODROIDs: ODROID-C2
Has thanked: 1 time
Been thanked: 2 times
Contact:

Make changes for U-boot to change partition sizes (just for testing)

Post by andnovator »

Odroid c2 Ubuntu partiton table has first FAT partition with 128MB size. I have [fast] microSD card with installed Ubuntu 20 (from "official" .img). For example, I want change first patition to 1Gb size (and accordingly "shrink" root partition), and still have botable Ubuntu. Is it possible?

This question is more related to U-Boot, but I don't know how to right "googling" for this info....

User avatar
odroid
Site Admin
Posts: 37392
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1795 times
Been thanked: 1140 times
Contact:

Re: Make changes for U-boot to change partition sizes (just for testing)

Post by odroid »

Are you going to increase the mmcblk0p1 size?
https://wiki.odroid.com/common/software ... odroid-c21

If yes, try changing the size on a Linux PC with GParted utility.

andnovator
Posts: 24
Joined: Wed Oct 28, 2020 4:38 am
languages_spoken: russian,english
ODROIDs: ODROID-C2
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Make changes for U-boot to change partition sizes (just for testing)

Post by andnovator »

Yes, mmcblk0p1

If I simply change partition size, Ubuntu became unbootable (blue led turned on once for a ~ second, then blinked once and boot stoped [failed?]) on my C2. As boot.ini has some addresses params (for example, for kernel - $loadaddr), looks like 128MB offset is somehow hardcoded/copiled in U-boot (or set in a config). However, if I grep binary data of U-Boot bootloader, I simply get string bootargs=root=/dev/mmcblk0p2 rw init=/init rootwait console=ttyS0,115200 hdmimode=720p60hz hdmitx=cecf logo=osd1,loaded,0x3f800000,720p60hz androidboot.hardware=odroidc2 androidboot.serialno=${fbt_id#} androidboot.selinux=disabled

As I extend FAT partition, I shrink and "move" root partition. GParted also noted, that it's recomended to update bootloader (GRUB for PC) after moving beginnig of root partition, but, of cource, it's not needed, for example, for GRUB [2]

andnovator
Posts: 24
Joined: Wed Oct 28, 2020 4:38 am
languages_spoken: russian,english
ODROIDs: ODROID-C2
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Make changes for U-boot to change partition sizes (just for testing)

Post by andnovator »

Maybe when I change FAT partition (mmcblk0p1 ) size, some alignment occurs, after that sectors before mmcblk0p1 re-writed and u-boot botloader / MBR (as it is not only on 0 sector on ODROID C2, but from 0 to 9 sector) becomes "corrupted"...

User avatar
odroid
Site Admin
Posts: 37392
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1795 times
Been thanked: 1140 times
Contact:

Re: Make changes for U-boot to change partition sizes (just for testing)

Post by odroid »

You probably need to build your own u-boot if there is any hardcoded offsets. But I don't think so.
https://wiki.odroid.com/odroid-c2/softw ... ing_u-boot
Do you have a USB-UART cable for low level debugging?

BTW, what happens if you only reduce the mmcblk0p2 (EXT4 rootfs) partition size with 1GB offset?
Is it still bootable?

User avatar
meveric
Posts: 11535
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go, H2 (N4100), N2, H2 (J4105), GoA, C4, GoA v1.1, H2+, HC4, GoS
Has thanked: 69 times
Been thanked: 481 times
Contact:

Re: Make changes for U-boot to change partition sizes (just for testing)

Post by meveric »

From my experience in most cases when you try to resize a FAT partition it fails and causes some unexpected results.
The best would be to copy the files on the fat partition to a backup location and create a new FAT partition with the desired size and copy the files back over.
Please Note: if you do that the partition ID will change and you may have to adapt your /etc/fstab to deal with the new partition ID.

Also I doubt uboot has anything to do with size of the FAT partition, uboot only searches for boot.ini on the FAT partition, the rest u-boot doesn't really care about.
You already have root=/dev/mmcblk0p2 as an option so u-boot knows where to find the rootfs. It doesn't matter if the rootfs stars at 100MB or 1GB it will always be the second partition.
These users thanked the author meveric for the post (total 2):
odroid (Tue Apr 27, 2021 5:49 pm) • andnovator (Wed Apr 28, 2021 4:22 am)
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

andnovator
Posts: 24
Joined: Wed Oct 28, 2020 4:38 am
languages_spoken: russian,english
ODROIDs: ODROID-C2
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Make changes for U-boot to change partition sizes (just for testing)

Post by andnovator »

Aha, I was wrong, It's all some specific "situations" with changing partition with odroid. Sometimes partition resizing partial "brokes" partition. Even with GPartred.

For example, when GParted moves root partition to right on SD card, it moved partition "sucessfull", but sometimes GPArted shows error in the end - and then odroid c2 boots only to black screen (kernel is loaded, as SysRQ keys works).

Also resizing/formatting fat partiton with Windows sometimes can "brake" booting.

When I copied "clean" Ubuntu 20 minimal from .img to sdcard, then moved root partition for 1000bm to right and resized to the end (I know that there are "autorun" service for resizing partitionm, it was a test). When I firstly booted on odroid c2, ubuntu booted , but after reboot becam unbootable - root partition becamed corrupted ("Bad magic number in super-block...").
When I copied "clean" Ubuntu 20 minimal from .img to sdcard, then moved root partition for 1000bm to right (without resizing) - odroid c2 booted normally, is booting normally after reboots

Also, the are problems with FAT partition resizing itself. There are known bug with libparted (e.g. even with latest GParted / GParted LiveCD) with resizing FAT [16] / FAT 32 partition less then 256mb (https://unix.stackexchange.com/question ... 182#366182 ), workaround - backup FAT partiton data, format to another fs, resize, format back to FAT / FAT 32, restore files (https://bugzilla.gnome.org/show_bug.cgi?id=649324#c4).
And, when I restore files by simple copying, seems like files addresses "changes", so odroid c2 booting is broken (in the "middle"), odroid c2 boots to black screen (blue led blinks as normall) [same - SysRq keys works]

So for "resizing" FAT partition I used Paragon HDM and restore (from it backup file) first sectors and fat partiton with "proporcional" resizng to free space before root partiton
Last edited by andnovator on Tue Apr 27, 2021 9:21 pm, edited 1 time in total.

andnovator
Posts: 24
Joined: Wed Oct 28, 2020 4:38 am
languages_spoken: russian,english
ODROIDs: ODROID-C2
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Make changes for U-boot to change partition sizes (just for testing)

Post by andnovator »

@meveric, >>/etc/fstab
not only, uboot config also contains this partition UUID

andnovator
Posts: 24
Joined: Wed Oct 28, 2020 4:38 am
languages_spoken: russian,english
ODROIDs: ODROID-C2
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Make changes for U-boot to change partition sizes (just for testing)

Post by andnovator »

@meveric, anyway thanks - I forgot that fornattinh partition EVEN with the SAME filesystem CHANGES partition uuid (and of cource boot.ini becomes "incorrect")

Btw: I was talking rubbish. {loaddr} - it's for loading files to RAM ,addreses in RAM for booting kernel,dtb and initrd. So I supriced, why sometimes when I replaced same files in FAT partition my odroid c2 hang on boot with black screen (or even make bootloop)

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 2 guests