9

When I am running linux from sd card and try to mount sd card -no problem, works fine. But when I am running linux from flash memory I am unable to mount my SD card:

# mount /dev/mmcblk0p1 /mnt/ 
mount: mounting /dev/mmcblk0p1 on /mnt/ failed: Invalid argument

What could be the basic reason for this error ?

Additional Info

root@Xilinx-ZC702-14_7:/# mount -t /dev/mmcblk0p1 /mnt
mount: can't find /mnt in /etc/fstab 

root@Xilinx-ZC702-14_7:/var/volatile/log# ls
wtmp

root@Xilinx-ZC702-14_7:/var/volatile/log# dmesg
dmesg: klogctl: Function not implemented
  • 1
    Please try the complete command (-t ...) so that the fstab entry is not used. – Hauke Laging Mar 4 '14 at 15:03
  • 1
    Does anything useful get written into /var/log/messages? How about dmesg | tail? – Flup Mar 7 '14 at 15:09
  • @Flup i updated my question above – gpuguy Mar 26 '14 at 11:19
  • 4
    mount -t /dev/mmcblk0p1 /mnt isn't a complete command. If you know the filesytem type, you should specify it after the -t argument (e.g. mount -t vfat /dev/mmcblk0p1 /mnt) or omit -t completely. – James Hebden Mar 26 '14 at 12:08
  • omitting did not work as you can see above – gpuguy Mar 26 '14 at 12:24
10
+25

As commented by goldilocks, mount -t expects the filesystem type to come after -t, so it won't work. Otherwise it sounds like you just need to specify the filesystem type. If you don't know the filesystem type, then there are a list of methods to find out in this answer. If the file command is available, this is probably the best method. As root you would do:

file -s /dev/mmcblk0p1

Note also that if the filesystem type is not in listed in /proc/filesystems, then the driver is not compiled into the kernel and so must be available as an external module. Once you have the correct type, you can try:

mount -t correct_type /dev/mmcblk0p1 /mnt

As a final thought, also make sure the /mnt directory exists! If not create it with mkdir /mnt.

  • mounts requires sudo? – Ferroao Apr 8 '17 at 21:29
  • @Ferroao, yes mounting requires root privileges. – Graeme Apr 8 '17 at 21:33
  • if i need to modify , create files in that sd will I need sudo? – Ferroao Apr 8 '17 at 21:48
  • @Ferroao, that depends on the filesystem you are trying to mount. For Linux filesystems permissions/owner/group on each file/directory determine who can read/write. – Graeme Apr 8 '17 at 22:06
3

Basic reasons: (updated)

1) Your system does not (properly?) initialize or does not recognize the SD when booting from flash. Is there the /dev/mmcblk0 device after you boot from flash? What does fdisk -l /dev/mmcblk0 say?

2) There is no file system on /dev/mmcblk0p1, you need to create a file system first (mkfs ...). Check with file -s /dev/mmcblk0p1

3) The file system on /dev/mmcblk0p1 is corrupted, you need to check / repair it, try fsck /dev/mmcblk0p1, or create a new one

4) Your kernel (when booting from flash) does not have the needed file system driver, check cat /proc/filesystems and ls "/lib/modules/$(uname -r)/kernel/fs/" and see if that list contains the needed file system type. Typically, older kernels don't support ext4, while your OS might already have tools to create an ext4 file system.

5) Hardware defect - could be the SD card, the controller, wiring ... but if it works when booting from the SD card then this is most probably not the case.

  • Note that the filesystems listed in /proc/filesystems are only the ones which are compiled into the kernel. For example my /proc/filesystems doesn't contain vfat, but I can still mount a vfat system since it is available as a module. – Graeme Mar 31 '14 at 17:25
  • Looks good, although the OP may just have to specify the type. The util-linux mount tries to identify the filesystem via blkid then attempts everything in /etc/filesystems or /proc/filesystem. I think this is the busybox mount, so it probably does less. Either would likely miss a specialist flash filesystem. – Graeme Apr 1 '14 at 10:32
2

First check the file systems supported in the kernel.

[kevin@hexcore ~]
$ cat /proc/filesystems 
....
    ext3
    ext2
    ext4
....

I assume that you are trying to mount the same SD card from which you are running the Linux. If so, I assume, quite reasonably, that it has native file system support in Linux. To make sure you have loaded the SD card driver, you can try,

$ sudo modprobe sdhci
$ dmesg | tail -n 10
sdhci: Secure Digital Host Controller Interface driver

Now, try read access to partitions:

$ sudo dd if=/dev/mmcblk of=/dev/null bs=4k count=0  # note: count = 0

Alternatively:

$ sudo fdisk -l /dev/mmcblk

fdisk will tell you the partition types as well.

This assures you that the SD card driver can access the block device. Now you can run parted to print the file systems:

$ sudo parted /dev/mmcblk
(parted) p
Number  Start   End     Size    Type     File system     Flags
 1      1049kB  8000MB  7999MB  primary  linux-swap(v1)
 2      8000MB  500GB   492GB   primary  ext4

Once you know the FS, mount it with

$ sudo mount -t <FS> /dev/mmcblkpX </target/dir>
  • Are you sure about that? parted can analyze the signature as well as far as I can remember. fdisk just dumps the partition type. – Kevin Apr 4 '14 at 14:58
  • Ok, your right, parted does try to determine the filesystem type. Comment removed. – Graeme Apr 4 '14 at 15:50
-1

I seem to remember this is the error you get when the type of partition you're trying to mount isn't supported.

  • If you know what the partition type is, check the appropriate fsck function is in /sbin and that the appropriate modules are in the kernel (/proc/modules) – sibaz Mar 26 '14 at 16:58
  • i dont know the partition type. is there any command to find the partition type? But I have see /proc/modules--its empty – gpuguy Mar 26 '14 at 17:13
  • If you have root this will be a lot easier, but if, as I think you are, you're doing this on Android, you're looking for blkid, if not, and it's a more conventional Linux environment, lsblk is probably preferable. – mikeserv Mar 26 '14 at 17:16
  • I will check lsblk tomorrow.But why is /proc/modules empty. – gpuguy Mar 26 '14 at 17:25
  • How can you know that and still be a whole day away from typing 5 letters at your prompt? – mikeserv Mar 26 '14 at 18:43
-1

Maybe you need to use (parted command) due to partition size:

# /sbin/parted /dev/mmcblk0p1
(parted) mklabel gpt
this disk will be lost. Do you want to continue?
Yes/No? yes
....
(parted) quit

To make sure that the partition is properly created use /sbin/parted /dev/mmcblk0p1 print”

Then you have to format the created partition

/sbin/mkfs -t correct_type /dev/mmcblk0p1
  • 2
    Using parted on /dev/mmcblk0p1 will create a partition table on a partition of a device which has already been partitioned. Also, following these instructions will erase all data on the device. – Graeme Mar 31 '14 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.