Bug 4308 - busybox/mount fails to mount loop devices
Summary: busybox/mount fails to mount loop devices
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 1.4
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 1.1.2
Assignee: Saul Wold
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2013-04-16 09:34 UTC by Khem Raj
Modified: 2013-04-18 07:28 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Khem Raj 2013-04-16 09:34:53 UTC
busybox is failing to mount loop devices

mount -o rw,loop,noatime,nodiratime /tmp/my.img /media/isolinux
mount: mounting /dev/loop0 on /media/isolinux failed: No such device

sh-4.2# ls /media/isolinux/ -ld
drwxr-xr-x    2 root     root             0 Apr 16 09:10 /media/isolinux/
sh-4.2# ls /dev/loop0 -ld
brw-rw----    1 root     disk        7,   0 Apr 16 09:10 /dev/loop0


The offending commit is below 


commit ecd90bc6aa63da2aef2513ac090d4b426b2b719c
Author: Saul Wold <sgw@linux.intel.com>
Date:   Tue Apr 9 23:25:54 2013 -0700

    busybox: fail on no media
    
    The current behaviour of busybox is to try all fstype when automounting
    even when no media exists.  The util-linux mount command bails when no
    media exists, so change the behaviour of busybox to do the same.
    
    It could also be argued that the KERN_INFO message from btrfs could be
    removed, but that would be harder to accomplish.
    
    (From OE-Core rev: e5403f55a1e9b1747535450fd95f499c85211771)
    
    Signed-off-by: Saul Wold <sgw@linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Comment 1 Saul Wold 2013-04-17 05:55:11 UTC
I looked into this and created a local ext2 image, with mkfs.ext2 and then tried to mount it loop, it worked correct both when specifing a -t and letting it auto mount, can you give me more details about the /tmp/my.img file you created?

I tried this with ext2, ext3, and ext4


ls -l /bin/mount
lrwxrwxrwx    1 root     root            12 Apr 17 05:40 /bin/mount -> /bin/busybox
root@qemux86-64:~# mount -o rw,loop -t ext2 ext2.img mnt
root@qemux86-64:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                16.8M     14.4M      1.5M  90% /
devtmpfs                 55.4M      4.0K     55.4M   0% /dev
tmpfs                    57.1M    228.0K     56.9M   0% /var/volatile
tmpfs                    57.1M         0     57.1M   0% /media/ram
/dev/loop0             1003.0K     17.0K    935.0K   2% /home/root/mnt
root@qemux86-64:~# umount mnt
root@qemux86-64:~# mount -o rw,loop ext2.img mnt
EXT4-fs (loop0): mounted filesystem without journal. Opts: (null)
root@qemux86-64:~# mount
rootfs on / type rootfs (rw)
/dev/root on / type ext3 (rw,relatime,barrier=1,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=56696k,nr_inodes=14174,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /var/volatile type tmpfs (rw,relatime)
tmpfs on /media/ram type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)
/dev/loop0 on /home/root/mnt type ext4 (rw,relatime)
root@qemux86-64:~#
Comment 2 Khem Raj 2013-04-17 05:56:25 UTC
mine is .iso image
Comment 3 Laurentiu Palcu 2013-04-17 12:05:25 UTC
It looks like the command works just fine if passing the -t iso9660 to the mount command. I think the checking done in the mentioned patch is not in the right place or some extra checking must be added.
Comment 4 Laurentiu Palcu 2013-04-17 12:47:19 UTC
Apparently, when it tries to mount the image as 'fat', it exits with ENODEV and bails out. It doesn't have a chance to try 'iso'.

strace output:
mount("/dev/loop0", "tmp/", "ext4", MS_NOATIME|MS_NODIRATIME|MS_SILENT, NULL) = -1 EINVAL (Invalid argument)
mount("/dev/loop0", "tmp/", "ext3", MS_NOATIME|MS_NODIRATIME|MS_SILENT, NULL) = -1 EINVAL (Invalid argument)
mount("/dev/loop0", "tmp/", "ext2", MS_NOATIME|MS_NODIRATIME|MS_SILENT, NULL) = -1 EINVAL (Invalid argument)
mount("/dev/loop0", "tmp/", "vfat", MS_NOATIME|MS_NODIRATIME|MS_SILENT, NULL) = -1 EINVAL (Invalid argument)
mount("/dev/loop0", "tmp/", "fat", MS_NOATIME|MS_NODIRATIME|MS_SILENT, NULL) = -1 ENODEV (No such device)

So, if the image type is not configured in the kernel, it'll always return ENODEV. So, perhaps, we should not check for ENODEV. Bail out only if we get ENOMEDIUM. I'll give it a test.
Comment 5 Laurentiu Palcu 2013-04-17 13:54:49 UTC
Sent a fix for this on oecore mailing list.