Page 1 of 1

Customize your boot (rc.local replacement)

Posted: 29 Jan 2016, 12:16
by datruche
post split from new tutorials section viewtopic.php?f=138&t=5450

Muuuch usefull ! Will test that piece of info tonight .

Tested aus9 tutorial and just works :D
Here is a shortened memo (note: originaly posted under aus8 tutorial then forum modo moved it here)

In Nemesis where do you guys put your "rc.local" (have simple commands run upon boot)?
In:
/etc/local.d/

Syntax is the same as "rc.local"

Note that any command you put here are system wide. There's a README in there for the smart guys (who RTFM ;)

Creation

1/ In any case

Code: Select all

# mkdir -p PATH/TO/CHANGES/local.d
2/ Starting fresh (with no working rc.local)

Code: Select all

# $EDITOR PATH/TO/CHANGES/local.d/zz.start

Code: Select all

#/!bin/bash

[Make your changes, eg.
mount DEVICE DIRECTORY OPTIONS]
2'/ You already have a working rc.local

Code: Select all

# cat /etc/rc.local > PATH/TO/CHANGES/local.d/zz.start
(-) #/!bin/sh
(+) #/!bin/bash
[ Your simple command(s) ]

3/ In any case, make it executable

Code: Select all

# chmod +x PATH/TO/CHANGES/local.d/zz.start

Re: Customize your boot (rc.local replacement)

Posted: 06 Feb 2016, 20:36
by datruche
Thanks to aus9 we know how to run our custom commands upon boot-up.

Now let's say you want to, say, fsck a local disk upon every 20 mounts for safety. Normaly you'd check fstab and add or edit a line then save, job done.
Here fstab is auto-generated at boot-up:

Code: Select all

$ cat /PATH/TO/CHANGES/etc/fstab 
# Do not edit this file as fstab is recreated automatically during every boot.
# Please use /etc/rc.local or sysvinit scripts if you want to mount/unmount
# drive, filesystem or network share.
Latest and single post mentioning fstab (also by aus9) has no answer: http://forum.porteus.org/viewtopic.php? ... tab#p38720

Do you know how to customize fstab on Nemesis? How you do that?

EDIT:
Seems two files handle the fstab generation at boot-up:
/etc/udev/rules.d/10-porteus-fstab-update.rules -> /usr/local/sbin/udev-fstab-update which states
# Create new entry as per the 'mopt=' cheatcode or porteus defaults
Please let us know if you've heard something useful about that cheatcode (I didn't)!

Re: Customize your boot (rc.local replacement)

Posted: 07 Feb 2016, 03:06
by aus9
Do you know how to customize fstab on Nemesis? How you do that?
I have just tested a changes cheatcode and a modded fstab.....its overwritten.

Thanks for discovering where it is over written

Yes we have no way to use a changes cheatcode and a mod of /etc/fstab to achieve what you want.

It looks like you may have to consider 3 options.
option one use a "rc.local" type script as detailed in the tutorial

option 2 ...manually boot up a live cd or bootable linux usb stick
umount the relevant partition if its auto mounted and fsck it.

option 3 mod the "over writer" script its self....altho I have not tried it

looking at it now reveals
# we don't care about loop* and ram* devices
KERNEL=="[!lr]*", SUBSYSTEM=="block", RUN+="/usr/local/sbin/udev-fstab-update %r/%k"
I shall see if I can add a line to umount a non / partition and fsck it and report back by edit

edit 1
first I have an umount local script already. Next I manually fscked /dev/sda1 and then ran this command to get my last checked timestamp

Code: Select all

dumpe2fs -h /dev/sda1
snip
Last checked:             Sun Feb  7 11:10:07 2016
first attempt to use a modifed run udev rule failed on reboot....so I will now see if about just using the "rc.local" way

edit 2
Looks like tune2fs might be what we after?
http://linux.die.net/man/8/tune2fs

as I don't want to test for 20 mounts let me report back after trying this

Code: Select all

tune2fs /dev/sda1 -c 1
tune2fs 1.42.13 (17-May-2015)
Setting maximal mount count to 1
and I can check with the dump command

edit 3
I removed my umount command for the rc.local and have no forced fsck command in there either did a number of reboots and result not good

Code: Select all

Last mount time:          Sun Feb  7 11:32:16 2016
Last write time:          Sun Feb  7 11:32:16 2016
Mount count:              4
Maximum mount count:      1
Last checked:             Sun Feb  7 11:10:07 2016
Check interval:           0 (<none>)
As you can tell sda1 was mounted after 11:10 but is not showing a later check time.

I will stop edits of this post and have to think about it.

Re: Customize your boot (rc.local replacement)

Posted: 07 Feb 2016, 03:46
by aus9
silly me....I only just read this line from the dump command.....last mounted on /

That is because that is my Xubuntu dual boot distro.
I have just booted into it.....and got a beautiful message that filesystem check is occurring.

Therefore it looks like the tune2fs command can be used to change to 20 mounts

Re: Customize your boot (rc.local replacement)

Posted: 16 Feb 2016, 15:09
by datruche
A brief feedback as I tried tune2fs as well.
Do you know how to customize fstab on Nemesis? How you do that?
I have just tested a changes cheatcode and a modded fstab.....its overwritten.
Yes we have no way to use a changes cheatcode and a mod of /etc/fstab to achieve what you want.
That's it!
It looks like you may have to consider 3 options.
option one use a "rc.local" type script as detailed in the tutorial

option 2 ...manually boot up a live cd or bootable linux usb stick
umount the relevant partition if its auto mounted and fsck it.

option 3 mod the "over writer" script its self....altho I have not tried it
1. Using a 'rc.local' script, aus9 you mean one to override fstab upon boot-up?

2. Or reboot in COpy2ram and run fsck. That's how I did.

Code: Select all

tune2fs /dev/sdb1 -c 1
tune2fs 1.42.13 (17-May-2015)
Setting maximal mount count to 1[code]
But device wasn't checked up upon reboot.

Thank you aus9 for trying to get control over fstab in Nemesis. Not that it's a big priority --only for people using it on a single box and don't need conf files re-generation at each boot... plus to take care of their filesystem ^_^