Forcing filesystem check at boot

Development on core packages and the distribution goes on in here.

Forcing filesystem check at boot

Postby dan64 » Sat Feb 04, 2012 9:50 am

I have a PogoPlug Pink (ARMv5) that is whitout a power button. Sometimes happen that I have to perform an hard shutdown (unplug the power-plug) and then I have to check the filesystem. Should be useful to perform this check whitout use another Linux installation. I have tried the following command, but doesn't work:

$this->bbcode_second_pass_code('', '
shutdown -Fr now
')
dan64
 
Posts: 75
Joined: Mon Jan 31, 2011 8:52 pm

Re: Forcing filesystem check at boot

Postby BinaryJay » Sat Feb 04, 2012 5:44 pm

I agree this would be nice. Currently have to shut down, remove the drive and plug it into another PC... given the rate that these things chew up the filesystem due to crashes etc. I almost think that it ought to force cleaning the filesystem every boot.
BinaryJay
 
Posts: 87
Joined: Mon Dec 06, 2010 10:27 pm

Re: Forcing filesystem check at boot

Postby hydro » Sat Feb 04, 2012 8:05 pm

shutdown -F will only create a file /etc/forcefsck before rebooting. It's up to /etc/rc.sysinit to check for that file and, if it exists, run fsck with option -A. Have a look at fsck's manpage. I'm not sure whether at least the root filesystem is checked even when it is not included in /etc/fstab.
VDR on DockStar / Pogoplug E02: http://linux.bplaced.net/
hydro
 
Posts: 210
Joined: Wed Jun 15, 2011 2:03 pm
Location: Germany

Re: Forcing filesystem check at boot

Postby dan64 » Sun Feb 05, 2012 10:09 am

This is the code of rc.sysint

$this->bbcode_second_pass_code('', '
# Check filesystems
[[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f"
declare -r FORCEFSCK
run_hook sysinit_prefsck
if [[ -x $(type -P fsck) ]]; then
stat_busy "Checking Filesystems"
fsck_all >|"${FSCK_OUT:-/dev/stdout}" 2>|"${FSCK_ERR:-/dev/stdout}"
declare -r fsckret=$?
(( fsckret <= 1 )) && stat_done || stat_fail
else
declare -r fsckret=0
fi
run_hook sysinit_postfsck

# Single-user login and/or automatic reboot if needed
fsck_reboot $fsckret

status "Remounting Root" \
mount -o remount,rw /

# now mount all the local filesystems
run_hook sysinit_premount
status "Mounting Local Filesystems" \
mount_all
run_hook sysinit_postmount
')

the file is checked so should work. But if I use the command shutdown -Fr now, after the reboot "dmesg" still display warnings that the filesystem is unchecked.
dan64
 
Posts: 75
Joined: Mon Jan 31, 2011 8:52 pm

Re: Forcing filesystem check at boot

Postby hydro » Sun Feb 05, 2012 12:03 pm

Well, the function fsck_all in the code you posted is defined in /etc/rc.d/functions
$this->bbcode_second_pass_code('', '# Check local filesystems
fsck_all() {
fsck -A -T -C"$FSCK_FD" -a -t "no${NETFS//,/,no},noopts=_netdev" $FORCEFSCK
return $?
}')

and this is what man fsck says about -A
$this->bbcode_second_pass_quote('', 'W')alk through the /etc/fstab file and try to check all filesystems in one run

but the default /etc/fstab doesn't even contain the root partition, only
$this->bbcode_second_pass_code('', '
tmpfs /tmp tmpfs nodev,nosuid 0 0
')
I don't know about your /etc/fstab, but if you didn't add an entry for the root partition, I would not expect it to be checked. If you add an entry, mind that
$this->bbcode_second_pass_quote('', 'F')ilesystems with a fs_passno value of 0 are skipped and are not checked at all
VDR on DockStar / Pogoplug E02: http://linux.bplaced.net/
hydro
 
Posts: 210
Joined: Wed Jun 15, 2011 2:03 pm
Location: Germany

Re: Forcing filesystem check at boot

Postby dan64 » Sun Feb 05, 2012 2:45 pm

So you are suggesting to add in fstab an entry like:

$this->bbcode_second_pass_code('', '
# <file system> <dir> <type> <options> <dump> <pass>
/dev/sda1 / ext2 rw,realtime,errors=continue 0 0
')

the output of command mount is:
$this->bbcode_second_pass_code('', '
/dev/root on / type ext2 (rw,relatime,errors=continue)
devtmpfs on /dev type devtmpfs (rw,relatime,size=126652k,nr_inodes=31663,mode=755)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
/sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
/run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
shm on /dev/shm type tmpfs (rw,nosuid,nodev,relatime)
')

the root is mounted on /dev/root so in fstab I have to use this device instead of /dev/sda1 ?
dan64
 
Posts: 75
Joined: Mon Jan 31, 2011 8:52 pm

Re: Forcing filesystem check at boot

Postby hydro » Sun Feb 05, 2012 3:25 pm

Yes, adding an entry in fstab is my suggestion, but, as I said, you must change the <pass> value from 0 to 1.
/dev/sda1 will work as long as there is only one USB storage device attached. /dev/root worked the last time I tried (months ago). You can also use LABEL or UUID as reported by blkid, or the link in /dev/disk/by-uuid/ that points to /dev/sda1
VDR on DockStar / Pogoplug E02: http://linux.bplaced.net/
hydro
 
Posts: 210
Joined: Wed Jun 15, 2011 2:03 pm
Location: Germany

Re: Forcing filesystem check at boot

Postby dan64 » Sun Feb 05, 2012 4:23 pm

Thanks, I have also read this post http://archlinuxarm.org/forum/viewtopic.php?f=29&t=1374 that gives the same kind of advises, but it seems that doesn't work.
Are you sure that worked for you ? such procedure it's reliable on this system ?
dan64
 
Posts: 75
Joined: Mon Jan 31, 2011 8:52 pm

Re: Forcing filesystem check at boot

Postby hydro » Sun Feb 05, 2012 4:38 pm

Yes, I am sure. I posted on this topic before:
viewtopic.php?f=23&t=1887#p10351
VDR on DockStar / Pogoplug E02: http://linux.bplaced.net/
hydro
 
Posts: 210
Joined: Wed Jun 15, 2011 2:03 pm
Location: Germany

Re: Forcing filesystem check at boot

Postby dan64 » Sun Feb 05, 2012 9:20 pm

Ok, thanks.
dan64
 
Posts: 75
Joined: Mon Jan 31, 2011 8:52 pm


Return to Arch Linux ARM

Who is online

Users browsing this forum: No registered users and 10 guests