i.MX6 chroot issues

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX6 chroot issues

750 Views
grim
Contributor III

I have set our i.MX system up so that it can boot from a USB thumb drive.

The thumb drive is intended to be used to update all of the software in the system (u-boot, kernel, rootfs, application, etc.).

I've got everything running just fine in regards to updating system software.

The problem that I have is that the customer has added a requirement that the upgrade utility should notify the user to remove the thumb drive and then issue a system "reboot" command.

Obviously, once the thumb drive is removed, a slew of errors gets reported through the debug port. At that time, the system doesn't even know what "reboot" is since the root file system is gone!

I ended up creating a RAM disk. Still haven't decided if I'm going to place the application in the RAM disk and just run the update from there or just mount the RAM disk  RAM is limited in some of our systems so we determined that a 128MB RAM disk is all we can afford to use. I modified my kernel so that it gives me 1 (128MB) RAM disk.

I've had no problems creating the RAM disk. I'm able to create it and copy some binaries and libraries over to it. I've verified that I can issue a "reboot" command from the RAM disk and the system reboots just fine.

The problem I'm having is UNMOUNTING the previous "root" which, in this case, is '/dev/sda2'. I have to prompt the user to remove the thumb drive first or the system will just boot back into the upgrade utility.

After I set the RAM disk up and switch to it, I want to issue a 'umount' command to unmount '/dev/sda2' (and sda1,sda3 and sda4 ... all partitions on the thumb drive).

Every time I issue the 'umount /dev/sda[X]' command, I get the error message "umount: /dev/sda2: not mounted".

Here are the steps I take to set up the RAM disk, chroot to it and issue the "umount" command.

1) Format the RAM disk

     mkfs.ext4 -m 0 /dev/ram0

2) Mount the RAM disk

     mount /dev/ram0 /mnt/rd

3) CD to RAM disk and create some directories

     cd /mnt/rd

     mkdir lib

     mkdir usr

     mkdir usr/bin

     mkdir sbin

     mkdir etc

     mkdir usr/local

     mkdir usr/local/qt5_5_0

     mkdir usr/local/qt5_5_0/plugins

     mkdir usr/local/qt5_5_0/plugins/platforms/

     mkdir mnt

     mkdir dev

     mkdir proc

     mkdir sys

4) Copy over binaries...

     cp -rf /bin .

     cp -rf /sbin .

     cp -rf /usr/sbin/ usr/

     cp -rf /etc .

5) Copy over some libraries (needed for umount,reboot,etc)

      cp /lib/libtinfo.so.5 lib/

     cp /lib/libdl.so.2 lib/

     cp /lib/libc.so.6 lib/

     cp /lib/ld-linux-armhf.so.3 lib/

     cp /lib/libmount.so.1 lib/

     cp /lib/libblkid.so.1 lib/

     cp /lib/libuuid.so.1 lib/

     cp /lib/libcrypto.so.1.0.0 lib/

     cp /usr/local/qt5_5_0/lib/libQt5Quick.so.5 lib/

     cp /usr/local/qt5_5_0/lib/libQt5Gui.so.5 lib/

     cp /usr/local/qt5_5_0/lib/libQt5Qml.so.5 lib/

     cp /usr/local/qt5_5_0/lib/libQt5Network.so.5 lib/

     cp /usr/local/qt5_5_0/lib/libQt5Core.so.5 lib/

     cp /usr/lib/libGLESv2.so.2 lib/

     cp /usr/lib/libEGL.so.1 lib/

     cp /usr/lib/libGAL.so lib/

     cp /lib/libpthread.so.0 lib/

     cp /usr/lib/libstdc++.so.6 lib/

     cp /lib/libm.so.6 lib/

     cp /lib/libgcc_s.so.1 lib/

     cp /usr/lib/libpng16.so.16 lib/

     cp /lib/libz.so.1 lib/

     cp /lib/librt.so.1 lib/

     cp /usr/lib/libproxy.so.1 lib/

     cp /usr/lib/libicui18n.so.53 lib/

     cp /usr/lib/libicuuc.so.53 lib/

     cp /usr/lib/libicudata.so.53 lib/

     cp /usr/lib/libgthread-2.0.so.0 lib/

     cp /usr/lib/libglib-2.0.so.0 lib/

     cp /usr/lib/libVSC.so lib/

     cp /usr/lib/libGAL_egl.so lib/

     cp /lib/libcap.so.2 lib/

     cp /lib/libm.so.6 lib/

     cp /lib/libproc-3.2.8.so lib/

6) "Bind" all the mount points (not sure about this step, this may be where my problem lies)

     for f in proc sys dev ; do mount --bind /$f $f ; done

7) Issue a "pivot_root" command

      mkdir oldroot

     pivot_root . oldroot

8) Issue a "chroot" command

     chroot .

At this point, I'm running inside the RAM disk. If I wish, I can issue a "reboot" command at this point and the system will reboot as expected.

I'm also able to unmount all of the partitions on the thumb drive except for the previous "root" which is /dev/sda2.

When I try to unmount /dev/sda2, I get the following error message....

"umount: /oldroot: target is busy"

Can anybody shed any light on how I can troubleshoot this issue or have any idea what is not allowing me to unmount the previous "root"?

Any advice would be greatly appreciated.

Thank You.

Labels (4)
2 Replies

517 Views
b36401
NXP Employee
NXP Employee

Actually old root seems to be still mounted.

Its mount point is already "overmounted" with new root however /dev/sda2 is actually busy.

Please doublecheck it with `mount` command.

You can try to unmount it with "-f" option.

Have a great day,

Victor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

517 Views
grim
Contributor III

Thanks Victor.

I ended up abandoning this approach. "oldroot" still had too many processes running (which I was unable to kill all of).

Ended up creating a u-boot script file that gets copied to the kernel partition once all the system software has been updated. The script file merely tells u-boot to ignore USB and to boot directly from MMC, instead. Once the unit boots from MMC it deletes the script file to allow USB booting again.

0 Kudos