fsck for vfat media on Arch


11 posts
by sdjf » Mon Dec 17, 2012 2:38 pm
How do I check the file system on media that is vfat format? Other Linux systems have fsck.vfat, but it does not appear to be on the Pi? I do prefer ext file systems but since my flash memory cards and sticks also need to be read by my PDA, I need to leave them as vfat since if the PDA crashes during read.write operations, ext2 and ext3 file systems seem to get corrupted much more seriously than the vfat.

The following is what I get when I try to mount and then fsck a 4 GB stick.

[root@alarmpi ~]# mount /dev/sda1
mount: wrong fs type, bad option, bad superblock on /dev/sda1,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try dmesg | tail or so
[root@alarmpi ~]# fsck
fsck fsck.ext4 fsck.reiserfs
fsck.cramfs fsck.ext4dev fsck.xfs
fsck.ext2 fsck.jfs
fsck.ext3 fsck.minix
[root@alarmpi ~]# fsck /dev/sda1
fsck from util-linux 2.21.2
fsck: fsck.vfat: not found
fsck: error 2 while executing fsck.vfat for /dev/sda1
[root@alarmpi ~]#

I really do not want to have to eject the media from the Pi and move it to another Linux system to do this, it is something that the Pi should be able to do. If I am having trouble mounting a device, I ought to be able to debug the situation directly on the Pi.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1258
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by pepedog » Mon Dec 17, 2012 6:11 pm
You want the package dosfstools
Save this file to your fat
http://us.mirror.archlinuxarm.org/armv6h/extra/dosfstools-3.0.12-1-armv6h.pkg.tar.xz
pacman -U /boot/dosfstools-3.0.12-1-armv6h.pkg.tar.xz
Will try to put this on next rootfs
Posts: 940
Joined: Fri Oct 07, 2011 9:55 am
by sdjf » Mon Dec 17, 2012 6:49 pm
@pepedog: thanks, it does seem like something pretty standard I was shocked to see was not built in.

My trouble now is that I cannot mount the vfat media containing my local repository for Pacman to install anything...may have to put the essential things in /boot! I hope not, but I see now that is what you said to do. Okay.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1258
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by MarkFoley » Tue Nov 05, 2013 1:29 am
I've seen a number of posts that *almost* answer my question of fsck on Raspi Arch, but I'm still confused. I am a long-time Linux user, but new to raspberry and Arch.

I've built an Arch SD card and have messed with it repeatedly over the past week, often powering down without sync or shutdown. Eventually, I corrupted the file system and couldn't read/write any files or run programs. I'd get some kind of mmc: error on the console (don't remember exactly). I reformatted and resinstalled Arch, now I have to reconstruct all my work.

I'd like to have the root file system checked on boot and be able to fsck other filesystems. How do I do that?

My fstab contains the lone entry: "/dev/mmcblk0p1 /boot vfat defaults 0 0". This shows fsck'ing off. In any case, this is just for the miniscuile /boot partition. Not really what I'm after. df gives me:

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 30317468 1320776 27752084 5% /
devtmpfs 84748 0 84748 0% /dev
tmpfs 236384 0 236384 0% /dev/shm
tmpfs 236384 320 236064 1% /run
tmpfs 236384 0 236384 0% /sys/fs/cgroup
tmpfs 236384 0 236384 0% /tmp
/dev/mmcblk0p1 91962 23886 68076 26% /boot

The main partition I want to check periodically is /dev/root, since that is where I put everything. What fstype is it? If I run `mount` w/o arguments I get a bewildering number of mounts with myriad 'cgroup's on /sys/fs/cgroup/... and other unfamiliar things. If I grep for /dev I get:

/dev/mmcblk0p5 on / type ext4 (rw,relatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=84748k,nr_inodes=21187,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
mqueue on /dev/mqueue type mqueue (rw,relatime)
/dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=ascii,shortname=mixed,errors=remount-ro)

my /dev/root isn't listed. fdisk -l shows:

Disk /dev/mmcblk0: 29.5 GiB, 31611420672 bytes, 61741056 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00057540

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA)
/dev/mmcblk0p2 186368 61741055 30777344 5 Extended
/dev/mmcblk0p5 188416 61741055 30776320 83 Linux

leading me to believe that my /dev/root is really /dev/mmcblk0, but is it? There appears to be 3 sub-partitions for that device.

I'm confused!!! How do I fsck my /dev/root partition?
Posts: 17
Joined: Thu Jun 27, 2013 8:21 am
by sdjf » Tue Nov 05, 2013 3:56 am
The basic boot partition is vfat, and the root partition is ext4.

Originally these were partitions 1 and 2 but the second partition got changed in how it gets called in order to be compatible with the Foundation's NOOBs images and software.

There are instructions in the Arch subforum written by pepedog about how to boot into the emergency console, I have not done it as it does not work over ssh.

Instead, I mount the card on another box (actually the Pi running ARch on another SD card) and check the boot partition with fsck.vfat.

Checking the root partition is tricky, what I did was try mounting it with different device references until I found onoe that succeeded, and then I knew which one to use for fsck!

I think it is likely to be either /dev/sda2 or /dev/sda5, if the card is seen as /dev/sda.

But make sure you make a backup of all important files first, fsck can be a very dangerous tool if the file system and/or journal are badly corrupted. I have made the mistake, way too many times, of running fsck on a file system that had no backup, and losing nearly everything. Journalling file systems are better than the old vfat and ext2 file system types I was using, but I still have lost data with ext3 and ext4.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1258
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by pepedog » Tue Nov 05, 2013 9:05 am
fschk on boot requires an initrd.
Posts: 940
Joined: Fri Oct 07, 2011 9:55 am
by MarkFoley » Thu Nov 07, 2013 1:33 am
I'm beginning to think that Arch is not a very good distro for the RasPi platform. I am unable to get through a compete system setup without the SD card getting corrupt. I did figure out how to do an fsck in another Linux computer:

fsck -t fat /dev/sda1
fsck -t ext4 /dev/sda4

A couple of days ago, I did manage to create a tarfile of a mostly setup system and copied that to another Linux system. I have been reformatting the SD card, installing the base arch system, and restoring that tarfile (after first deleting the files in /var/lib/packman/local/) to recover things. I've done this several times. Most recently, I did get everything set up and was creating a differential tarfile with the changes, and the filesystem crapped out again. Couldn't read or write or find executables. I put the SD into the other Linux computer and fsck'd the partitions, but still wouldn't boot. The partitions seem to mount OK on the other Linux system and all the files seem to be there and OK, so I can't figure out what's up. When I try to boot on the Raspberry I get the following console messages immediately following the "Welcome to Arch Linux ARM!" message:

[ 3.370506] system[1]: systcmd-journalid.socket lacks Listen setting. Refusing.
[ 3.413643] system[1]: Failed to read configuration file '/usr/lib/systemd/system/sleep.target': is a directory
[ 3.444714] system[1]: Unable to break cycle
[ 3.449913] system[1]: Failed to isolate default target: Trasnaction order is cyclic. See system logs for details.

It hangs there forever, except that it does blank out the screen after a few minutes and I can hit the shift key to re-display the console.

What do these error messages mean and how do I fix it? Can I do so without formatting and re-installing?

Upon examining '/usr/lib/systemd/system/sleep.target' on another Linux host, I find that it is indeed a directory and it contains a symbolic link named systemd-random-seed-save.service which is linked to ../systemd-journald.service which appears to be a rather ordinary service parameter file containing the following:

# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Login Service
Documentation=man:systemd-logind.service(8) man:logind.conf(5)
Documentation=http://www.freedesktop.org/wiki/Software/systemd/logind
Documentation=http://www.freedesktop.org/wiki/Software/systemd/multiseat
Wants=user.slice
After=nss-user-lookup.target user.slice

[Service]
ExecStart=/usr/lib/systemd/systemd-logind
Restart=always
RestartSec=0
BusName=org.freedesktop.login1
CapabilityBoundingSet=CAP_SYS_ADMIN CAP_AUDIT_CONTROL CAP_CHOWN CAP_KILL CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE C
AP_FOWNER CAP_SYS_TTY_CONFIG

# Increase the default a bit in order to allow many simultaneous
# logins since we keep one fd open per session.
LimitNOFILE=16384

help would be appreciated. I may try Raspian next if this problem continues.
Posts: 17
Joined: Thu Jun 27, 2013 8:21 am
by sdjf » Thu Nov 07, 2013 2:06 am
I wonder if you have a bad SD card, have you run badblocks on each partition? Example:
badblocks -vs /dev/sdb1

Also, inadequate power supply can also mess up the system, did you say what devices are attached? And have you run any other distribution on your Pi, or is Arch the first one you tried?
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1258
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by MarkFoley » Thu Nov 07, 2013 3:59 am
> I wonder if you have a bad SD card, have you run badblocks on each partition? Example: badblocks -vs /dev/sdb1

I just tried that. No bad blocks.

> Also, inadequate power supply can also mess up the system, did you say what devices are attached?

I am using a 1.5V 2100mA supply recommend by the store where I bought my Rpi. I have a 2nd USB Ethernet device and a USB external drive attached to a powered hub -- the hub is attached to the Raspberry, although this issue seems to happen whether or not the hub is connected. The USB hub itself seems sufficient to power the Raspberry Pi because when I unplug the 2.1A supply the device stays up. I have to unplug the hub as well. I have been careful to always do `sync;shutdown -h now` to take down the Raspberry versus just yanking the power. That seems to help, but is not foolproof. It also seems that `reboot` causes more corruptions then `shutdown -r now`. I've tried expanding the partition to 32G and I've tried setting the MHz to "medium", but neither partition size nor speed seem to make any difference one way or the other.

> And have you run any other distribution on your Pi, or is Arch the first one you tried?

I originally installed Raspian, but that was on a different 4GB SD (Arch is on a 32GB card). I use Raspian for downloading and watching movies and I don't recall that I've ever had a problem with it. It think the problem must either be the card of the distribution.

Perhaps I should try Raspian and see if that makes any difference. What do you think?
Posts: 17
Joined: Thu Jun 27, 2013 8:21 am
by pepedog » Thu Nov 07, 2013 9:07 am
Poweroff is preferred command
Posts: 940
Joined: Fri Oct 07, 2011 9:55 am
by sdjf » Thu Nov 07, 2013 2:11 pm
should always use "sync" before "reboot".

some SD cards just do not work well on Pi, I wonder if that is the case with your 32GB card. You could test that by trying raspian on it.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1258
Joined: Fri Mar 16, 2012 5:20 am
Location: California