1

On a Raspberry Pi with the raspbian distro i need to make an extra partition that can be read from both windows and linux.

So i use FDISK on /dev/mmcblk0 (the sd card) to create a new partition which is a FAT32 partition like so

Device         Boot   Start      End  Sectors   Size Id Type
/dev/mmcblk0p1           16   125055   125040  61.1M  b W95 FAT32
/dev/mmcblk0p2       125056  2000000  1874945 915.5M 83 Linux
/dev/mmcblk0p3 *    2000001 15523839 13523839   6.5G  c W95 FAT32 (LBA)

After i have written the above and rebooted the device there is no extra drive or anything listed like the above partition, which i determine by using the df -h command:

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       885M  442M  384M  54% /
devtmpfs        483M     0  483M   0% /dev
tmpfs           487M     0  487M   0% /dev/shm
tmpfs           487M  6.5M  481M   2% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           487M     0  487M   0% /sys/fs/cgroup
tmpfs           487M     0  487M   0% /tmp
/dev/mmcblk0p1   61M   35M   27M  57% /boot
tmpfs            98M     0   98M   0% /run/user/0

The partition needs to be visible inside the linux terminal (mounted) and also visible if i pull out the card and plug it into a windows pc

8
  • df -h only prints mounted filesystems. What does file -s /dev/mmcblk* tell you? (you need to run that as root, you do not need to umount anything to be able to run that) – grochmal Jul 26 '16 at 21:53
  • it lists the all the partitions, including /dev/mmcblk0p3: data but nothing more about mmcblk0p3 – Daniel Jørgensen Jul 26 '16 at 22:16
  • That looks fine, it is a partition alright then. But did you actually create a filesystem on the partition? e.g. mkfs.vfat -F 32 /dev/mmcblk0p3 – grochmal Jul 26 '16 at 22:38
  • if i write mkfs vfat -F 32 /dev/mmcblk0p3 it returns this output mkfs.ext2: invalid blocks '/dev/mmcblk0p3' on device '32'. I cannot write mkfs.vfat as that gives me command not found – Daniel Jørgensen Jul 26 '16 at 22:47
  • Figured that the reason for the command not found was because i needed dosfstools. Got that and now the command worked it seems as i got no errors when i ran the command you mentioned. But i still dont see it in df -h . Do i need to do anything further? – Daniel Jørgensen Jul 26 '16 at 22:52
3

As we discussed the issue was that fdisk does not create a filesystem, it only creates partitions.

To create a FAT32 filesystem on raspbian you need to install dosfstools and then use mkfs.vfat as follows:

mkfs.vfat -F 32 <device>

In this specific case

mkfs.vfat -F 32 /dev/mmcblk0p3

After this the device is mountable.


Note: FAT32 has no uid/gid or access permissions written to the files on the filesystem. Therefore you may want to use the -o option of mount to use the files as a normal user. For example

mount -o uid=myuser /dev/mmcblk0p3 /home/myuser/mymountpoint

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.