[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How can I force a full fsck on a remote system at next reboot?



Quoting Jape Person (japers@comcast.net):
> 
> 
> On 03/12/2015 05:48 PM, Michael Biebl wrote:
> >
> >touch /forcefsck is deprecated under systemd, but still supported.
> >
> >What sysvinit's shutdown -F does, is simply create that flag file.
> >That parameter was removed from systemd's shutdown command, as its use
> >is discouraged, but as said, still supported.
> >
> >Run "touch /forcefsck" under systemd and it will happily check the file
> >systems on next boot.
> >
> >
> >As for alternate ideas: I could think, that having update-grub generate
> >an alternate grub entry, which adds fsck.mode=force to the kernel
> >command line and which can be selected during boot, might be one idea.
> >
> >
> >For remote systems, where you don't have a sideband channel like iLO,
> >you could use "grub-set-default", to choose the boot entry for the next
> >boot. See man 8 grub-set-default.
> >
> 
> Hi, Michael.
> 
> Well, I almost got it.
> 
> Adding a new menu entry to run fsck was easy enough. I modified the
> /etc/grub.d/40_custom script and ran update-grub, and the new entry
> thus created works when chosen from the grub menu.
> 
> However, I can't get grub-set-default to redesignate that new menu
> entry as the default.
> 
> What I did to try to get it to work:
> 
> 1. changed the "GRUB_DEFAULT=0" entry in /etc/default/grub to
> "GRUB_DEFAULT=1" (Also tried "GRUB_DEFAULT=saved", just in case the
> manual was being explicit about the value.)

You need to set GRUB_DEFAULT=saved and then run grub-mkconfig.
This adds a little bit of juggling code to the top of /boot/grub/grub.cfg
where it plays about with the contents of /boot/grub/grubenv (which
you should never muck about with).

> 2. ran grub-set-default (I tested the command using both the menu
> line number and the full menu line name in quotes.)

As mentioned in this thread, you can use numbers, but names are more
reliable, I find. If you want long explanations in your menu entries,
just use short names in the $menuentry_id_option string:

menuentry 'Debian GNU/Linux, with Linux 3.16.0-4-686-pae (SINGLE)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'fsck' {

Each time you run grub-set-default, take a look at /boot/grub/grubenv
and you will find the string there. That's what survives through the
actual reboot, and what the juggling code is juggling.

I wouldn't have thought a menuentry in 40_custom should need the 'a>b'
format. That's for when 'a' is a submenu, and 'b' is within 'a'.

Cheers,
David.


Reply to: