Tuesday, April 30, 2019

mount - What is default "fstab" file in Android?


As I known, in Android 9, system and vendor are mounted in the first stage of init by parsing fstab from device tree. But, there is another fstab parsed in init process, it is device default fstab, which is parsed by ReadDefaultFstab function below. I am facing to a error " failed to find device default fstab " in boot log. Can anyone explain for me this default fstab file? What is it and it's role?


// Loads the fstab file and combines with fstab entries passed in from device tree.
bool ReadDefaultFstab(Fstab* fstab) {
Fstab dt_fstab;
ReadFstabFromDt(&dt_fstab, false);

*fstab = std::move(dt_fstab);

std::string default_fstab_path;

// Use different fstab paths for normal boot and recovery boot, respectively
if (access("/system/bin/recovery", F_OK) == 0) {
default_fstab_path = "/etc/recovery.fstab";
} else { // normal boot
default_fstab_path = GetFstabPath();
}

Fstab default_fstab;
if (!default_fstab_path.empty()) {
ReadFstabFromFile(default_fstab_path, &default_fstab);

} else {
LINFO << __FUNCTION__ << "(): failed to find device default fstab";
}

for (auto&& entry : default_fstab) {
fstab->emplace_back(std::move(entry));
}

return !fstab->empty();
}


Answer



It can be in / (ramdisk), /odm/etc/ or /vendor/etc/.


Android Storage Configuration:



For Android releases 4.3 and later, the various fstab files used by init, vold and recovery were unified in the /fstab. file



Next change occured with Treble when vendor/SoC specific code was separated from Generic AOSP code. So fstab was moved to /odm or /vendor.


default_fstab_path reads GetFstabPath():


// Identify path to fstab file. Lookup is based on pattern fstab.,
// fstab. in folders /odm/etc, /vendor/etc, or /.


Commit states:



fstab contains device- and soc- specific content that should reside in /odm or /vendor partition. This change searches the fstab.${ro.hardware} file from /odm/etc, /vendor/etc and /, then use the first one found.



fstab contains entries for all filesystems to be mounted on boot or in recovery from partitions including system, vendor, userdata, cache, misc, persist, modem, dsp etc. See details in Android Partitions and Filesystems.


Some of the entries of fstab are moved to DTB. See "WHERE FSTAB IS?" in How to disable dm-verity on Android?


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...