How to mount ext2 fs?

jacknad picture jacknad · Mar 13, 2013 · Viewed 16.9k times · Source

fdisk is used to create mmcblk0p3 on the 64G SD card.

Disk /dev/mmcblk0: 63.8 GB, 63864569856 bytes
255 heads, 63 sectors/track, 7764 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

        Device Boot      Start         End      Blocks  Id System
/dev/mmcblk0p1   *           2           6       40162+  c Win95 FAT32 (LBA)
/dev/mmcblk0p2               7         130      996030  83 Linux
/dev/mmcblk0p3             131        7764    61320105  83 Linux

The fs is then formatted like this:

$ mke2fs -L media /dev/mmcblk0p3
Filesystem label=media
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3833856 inodes, 15330026 blocks
766501 blocks (5%) reserved for the super user
First data block=0
Maximum filesystem blocks=16777216
468 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, ...

Mount point /media definitely exists and $ mount /dev/mmcblk0p3 /media works fine when mmcblk0p3 is a FAT32 FS on a Win95 FAT32 partition. I need to change from FAT32 to ext2 since the FAT32 partition 3 is too easily hosed in this embedded Linux target (power cycle, USB mass storage disconnects, etc.). An Ubuntu 10.04 desktop system has been used to verify that the partition type is ext2 and is able to mount the SD card partition but this needs to work on the embedded Linux target. The kernel version is 2.6.32-17-ridgerun with BusyBox v1.18.2.

  • Why does $ mount /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: Invalid argument?
  • Why does mount -t ext2 /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: No such device?

Answer

user568109 picture user568109 · Mar 17, 2013

Why does $ mount /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: Invalid argument?

The kernel can probably mount the filesystem, but it wrongly guess its type.

Why does mount -t ext2 /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: No such device?

If, after you specified -t, you get a problem like that, it is very likely that the kernel cannot mount the requested filesystem for you. Check if there is a module for that filesystem and it is loaded.

lsmod          # show modules
modprobe ext2  # load module

Sources : http://www.silas.net.br/doc.notes/unix/linux/busybox-troubleshooting.html

As far as I know ext2 modules are already loaded by default. But it won't hurt to check. The problem here I think is the ambiguity due to mke2fs. mke2fs can be used to create ext2/ext3/ext4 filesystems. You have to specify the file system via -t option. Try doing this :

#mkfs -t ext2 /dev/hda1
#mkfs.ext2 /dev/hda1

You missed out -t option in your command making mke2fs format it with filesystem in default conf.