You are not logged in.

#1 2018-02-28 18:39:59

Dren
Member
From: Canada
Registered: 2010-12-14
Posts: 28

Need to shut down my laptop after a timeout in initramfs

I'm having a problem with my Surface Book where it's turning on at random in my bag. I have no idea what's causing this, but I'm trying to make it shut down after a timeout. To complicate matters, my disk is encrypted, so I need to do this in initramfs.

I copied the "timeout" program to initramfs and modified the "encrypt" hook to use it, and it works... except that the "poweroff" command doesn't work in initramfs. If I could just figure out an alternative command to shut down the system, this would work...

I suppose an alternative would be to set up a timeout in grub, if that's a feature.

Here's the code I put in the encrypt hook for timing out.

                echo "A password is required to access the ${cryptname} volume:"

                #try to get a password, timeout after 5 seconds
                timeout 5 cryptsetup open --type luks ${resolved} ${cryptname} ${cryptargs} ${CSQUIET}
                if [ $? -ne 0 ]; then
                    err "Timeout waiting for password."
                    poweroff
                    return 1
                fi

Offline

#2 2021-03-15 03:56:50

luthepa1
Member
Registered: 2021-03-15
Posts: 2

Re: Need to shut down my laptop after a timeout in initramfs

Hi Dren,

Did you ever figure this out?  I have similar issue where if I plug my xps13 into the usb-c dock it turns on the laptop automatically but because I have encryption it will sit at the password prompt screen indefinately.  I want a timeout to auto poweroff laptop.  How exactly did you implement your script with the encrypt hook?

Thanks,

Paul.

Offline

#3 2021-03-15 12:15:59

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: Need to shut down my laptop after a timeout in initramfs

Dren has not been back to the forum since 2018, so I am going to consider this thread abandoned and close it.

luthepa1, welcome to the forum. Please be aware of the dates on threads and our rules about necrobumping -- if you still need help please open a new thread with your issue.

Offline

Board footer

Powered by FluxBB