Apalis T30: mbr.bin: Operation not permitted

Hi team,

A customer is having an issue when trying to use the legacy method to setup a USB drive and when executing the script command, they have the following error:

Apalis T30 rootfs detected    
Image file apalis_t30.img has been successfully generated!    

Creating MBR file and do the partitioning    
0+0 records in    
0+0 records out    
0 bytes copied, 0.000753089 s, 0.0 kB/s    
Error: Error opening /home/hw/Downloads/Apalis-T30_LXDE-Image_2.8.6/apalis-t30_bin/mbr.bin: Operation not permitted

Script aborted unexpectedly...

They have the same issue with both 2.7.4 and 2.8.6 image when trying to install through the legacy image. With TEZI they don’t have an issue but since they want to use the 2.7.4 image, they asked about the legacy method. They also tried with different devices.

As for the extracting the also did the following, nothing too crazy:

Downloaded Apalis-T30_LXDE-Image_2.8b6.184-20190401.tar.bz2
sudo tar xjvf Apalis-T30_LXDE-Image_2.8b6.184-20190401.tar.bz2 --no-same-owner
cd Apalis-T30_LXDE-Image_2.8.6/
./update.sh -o /media/hw/<partition_label>/

Some additional details:

SoM: Apalis T30
Carrier Board: Apalis Evaluation Board
Tegra U-Boot Versions: Git Branch: 2016.11-toradex
Linux-toradex module version : 3.1.10-g37b9f03
Tegra T20/T30 Image Versions: 2.7 beta 4 (Aplis-T30_LXDE-image_2.7.4)
Gcc version : gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf

UPDATE:

I added some traces into the update.sh file to better understand what is going on and I could better pinpoint the issue but still no idea what is going on and unable to solve the issue. Problem sees to be with dd and parted. Customer is using Ubuntu 16.04.3, with dd (coreutils) 8.25 and parted 3.2.

The part in particular is the following and seems to be related with the permissions or the way that dd creates MBR.bin:

            echo ""
		echo "Creating MBR file and do the partitioning"
		# Initialize a sparse file
		sudo rm -rf ${BINARIES}/mbr.bin

		if [ -f "${BINARIES}/mbr.bin" ] ; then
			echo "MBR file exists"
		else
			echo "MBR file non-existent"
		fi

		dd if=/dev/zero of=${BINARIES}/mbr.bin bs=512 count=0 seek=${EMMC_SIZE}
		echo "dd - completed"
		echo "MBR.bin permissions:"
		ls -l ${BINARIES}/mbr.bin
		sudo chmod 666 ${BINARIES}/mbr.bin
		echo "chmod completed"
		echo "MBR.bin permissions:"
		${PARTED} -s ${BINARIES}/mbr.bin mklabel msdos
		echo "parted - mklabel completed"
		echo "MBR.bin permissions:"
		ls -l ${BINARIES}/mbr.bin
		${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary fat32 ${BOOT_START} $(expr ${ROOTFS_START} - 1 )
		echo "parted - mkpart fat32 completed"
		echo "MBR.bin permissions:"
		ls -l ${BINARIES}/mbr.bin
		echo "-----Did it change?-----"

		exit 1
		# the partition spans to the end of the disk, even though the fs size will be smaller
		# on the target the fs is then grown to the full size
		if [ "${IMAGEFILE}" = "root.ext3" ] ; then
			${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary ext3 ${ROOTFS_START} $(expr ${EMMC_SIZE} \- ${ROOTFS_START} \- 1)
		else
			${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary ext4 ${ROOTFS_START} $(expr ${EMMC_SIZE} \- ${ROOTFS_START} \- 1)
		fi
		${PARTED} -s ${BINARIES}/mbr.bin unit s print 
		echo "parted - mkpart extX completed"

From the tests I did myself, I always created the MBR file with 666 permissions, however, the customer seems unable to change it for some reason at the botton part when they have to create the ext3/ext4 partition:

Apalis T30 rootfs detected
Image file apalis_t30.img has been successfully generated! 

Creating MBR file and do the partitioning
MBR file non-existent
0+0 records in
0+0 records out
0 bytes copied, 0.000787268 s, 0.0 kB/s
dd - completed
MBR.bin permissions:
-rw-r--r-- 1 root root 7811891200 Sep 13 19:03 apalis-t30_bin/mbr.bin
chmod completed
MBR.bin permissions:
parted - mklabel completed
MBR.bin permissions:
-rw-rw-rw- 1 root root 7811891200 Sep 13 19:03 apalis-t30_bin/mbr.bin
parted - mkpart fat32 completed
MBR.bin permissions:
-rw-rw-rw- 1 root root 7811891200 Sep 13 19:03 apalis-t30_bin/mbr.bin
-----Did it change?-----
Error: Error opening /home/hw/Downloads/Apalis-T30_LXDE-Image_2.7.4/apalis-t30_bin/mbr.bin: Operation not permitted

Script aborted unexpectedly...

It seems that there is an issue in the way that the MBR file is created and cannot be correctly changed, even with a forced chmod 666. Also, the file seems to be created by root even though it is not launched with sudo. Without chmod, the permissions look like this, and fails in the same spot, which is something that really confuses me:

Apalis T30 rootfs detected
Image file apalis_t30.img has been successfully generated! 

Creating MBR file and do the partitioning
MBR file non-existent
0+0 records in
0+0 records out
0 bytes copied, 0.00018434 s, 0.0 kB/s
dd - completed
MBR.bin permissions:
-rw-r--r-- 1 root root 7811891200 Sep 13 16:38 apalis-t30_bin/mbr.bin
parted - mklabel completed
MBR.bin permissions:
-rw-r--r-- 1 root root 7811891200 Sep 13 16:38 apalis-t30_bin/mbr.bin
parted - mkpart fat32 completed
MBR.bin permissions:
-rw-r--r-- 1 root root 7811891200 Sep 13 16:38 apalis-t30_bin/mbr.bin
-----Did it change?-----

Error: Error opening /home/hw/Downloads/Apalis-T30_LXDE-Image_2.7.4/apalis-t30_bin/mbr.bin: Operation not permitted

Script aborted unexpectedly...

Somehow, the mklabel and the mkpart fat32 work but the problem happens at the mkpart ext

I attached the final update.sh that I sent the customer with additional tests and changes but everything remains the same compared to the original found in the image. My changes:

Delete of mbr.bin (in case this was created with sudo and kept this way).
Change of PARTED to always use sudo (in case it was a permission issue).
Added a manual chmod 666 to ensure the rw from everyone…

Many thanks and kind regards,
Alvaro.

I vaguely recall that this is a pre-requisites issue.

https://developer.toradex.com/knowledge-base/board-support-package/openembedded-(core)#Prerequisites

What exact Linux distribution and flavour thereof is the customer running?

Hi @marcel.tx, thanks for the comment. I passed the customer the prerequisites but mentioned that it hasn’t change the behaviour.

He mentioned to me that he is using Ubuntu 16.04 LTS with kernel Ubuntu 4.10.0-40. I tried a VM with 16.04.6 (Kernel 4.15.0-45) and 16.04.3 (Kernel 4.10.0-28) and if I don’t install the prerequirements I get another error (related to the creation of the img). If I install it, everything gets installed perfectly on the pendrive.

Further checking the error with the customer, it seems that the line that fails is the 393:

dd if=/dev/zero of=${BINARIES}/mbr.bin bs=512 count=0 seek=${EMMC_SIZE}

For some reason, mbr.bin when read with the file command, it states to have no read permission. However, it also states to have reading permision with ls: -rw-r—r—“ (and hence the “No read permission error”. Any idea? I never heard about this script failing like this or any other file showing this kind of behaviour.

I will suggest using playing with chmod to see if this changes but since sudo is used I believe this should not affect at all…

What exactly is that /media/hw/<partition_label>/ of yours? What exact media, what exact partitioning on it?

BTW: Why exactly would you untar with --no-same-owner? That definitely does not make any sense when extracting a root file system!

Hi @marcel.tx ,

What exactly is that /media/hw// of yours? What exact media, what exact
partitioning on it?

Is a USB drive, however the process fails way before the USB comes into play.

BTW: Why exactly would you untar with --no-same-owner? That definitely does not make any
sense when extracting a root file system!

Indeed, actually it doesn’t make any change. The reason why we added is that I had problems with an untar of a TEZI image in a USB drive sometime ago. However, we are no longer using that parameter.

Kindly check the update as I edited the update.sh to add some traces and better understand what was going on in the customer’s PC.

What exact file system did they extract the update package to? Looks like that may not quite be something sane.

Hi @marcel.tx, thanks for the update. Let me check with them. Any way of running a sanity check to check if it’s that? Also, they asked if there is any limitation in using GPT in the development PC (which I believe it doesn’t, but better check).

Update: @marcel.tx, they are using GPT + EXT4 according to df -Th

I’m really not aware of any such issue and hundreds of customers have run this before.