How can I edit my startup scripts in linux so that I get to the login screen as soon as possible? I want all the other accessories (such as Bluetooth, Wifi, Ethernet) drivers to run ONCE I have gotten to the login screen and can now log into shell.
The only thing I can think of is to change the rmnologin order so that it runs before anything else. Is that a good idea?
Use a dependency based init tool like systemd or startpar, then if you still don't have prompt fast enugh dependency reasearch (or trial and error) would be in order. Also set your bios to fast boot. You can also boot into single user mode then change run level later if you want.
Related
I am running Linux kernel 4.14.149 built by Yocto Zeus, and I am running 2019.07 U-boot. At the recommendation of our security team, I am trying to get rid of the Linux console. I am not worried about debugging (once I get this to work anyways); we have other ways of getting the system logs out of the machine, and this will not be done on software development boards. That mechanism is already in place and is tested working. We have an i.MX6 as our core (this is an embedded system), and we have dedicated UART5 to our console on dev boards.
I have tried a few different methods to do this. The first was to disable the framebuffer console kernel config (CONFIG_FRAMEBUFFER_CONSOLE). The primary issue with this approach is that it disabled the splash screen. We have a splash screen that is put up in U-boot (and it is displayed again by Linux), but Linux appears to reset the framebuffer or something when it is booting, resulting in the display flickering and being blank for a bit before our applications start, which was unacceptable (and is the reason we put the splash screen up in both U-boot and Linux).
I also tried just setting "console=" on our command line. This is close to what we want to achieve in that the console doesn't come out the UART anymore, but we see it start to appear on the display on top of the splash screen. I haven't found any way to fix that (I can upload a screenshot if desired).
Just eliminating the console parameter entirely didn't appear to work, it still came out the UART. This is to be expected based on the serial console documentation which says it just uses the first available device.
I have tried commenting out the console initialization in main.c in the Linux source, which exploded rather quickly.
I tried setting to be a netconsole (see Where do you send the kernel console on an embedded system?) but the splash screen still got overwritten, same as the setting it nothing case.
The last thing I have tried was just setting it to a bogus device ("console=ttymxc9" on the Linux command line). While this appears to work (there is no data on the display or the UART) it appears to stall (crash?) partway through bootup and without being able to get the logs (it stalls before our application service runs). I say stall because we have Linux configured for a heartbeat and we do still get proper LED heartbeat behavior. None of the systemd services I added to our build however appear to run (I added one to save the journalctl log file after boot to a file on an external SD card for debugging purposes until I get this working)
At this point, I have run out of ideas on how to get rid of the console while keeping the splash screen intact. What is the proper way to disable the Linux console?
For kernel versions 5.11 and newer:
In the submenu "Character devices" under "Device Drivers" from make menuconfig, there is an option called "Null TTY driver" (CONFIG_NULL_TTY) that you can enable and add console=ttynull to the kernel boot cmdline so that all console output will be simply discarded.
You can also disable CONFIG_VT and CONFIG_UNIX98_PTYS, since you don't need to interact with your program via console at all.
For older kernels (like my 4.14):
You can add this support with the diffs at: https://lore.kernel.org/lkml/20190403131213.GA4246#kroah.com/T/ and then follow the instructions above.
More recent versions of yocto use systemd and a service called getty.target to load the serial port console. Disable by running the following command (once):
systemctl mask getty.target
This answer may not fully fit your question, however, it could serve as a research source for other users, just like me. I use the commands below to temporarily turn the console (ttyS0) on and off.
systemctl stop serial-getty#ttyS0.service
and
systemctl start serial-getty#ttyS0.service
I created a simple module that controls wheter a USB supplies power for a device when in host mode or not. When loaded, this module cuts off the power to any device connected until told otherwise.
It is also desired that when booted, the system comes with both my module loaded, and the USB supply cut off. To this end, so far I've tried:
Setting my module as a kernel built-in: had no effect, modules that are loaded later overrun my configuration;
Creating an init.d script: Created the script, and set it up to run on rc5. No luck as well, I run into multiple problems with USB devices (such as usb 2-1: device descriptor read/64, error -110);
I'm running Kernel 3.12 on a custom board, and I've tested that the module works as intended if I load it manually (via modprobe) into the system, after logging in.
Ideally, I want to keep these configurations to be done during boot, without any need of logins and such.
So, my question is: how can I postpone the module loading until the last possible minute, assuring that any other configuration is already finished? Also, is udev a good solution for this sort of thing? From what I read, I had the impression it wouldn't be the best fit...
Regards,
Guilherme
So, I've figured out how to get rid of the errors when using an init.d script. All that is needed is to unbind the devices before loading the module. the following line before the modprobe did the trick for me:
echo "2-1" > /sys/bus/usb/drivers/usb/unbind
Regards,
Guilherme
I want to make a system which would get input from USB barcode scanner, validate it on remote server and display an answer (text and images).
I would use JavaFX or in-browser JS web application to grab scanner input somehow.
I'm planning to run this application on Raspberry Pi or plain PC.
Is there a way (or a special linux distribution) to ensure that system always loads the same way and starts JavaFX app or opens particular web page in browser?
e.g. no login page, NO update or other popups are shown.
Any other ideas? Thanks
...
Found an interesting solution here, where JavaFX GUI app is started from command line, without X-Server(linux graphical interface) at all.
I have recently done something similar, and it's not too hard. Obviously working on the Pi, you will want to use something like Linux and having limited hardware will mean that you should be minimising what you are running. Due to this, I would recomend that you run a light weight distro. Something like arch (which is what I used) allows you to build only what you want from the ground up without the need to find and compile everything like you do for LFS or Gentoo.
As for booting, the following two wikis will give you the details of starting the Gui without manual login:
https://wiki.archlinux.org/index.php/Automatic_login_to_virtual_console
https://wiki.archlinux.org/index.php/Start_X_at_Login
After that, it is simply a matter of putting the command to launch your program in .xinitrc.
I was wondering if i can run a exe with daemons in mac and linux or do you have any other solutions to do something similar to a windows service that is a scheduler ? I know i can use crontab but i was wondering if there was other way to do it.
Thx
On OS X, the preferred way of doing things like this is with launchd daemons. You create a .plist file with information about what program to run, parameters to pass it, and what conditions to start it under (i.e. at certain times, when a network connection is received on a certain port, or just run always), and various other options. Lingon provides a handy GUI for creating the .plist, or just read the Apple LAUNCHD docs and create it yourself. Put the .plist in /Library/LaunchDaemons, and either reboot or activate it with sudo launchctl load /Library/LaunchDaemons/whatever.plist.
A warning about using launchd: most daemon-type programs for unix will "daemonize" themselves -- they drop into the background, and generally detach themselves from the program that started them. Launchd doesn't like this. It wants to keep watch over its children, so that it can monitor their status, relaunch them if necessary, etc. So you may either need to tell the program not to daemonize, or add an option to the .plist to tell launchd not to freak out if the program appears to quit.
Linux alternative to windows NT services are daemons. You can read a little more about it
here.
You also start executables by scripts located in "/etc/init.d" Just look at one of those scripts for reference. If you want to make a task or executable start at a given time use a crontab. It is made for this purpose and I don't see why use something else.
If you have a mono executable probably the easiest way is just to make a script in "init.d" if you want to start when system starts or make a crontab entry. It is realy easy. Here you can find a simple reference.
I have written a daemon in linux for doing dhcp for an embedded system. This platform only has a linux kernel running on it and have no CLI support. What is the best way for me to test my daemon? How do I write a program that will call the main function in this daemon and verify if its working fine?
Appreciate the answers.
When I've been in a situation like this, I've written a second daemon (or had a second listener in the existing daemon) to take the place of a CLI, listening at a particular port and responding to a very limited command set of your own choosing.
In this case, all you really care about is triggering the function on demand, so you could even have it trigger when you connect to this second port, and then report results back to the socket.
I strongly recommend, by the way, making sure your embedded system has some more generic mechanism for logging information to persistent storage and retrieving that log. It doesn't have to be syslog or anything so complicated. But you will want that ability in the future to enable forensic analysis of problems in the field.
You will want to write and debug your daemon in a full featured environment first, then install it on the embedded system at the end when you are sure it works properly.
If you can build a dhcp server for the embedded system you can surely build a simple shell for it also. Try building BusyBox or ash or dash.
You could also try using GDB remote debugging. I found an article about it.