Skip to content

Mod to make TWRP wait until partitions are available before trying to mount during boot #1634

@Pro-me3us

Description

@Pro-me3us
  • [ no] I am running an official build of TWRP, downloaded from https://twrp.me/Devices/
  • [yes] I am running the latest version of TWRP
  • [ yes] I have read the FAQ (https://twrp.me/FAQ/)
  • [ yes] I have searched for my issue and it does not already exist

Device codename: Raven (FireTV 2nd gen Cube, Amlogic SOC, FireOS7/Android 9.0)
TWRP version: 3.7.0_9-0

TWRP tries to mount my device partitions before the partition table has been loaded. The results is in the recovery.log, following the FSTAB processing, there are 'Failed to mount' and 'unable to Mount' messages for all my partitions. When TWRP loads, I'm able to access all my ext4 partitions and files from within ADB, but many of the partitions do not appear in the backup and mount menus of the TWRP GUI. Another byproduct is that /sdcard (internal storage) mounts /data/media rather than /data/media/0.

The first message I see after FSTAB processing is done, is 'Setting up '/data' as data/media emulated storage'. This is handled by twrp/bootable/recovery/partition.cpp. I have added a wait function so that this step does not proceed until my data block device is detected. I suspect that the partition table initiation is only 1-2sec behind TWRP's loading because this adds little to no noticeable bootup delay, and it fixes all the mount errors. TWRP gui also shows all my partitions and sizes under Backup and Mount.

void TWPartition::Setup_Data_Media() {
	while (access("/dev/block/data", F_OK) != 0) {
        	// if /data is not present, wait for 1 second and check again
        	sleep(1);
    	}
	LOGINFO("Setting up '%s' as data/media emulated storage.\n", Mount_Point.c_str());
	if (Storage_Name.empty() || Storage_Name == "Data")

I've only added the 4 line wait code above to TWPartition::Setup_Data_Media() in partition.cpp. This would need to be more generalized since I have used the partition path specific to my device /dev/block/data. I made a number of attempts to use PartitionManager.Find_Partition_By_Path(path) to wait for the data path to become available before proceeding, but I could not get it working.

This issue of TWRP trying to mount partitions before partition table initiation I would guess affects a number of other devices too.

I'm sure there is a better way to code this in, but I just wanted to report the issue, and a possible work around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions