onekey-sec / ubi_reader

Collection of Python scripts for reading information about and extracting data from UBI and UBIFS images.
GNU General Public License v3.0
524 stars 136 forks source link

Change First UBI PEB Number to 42.0 #55

Closed pruwait closed 2 years ago

pruwait commented 2 years ago

My original image:

ubireader_display_info  /hassio/share/ubifs-root/15-0-systm2.bin
UBI File
---------------------
        Min I/O: 2048
        LEB Size: 126976
        PEB Size: 131072
        Total Block Count: 258
        Data Block Count: 242
        Layout Block Count: 2
        Internal Volume Block Count: 0
        Unknown Block Count: 0
        First UBI PEB Number: 42.0

        Image: 251495409
        ---------------------
                Image Sequence Num: 251495409
                Volume Name:rootfs
                Volume Name:usrfs
                PEB Range: 0 - 257

                Volume: rootfs
                ---------------------
                        Vol ID: 0
                        Name: rootfs
                        Block Count: 242

                        Volume Record
                        ---------------------
                                alignment: 1
                                crc: '0x30fb56ba'
                                data_pad: 0
                                errors: ''
                                flags: 0
                                name: 'rootfs'
                                name_len: 6
                                padding: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
                                rec_index: 0
                                reserved_pebs: 496
                                upd_marker: 0
                                vol_type: 'dynamic'

                Volume: usrfs
                ---------------------
                        Vol ID: 1
                        Name: usrfs
                        Block Count: 14

                        Volume Record
                        ---------------------
                                alignment: 1
                                crc: '0x4f66b6e1'
                                data_pad: 0
                                errors: ''
                                flags: 'autoresize'
                                name: 'usrfs'
                                name_len: 5
                                padding: '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
                                rec_index: 1
                                reserved_pebs: 14
                                upd_marker: 0
                                vol_type: 'dynamic'

My repacked image:

ubireader_display_info sys2.ubi
UBI File
---------------------
        Min I/O: 2048
        LEB Size: 126976
        PEB Size: 131072
        Total Block Count: 258
        Data Block Count: 242
        Layout Block Count: 2
        Internal Volume Block Count: 0
        Unknown Block Count: 0
        First UBI PEB Number: 0

        Image: 251495409
        ---------------------
                Image Sequence Num: 251495409
                Volume Name:rootfs
                Volume Name:usrfs
                PEB Range: 0 - 257

How can I get First UBI PEB Number: 42.0?

jrspruitt commented 2 years ago

Hi pruwait,

I am unaware of any way to specify the starting PEB when creating an image. Perhaps compiling the tools for making the image you could hack in an offset?

-Jason