[BusyBox] 1.00-pre1 problem: can't umount oldroot after pivot_root&chroot

Yang Xiaopeng yxp at hanwang.com.cn
Mon Jul 28 02:06:25 UTC 2003


Hi,

I use busybox in my embedded system, and use cramfs as root filesystem
in flash. To update the root filesystem without reboot the board, I
wrote some scripts to do the following things:

1. Copy rootfilesystem image file to /tmp(tmpfs)
2. Restart init, this step will kill all processes, umount all
filesystem except /(cramfs) and /tmp(tmpfs), then init exec my script.
3. Here is my first script:

	#!/bin/sh

	# Copy all system file to new root
	cp -a /bin /sbin /etc /lib /dev /tmp

	cd /tmp
	mkdir old_root proc tmp

	mount -t proc none proc

	# Change root device
	pivot_root . old_root

	#chroot to tmpfs
	exec sbin/chroot . sbin/flash.sh <dev/console >dev/console 2>&1

These steps work well in both 0.60.5 and 1.00-pre1.

In my second script (flash.sh), I first do an umount on old_root:

	umount old_root

this works in busybox-0.60.5, but fails in busybox-1.00-pre1 with the
error "Device or resource is busy". By adding a

	mount

command before above line, I found the difference: in 0.60.5, the device
on /old_root is the real device:

	/dev/mtd_blk2 on /old_root type cramfs (rw)

but in 1.00-pre1, the device changes to /dev/root:

	/dev/root on /old_root type cramfs (rw)

I wonder whether this change cause the error? Is this a bug?







More information about the busybox mailing list