mkfs.ubifs problem when output file really isn't in the UBIFS root directory

Marcus Prebble marcus.prebble at axis.com
Wed Oct 10 05:04:16 EDT 2012


On Wed, 2012-10-10 at 08:47 +0200, Artem Bityutskiy wrote:
> Yeah, I am probably confused.

Or, I have explained it in a not-so-clear way ;)

> 
> On Mon, 2012-10-08 at 17:04 +0200, Marcus Prebble wrote:
> > We have remounted a static UBI volume which happens to be the rootfs (/)
> > onto another location, /tmp/newrootfs
> 
> So, you have your UBI volume, it contains your root file-sytem, right?

Exactly.

> Then you "remount your" root to /tmp/newrootfs? If yes, I would like to
> understand how exactly you do this? Give some more details.

The mount command is: 

mount -t ubifs -o ro ubi0:rootfs /tmp/newrootfs

which results in the following mount table:

[root at axis-00408c93d266 /tmp]4517# mount
ubi0:rootfs-11 on / type ubifs (ro,relatime)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
udev on /dev type tmpfs (rw,relatime)
/dev/ubi0_23 on /mnt/flash type ubifs (rw,relatime)
/dev/part/persistent on /lib/persistent type ubifs (rw,relatime)
/dev/part/iv on /usr/local type ubifs (rw,relatime)
tmpfs on /var type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
tmpfs on /dev/shm type tmpfs (rw,relatime)
tmpfs on /var/cache/recorder type tmpfs
(rw,relatime,size=111320k,nr_inodes=0)
ubi0:rootfs-11 on /var/tmp/newrootfs type ubifs (ro,relatime)

> 
> > We are trying to make an image of /tmp/newrootfs with mkfs.ubifs and
> > where the output file is /tmp/newrootfs.img.

> If the inode number of / is the same as /tmp/newroofs, and the device
> number is the same, this is the same inode, no?

I wrote a small program to test this seeing we don't have stat on target

[root at axis-00408c93d266 /tmp]4530# ./a.out / 
Stat() info for '/':
st_mode=0x41ed
st_ino=1
st_dev=10
st_rdev=0
st_size=0

[root at axis-00408c93d266 /tmp]4530# ./a.out /tmp/newrootfs/
Stat() info for '/tmp/newrootfs/':
st_mode=0x41ed
st_ino=1
st_dev=10
st_rdev=0
st_size=0

So according to stat() it is the same inode.

> 
> This means that /tmp/newrootfs.img will also be visible
> in /tmp/newrootfs/tmp/newrootfs.img, no?

No, as /tmp is a tmpfs mounted on  /var/tmp

[root at axis-00408c93d266 /]4530# touch /tmp/foo.txt   
[root at axis-00408c93d266 /]4530# ls /tmp/newrootfs/tmp/       
ls: /tmp/newrootfs/tmp/: No such file or directory
[root at axis-00408c93d266 /]4530# 

.. and is thus not reachable from /tmp/newrootfs/ 

[root at axis-00408c93d266 /]4530# ls /tmp/newrootfs/var/
[root at axis-00408c93d266 /]4530# 

Apologies for the long-winded explanation - but the output file really
isn't in the the root directory, even though apparently the inodes are
the same. 

Thanks and kind regards,

/Marcus Prebble




More information about the linux-mtd mailing list