Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 08-29-2016, 10:17 AM   #1
Feathers_McGraw
Member
Feathers_McGraw began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Aug 2016
Device: Kindle 3
Kindle 3 sysvinit scripts

I have installed optware on my kindle 3, which works fine when I manually mount the filesystem, but I'd like to automount it at startup.

The wiki page (https://wiki.mobileread.com/wiki/Optware) has an init script (/etc/init.d/optmount), which I've copied here for reference:

Code:
#!/bin/sh
 
 _FUNCTIONS=/etc/rc.d/functions
 [ -f ${_FUNCTIONS} ] && . ${_FUNCTIONS}
 
 mount_us()
 {
         /bin/mount /mnt/us/optware.ext3
 }
 
 umount_us()
 {
         /bin/umount -d /mnt/us/optware.ext3
 }
 
 case "$1" in
         start)
                 mount_us
                 ;;
         stop)
                 umount_us
                 ;;
 
         restart|force-reload)
                 :
                 ;;
         *)
         msg "usage: /etc/init.d/$NAME {start|stop}" W >&2
                 exit 1
                 ;;
 
 esac
 
 exit 0
The script works fine when I run it manually, but I'd like to run it at startup. The wiki says:

Quote:
Once done, create the appropriate sysvinit symlinks under /etc/RcS.d (Startup), /etc/Rc6.d (Restart) and /etc/Rc0.d (Shutdown)
I've created these symlinks:

Code:
ln -s /etc/init.d/optmount  /etc/rc.d/optmount
ln -s /etc/init.d/optmount  /etc/rc6.d/optmount
ln -s /etc/init.d/optmount  /etc/rcS.d/optmount
But the filesystem doesn't get auto-mounted when I reboot. My first thought was to change options in /etc/fstab to ...,auto,nofail, but I don't think that will work because the "filesystem" is a file on /mnt/us, so it has to be mounted after the internal storage...

Do I have to name the symlinks in /etc/rc*.d/ differently so that the names match the option I want to use (start, stop, restart) like how the symlinks reboot, shutdown, poweroff all point to systemctl in distros with systemd as init system, and the name the program was called as is used as the argument? Or do all of the scripts in those folders get called with additional options anyway?

Can anyone give me a pointer in the right direction? Any more information about the init process on Kindle would be great too, I'd love to learn it in detail. I've been running linux on the server for >3 years but never looked into sysvinit, despite the switch to systemd you still find it everywhere in embedded devices.
Feathers_McGraw is offline   Reply With Quote
Old 08-29-2016, 05:12 PM   #2
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 83,968
Karma: 78697158
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
Questions such as this belong in the dev forum, to where I'm now moving it.
HarryT is offline   Reply With Quote
Advert
Old 08-29-2016, 05:31 PM   #3
knc1
On Holiday
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 16,325
Karma: 17324622
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Do not mount or symlink to anything or from anything in Visible USB mass storage (internally known as: /mnt/us).
It is a fuse file system on top of a FAT-32 file system and you can never be certain of its status, in fact, it might not even be present when you most want it.

Use the /var/local partition, it is always there beginning early in the boot sequence.
knc1 is offline   Reply With Quote
Old 08-29-2016, 05:45 PM   #4
Feathers_McGraw
Member
Feathers_McGraw began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Aug 2016
Device: Kindle 3
The /var/local partition is only 23.2M on my device, 20.6M of which is free, not sure that's enough for what I had in mind - the filesystem I created for optware was 250M and I thought that was on the small side!

Isn't mounting a filesystem contained in /mnt/us quite common? All of the optware and debian chroot posts and guides I've seen so far do that.
Feathers_McGraw is offline   Reply With Quote
Old 08-29-2016, 05:58 PM   #5
knc1
On Holiday
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 16,325
Karma: 17324622
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by Feathers_McGraw View Post
The /var/local partition is only 23.2M on my device, 20.6M of which is free, not sure that's enough for what I had in mind - the filesystem I created for optware was 250M and I thought that was on the small side!

Isn't mounting a filesystem contained in /mnt/us quite common? All of the optware and debian chroot posts and guides I've seen so far do that.
"quite common" != correct or reliable nor recommended.

What happens when you try to run your little script while that file system is exported as USBMS?
Try it, you can always use Kubrick to un-brick it.
knc1 is offline   Reply With Quote
Advert
Old 08-29-2016, 06:06 PM   #6
Feathers_McGraw
Member
Feathers_McGraw began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Aug 2016
Device: Kindle 3
Yeah I take your point. Do you run a debian chroot or optware on any of your devices then? What do you do? I'm equally wary of filling up essential root partitions and bricking the device that way.

I hadn't considered what happens in that situation... would that really brick the device?
Feathers_McGraw is offline   Reply With Quote
Old 08-29-2016, 06:34 PM   #7
knc1
On Holiday
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 16,325
Karma: 17324622
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by Feathers_McGraw View Post
Yeah I take your point. Do you run a debian chroot or optware on any of your devices then? What do you do? I'm equally wary of filling up essential root partitions and bricking the device that way.

I hadn't considered what happens in that situation... would that really brick the device?
It might disrupt the boot sequence enough so that it doesn't complete.

Question:
Why are you trying to run either a Debian chroot or Optware?

You must be reading some really, really old post on the Internet.
You know, the old "I read it on the Internet, it must be (still) true."
knc1 is offline   Reply With Quote
Old 08-29-2016, 06:50 PM   #8
Feathers_McGraw
Member
Feathers_McGraw began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Aug 2016
Device: Kindle 3
I'd like to have the ability to install standard commandline utilities on the kindle so I can use it for debugging servers, I quite like the eink screen for terminal work, and the battery life is killer.
Feathers_McGraw is offline   Reply With Quote
Old 08-29-2016, 07:07 PM   #9
knc1
On Holiday
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 16,325
Karma: 17324622
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by Feathers_McGraw View Post
I'd like to have the ability to install standard commandline utilities on the kindle so I can use it for debugging servers, I quite like the eink screen for terminal work, and the battery life is killer.
The battery run-time on a single charge (assuming battery is in 'new' condition) is about 2 to 4 hours, depending.

You don't need either a chroot nor Optware to run what you want to run.

No insult intended, but . . . .

*) Linux, like nearly any other *nix system, uses ELF format binaries.
*) All ELF format systems support multiple, concurrent, system libraries.

A point overlooked, or unknown to the authors of all those old Debian chroot and Optware posts.

Translation:
You can just install binaries from your preferred Debian/ARMel release in the visible USB user mass storage area and run them from there.

twobob even wrote scripts that determine what dependencies are not already installed on the Kindle.

AND...
There is a 'standardized' file storage tree for USB mass storage.

You most likely will have to edit the interpreter entry and the rpath entry of the binaries.

But there is a tool for that (patchelf) - you can use Buildroot to build the most recent verison of patchelf for yourself.
In fact, you probably build all of the common things you want with the same run of a Buildroot instance.

You do have to deal with programs that expect a writable /etc and a persistent ~ for root.
But there is a good selection of ways to deal with those details.

I don't have a worked example for the K3 but the worked example for the 5.x series firmware is similar in principle.
See the thread:
ARMhf on Kindle
(or something like that, filter by my nickname and use ARMhf as a title keyword in your search here).
knc1 is offline   Reply With Quote
Old 08-29-2016, 07:36 PM   #10
Feathers_McGraw
Member
Feathers_McGraw began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Aug 2016
Device: Kindle 3
I know that's possible, but it's a lot less convenient IMO - as I see it, the choice is:

find all of the binaries I think I'll need in advance (probably won't think of them all), patch them all, update them manually etc.

vs

set up a functional package manger in a chroot, and then install whatever I need, when I need it, from a massive repo where everything "just works", with easy access to updates and dependencies...
Feathers_McGraw is offline   Reply With Quote
Old 08-29-2016, 07:53 PM   #11
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,247
Karma: 83049305
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Notwithstanding what knc1 said, you you might just really really want a chroot for some reason, so it is still interesting to know how to automount it.
(Package managers are one good reason.)

The most important thing to keep in mind, is that the Kindle uses Ubuntu's Upstart init system, so in the best case scenario your initscript did absolutely nothing regardless.
(/etc/init.d/ is not used by anything and I am unsure why it exists, /etc/rc*.d/ is basically empty and I am not really sure what they do either, /etc/init/ is a symlink to /etc/upstart/)

The following upstart service is what I use to start something (in this case, Aeris' KindleMenu launcher) after the Kindle has booted and the UI is properly initialized and everything:

Code:
[root@kindle root]# cat /etc/upstart/aeris_menu.conf
# vim: set ft=upstart:

start on framework_ready and started kb and started pillow
stop on stopping framework

export LANG LC_ALL

pre-start script
    /etc/upstart/aeris_menu &
end script

Last edited by eschwartz; 08-29-2016 at 07:59 PM.
eschwartz is offline   Reply With Quote
Reply

Tags
boot process, kindle 3, mount filesystem, sysvinit

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
is it possible to run k5 launchpad scripts on k5 techiemonkey Kindle Developer's Corner 3 07-30-2012 10:10 AM
Kindle tries to run C/++ applications like sh scripts? dnR Kindle Developer's Corner 1 01-09-2011 08:45 AM
Replacement Kindle 1 Serial number does not work with scripts daffy4u Amazon Kindle 4 02-10-2010 08:53 PM
Any Page Turner Scripts Out There? Barney Kindle Formats 0 09-26-2009 06:36 PM
Network Control Scripts synerr iRex 3 01-13-2008 07:54 AM


All times are GMT -4. The time now is 01:01 AM.


MobileRead.com is a privately owned, operated and funded community.