Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

make_sdimage.py creates invalid ext3 partition

I am using the make_sdimage.py to create a 128G SD image. Parameters to the script are:

-s 117G

-n sd_mage-128G.bin

-P u-boot-with-spl.sfp,num=1,format=raw,size=1M,type=A2

-P zImage,socfpga.dtb,u-boot.scr,num=2,format=vfat,size=1G

-P rootfs,num=3,format=ext3,size=114G

When i boot from the SD card, the SPL and u-boot load fine, the kernel faults when trying to mount the rootfs:

EXT4-fs (mmcblk0p3): mounting ext3 filesystem using the ext4 subsystem

EXT4-fs (mmcblk0p3): bad geometry: block count 29884416 exceed size of device (29884415 blocks)

EXT4-fs (mmcblk0p3): bad geometry: block count 29884416 exceed size of device (29884415 blocks)

EXT4-fs (mmcblk0p3): warning: mounting ext3 filesystem as ext2

EXT4-fs (mmcblk0p3): warning: mounting unchecked fs, running e2fsck is recommended

EXT4-fs (mmcblk0p3): VFS: Mounted root (ext2 filesystem) on device 179:3

EXT2-fs (mmcblk0p3): error: ext2_check_page: bad entry in directory# 2: : inode out of bounds - offset=0, inode244069792, rec_len=3152, name_len=0

devtmpfs: error mounting -2

I saw a similar error when using a 64G SD card and trying to mount it on my Linux dev system. It would appear there may be an off-by-one error somewhere in the script, but I haven't dug into it to try and find it. I'm hoping someone here is familiar with the script or has seen a similar problem.

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    This is an old thread, but since I faced similar problems and found a solution, here's a reply anyway.

    I had parameters to make_sdimage.py for four partitions:

    			sudo $(PATH_HPS_BIN)/make_sdimage.py 
    				-s 7464M 
    				-n $(SD_IMG) 
    				-P $(DIR_BSP)/preloader-mkpimage.bin,$(DIR_BSP)/uboot-socfpga/u-boot.img,num=3,format=raw,size=1M,type=A2 
    				-P zImage,$(DIR_IMG)/socfpga.dtb,num=2,format=ext3,size=1023M 
    				-P rootfs,num=1,format=ext3,size=1G 
    				-P num=4,format=ext3,size=5G
    

    I found, by instrumenting make_sdimage.py, that it correctly computes sizes and offsets, and passes them to fdisk. The actual layout created by fdisk differs from the requested parameters, and has gaps between the end of one partition and the start of the next:

    Disk /dev/sdb: 7.3 GiB, 7826571264 bytes, 15286272 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: 0xf5526d7a
    Device     Boot   Start      End  Sectors  Size Id Type
    /dev/sdb1          2048  2099199  2097152    1G 83 Linux
    /dev/sdb2       2099201  4194303  2095103 1023M 83 Linux
    /dev/sdb3       4194306  4196351     2046 1023K a2 unknown
    /dev/sdb4       4196355 14682111 10485757    5G 83 Linux
    

    Changing the requested partitioning slightly (1G instead of 1023M, the "-s 7200M" was done for other reasons):

    			sudo $(PATH_HPS_BIN)/make_sdimage.py 
    				-s 7200M 
    				-n $(SD_IMG) 
    				-P $(DIR_BSP)/preloader-mkpimage.bin,$(DIR_BSP)/uboot-socfpga/u-boot.img,num=3,format=raw,size=1M,type=A2 
    				-P zImage,$(DTB_BASE).dtb,num=2,format=ext3,size=1G 
    				-P rootfs,num=1,format=ext3,size=1G 
    				-P num=4,format=ext3,size=5G
    

    gives a regular partitioning (and working EXT3 file systems):

    Command (m for help): p
    Disk ../build/QWG/sd_image_yocto.bin: 7 GiB, 7549747200 bytes, 14745600 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: 0xd784cd63
    Device                           Boot   Start      End  Sectors Size Id Type
    ../build/QWG/sd_image_yocto.bin1         2048  2099199  2097152   1G 83 Linux
    ../build/QWG/sd_image_yocto.bin2      2099200  4196351  2097152   1G 83 Linux
    ../build/QWG/sd_image_yocto.bin3      4196352  4198399     2048   1M a2 unknown
    ../build/QWG/sd_image_yocto.bin4      4198400 14684159 10485760   5G 83 Linux