Re: shutdown busybox and start another PID1 process

2014-08-13 Thread Sam Liddicott
This works in busybox ash getch() { read -t 1 -n 1 $1 } getch key echo $key you probably also want stty -echo before you start Sam On Tue, Aug 12, 2014 at 5:44 AM, James Bowlin bit...@gmail.com wrote: On Mon, Aug 11, 2014 at 07:35 PM, Harald Becker said: Did I get it right? This is

Re: shutdown busybox and start another PID1 process

2014-08-12 Thread Harald Becker
Hi James ! This is very close to what I'm doing now. The two changes are: 1) I boot into Debian so I switch_root into their /sbin/init and I use telinit u to get back pid 1. If that work, fine. Not much difference, just use the init you like, the only question is how to shut

Re: shutdown busybox and start another PID1 process

2014-08-11 Thread Laurent Bercot
On 2014-08-11 03:27, James Bowlin wrote: If someone had done a frugal install (copy the squashfs file to internal hd) or if they enable static root persistence (which opens a persistence file on the internal hd ) then it is impossible to cleanly umount the hd without doing a pivot_root first.

Re: shutdown busybox and start another PID1 process

2014-08-11 Thread James Bowlin
On Mon, Aug 11, 2014 at 08:06 AM, Laurent Bercot said: Isn't it possible to simply remount it read-only ? That's the traditional way of fscking a rootfs, and it has always worked for me - but maybe it's unapplicable to your situation, especially with a HD install that users can modify. I

Re: shutdown busybox and start another PID1 process

2014-08-11 Thread Harald Becker
Hi Laurent! Before I can umount the ntfs (or other rw fs) I need to first umount the squashfs file and the static persistence file (if it is being used). To do that I need to first umount the aufs which is the root file system. Without the pivot_root, this is not possible. Isn't it

Re: shutdown busybox and start another PID1 process

2014-08-11 Thread James B
Hi James (from another James). On Mon, 11 Aug 2014 03:17:52 -0600 James Bowlin bit...@gmail.com wrote: There was a need to have static root persistence where the changes are saved directly in the root persistence file so I needed to bite the bullet and finally get clean umounts during

Re: shutdown busybox and start another PID1 process

2014-08-11 Thread Harald Becker
Hi James, I looked a bit in what you are doing (if I understand it right) and suggest the following (doing something similar on some of my systems): Startup your system from initramfs and setup required root file system do switch_root starting /bin/busybox init on your root file system

Re: shutdown busybox and start another PID1 process

2014-08-11 Thread Sam Liddicott
I wonder if cgroups or namespaces have any role here. The initrd mounts NTFS and then creates a new namespace for new init which can't see or kill fuse. Sam On 11 Aug 2014 17:34, James B jamesbond3...@gmail.com wrote: Hi James (from another James). On Mon, 11 Aug 2014 03:17:52 -0600 James

Re: shutdown busybox and start another PID1 process

2014-08-11 Thread James Bowlin
On Mon, Aug 11, 2014 at 07:35 PM, Harald Becker said: Did I get it right? This is very close to what I'm doing now. The two changes are: 1) I boot into Debian so I switch_root into their /sbin/init and I use telinit u to get back pid 1. 2) I copy busybox et al. into the new root

Re: shutdown busybox and start another PID1 process

2014-08-11 Thread James Bowlin
Thanks James for all the great info! This candy store just gets sweeter and sweeter. Were you, by any chance, in physics grad school in the 1970s? I'm sorry for the delay in responding. This was the first post I started to respond to this morning but the way my interrupts work, it is the last

Re: shutdown busybox and start another PID1 process

2014-08-10 Thread James Bowlin
Thanks for the insightful suggestions Sam. I will definitely try some of them. I already have breakpoints in my shutdown script and several options to pause until a key is pressed. Currently all that my new /sbin/init script does is touch a file and then endlessly sleep. I may need to change

Re: shutdown busybox and start another PID1 process

2014-08-10 Thread Laurent Bercot
On 2014-08-10 08:07, James Bowlin wrote: BTW: I use the start-time of processes to find all the processes that need to be killed. Using pid is unreliable because it can wrap on 32-bit systems. The *only* way to be 100% sure they are no remaining processes at some point in a system's lifetime

Re: shutdown busybox and start another PID1 process

2014-08-10 Thread James Bowlin
On Sun, Aug 10, 2014 at 09:38 AM, Laurent Bercot said: The *only* way to be 100% sure they are no remaining processes at some point in a system's lifetime is to kill them all - like aliens, or zombies. Trying to be smarter or more gentle than that is a losing battle: any process can sneakily

Re: shutdown busybox and start another PID1 process

2014-08-10 Thread Laurent Bercot
On 2014-08-10 11:29, James Bowlin wrote: I've been able to deal with processes that spawn children on shutdown but it might be possible for someone to intentionally build a fork bomb that I would have trouble with. I believe that if someone with root is malicious enough then they can defeat any

Re: shutdown busybox and start another PID1 process

2014-08-10 Thread James Bowlin
Thanks Laurent, I'm learning a lot. It is refreshing to have someone to talk with about this stuff but I'm going to have to wrap this up soon. It feels like I'm spawning children on this list faster than I can kill them off. I will certainly read any replies (at least) and I might come back to

Re: shutdown busybox and start another PID1 process

2014-08-10 Thread Laurent Bercot
I don't quite understand what you are suggesting. Ah, I'm sorry, I hadn't realized you were not the OP, and I have replied as if you were trying to bring up a system - but you are just trying to shut it down. Well a shutdown isn't really something I've mastered. I've always considered it was

Re: shutdown busybox and start another PID1 process

2014-08-10 Thread Sam Liddicott
Don't forgot umount -fl which pretends to unmount now but actually does it as soon as all files are closed. Not sure right now if busybox supports it. Sam On 10 Aug 2014 22:51, Laurent Bercot ska-dietl...@skarnet.org wrote: I don't quite understand what you are suggesting. Ah, I'm sorry, I

Re: shutdown busybox and start another PID1 process

2014-08-10 Thread James Bowlin
On Sun, Aug 10, 2014 at 11:52 PM, Laurent Bercot said: I don't understand why you would pivot_root to shutdown. Who cares what your rootfs is, since the system isn't going to live anyway ? I'm sorry, I should have explained. I work on the Live system for MX-14 Linux and antiX Linux. The

Re: shutdown busybox and start another PID1 process

2014-08-09 Thread tito
On Saturday 09 August 2014 13:02:28 Rieker Flaik wrote: Greetings, I want to use busybox as a pre-OS before my actual system starts up, so that I can do backups and stuff. Currently, I'm able to start busybox from an initramfs. I hacked a small shellscript which serves as /init that

Re: shutdown busybox and start another PID1 process

2014-08-09 Thread Michael Conrad
On 08/09/2014 07:02 AM, Rieker Flaik wrote: But here I can't do that because /sbin/init has taken over PID 1 and spawned processes. So I first have to shut this pre-OS down before booting into the next. Is there a way to kill all processes and start a shellscript as PID 1 again? Maybe by

Re: shutdown busybox and start another PID1 process

2014-08-09 Thread James Bowlin
On Sat, Aug 09, 2014 at 01:02 PM, Rieker Flaik said: There I can exec busybox its normal init /sbin/init. This is what I want to use in this pre-OS, having a nice init system to spawn all kinds of programs like udhcp and dropbear to do the backup stuff. It is actually very easy to get control

Re: shutdown busybox and start another PID1 process

2014-08-09 Thread Sam Liddicott
You can replace /sbin/init with a bind mount; e.g. mount /tmpfs/sbin/init.shutdown /sbin/init -o bind that will replace init, but only till the next reboot. When debugging the first couple of lines should be something like: exec /dev/ttyS0 21 # if serial console exec /dev/tty1 21 # if normal