5

I have a time-consuming program running in Lubuntu 18.04 Live. It will take around one day to finish. After the program finishes the computer shuts down.

But since I am running Lubuntu Live, the computer asks me to

Please remove the installation medium then press enter

after initiating the shutdown. I will be traveling away before the program can finish and will not be back in a few weeks. I don't want the computer to be powered on all that time.

My question is: Is there a timeout after which the computer will eventually shut down, or is there any way to skip this prompt and completely shut down Lubuntu Live?

8
  • Sorry I missed 'Live' in the os description!
    – gena2x
    Jul 5 '19 at 17:46
  • You can always do poweroff -f, which will shutdown unconditionally and immediately. As this is livecd it should be fine, just be sure to unmount any file system you using.
    – gena2x
    Jul 5 '19 at 17:48
  • @gena2x Yes that works, thank you. I can use that.
    – TheAdam122
    Jul 5 '19 at 17:53
  • Strictly speaking, the computer isn't "up and running" at that point. The OS has been unloaded and it's safe to turn it off. Is using a plug with a timer an option? That way you can set it to just turn off the power after a day or so.
    – terdon
    Jul 5 '19 at 18:00
  • @terdon well using a timer would mean having to unplug the computer so that is not an option for me, as the program is already running and it is not easy to stop and resume (i am running automated data recovery)
    – TheAdam122
    Jul 5 '19 at 18:08
1

In situations, where a remotely accessed rescue system is already running and a reboot into the installed OS is required, the prompt can be disabled by editing the file /sbin/casper-stop.

E.g., at the end of /sbin/casper-stop:

    eject -p -m $device >/dev/null 2>&1

    [ "$prompt" ] || return 0

add an unconditional return 0:

    eject -p -m $device >/dev/null 2>&1

    [ "$prompt" ] || return 0

    return 0
1

/sbin/casper-stop already has (or has since had added) code to handle this situation if the file /run/casper-no-prompt exists.

You can create a simple systemd unit file to always create this:

mint@mint:~$ cat /etc/systemd/system/casper-no-prompt.service 
# see /sbin/casper-stop
[Unit]
Description=Casper no-prompt

[Service]
Type=oneshot
ExecStart=touch /run/casper-no-prompt

[Install]
WantedBy=multi-user.target
mint@mint:~$ sudo systemctl daemon-reload
mint@mint:~$ sudo systemctl enable casper-no-prompt
mint@mint:~$ sudo systemctl start casper-no-prompt
mint@mint:~$ sudo systemctl status casper-no-prompt
● casper-no-prompt.service - Casper no-prompt
     Loaded: loaded (/etc/systemd/system/casper-no-prompt.service; enabled; vendor preset>
     Active: inactive (dead) since Sat 2020-11-28 09:19:33 GMT; 1s ago
    Process: 4931 ExecStart=/usr/bin/touch /run/casper-no-prompt (code=exited, status=0/S>
   Main PID: 4931 (code=exited, status=0/SUCCESS)

Nov 28 09:19:33 mint systemd[1]: Starting Casper no-prompt...
Nov 28 09:19:33 mint systemd[1]: casper-no-prompt.service: Succeeded.
Nov 28 09:19:33 mint systemd[1]: Finished Casper no-prompt.
mint@mint:~$ ls -l /run/casper-no-prompt 
-rw-r--r-- 1 root root 0 Nov 28 09:19 /run/casper-no-prompt
mint@mint:~$ 
6
  • What can u do in Finnix ? This only works in Ubuntu
    – ToiletGuy
    Apr 16 at 8:51
  • 1
    On Finnix the behaviour can be changed by setting LIVE_MEDIUM_EJECT_VERBOSE=false prior to shutdown. This can be set in /etc/tools/live.conf (see the /bin/live-medium-eject script for details of the implentation), although since Finnix is designed to be used in "live" read-only mode, I'm not sure how you would do this persistently. Apr 17 at 15:05
  • I have found the solution yesterday unix.stackexchange.com/questions/645377/… and about how i did the read only mode, is I modified that live CD using squashfs tool and repack back.
    – ToiletGuy
    Apr 17 at 15:57
  • Is there a documentation about that somewhere? You just gave me valuable info here.
    – ToiletGuy
    Apr 17 at 16:01
  • I don't know, I just read the code. :-) Apr 19 at 5:43
0

Try adding noprompt to the kernel command line (e.g., type e at the grub menu or the suggested Fn key).

See the manpage for other live boot options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.