From owner-freebsd-multimedia@FreeBSD.ORG Tue Feb 3 05:33:39 2004 Return-Path: Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0781816A4D9 for ; Tue, 3 Feb 2004 05:33:39 -0800 (PST) Received: from fw.farid-hajji.net (fw.farid-hajji.net [213.146.115.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id D5C4F43D45 for ; Tue, 3 Feb 2004 05:33:35 -0800 (PST) (envelope-from cpghost@cordula.ws) Received: from fw.farid-hajji.net (localhost [127.0.0.1]) by fw.farid-hajji.net (Postfix) with ESMTP id AB92040826; Tue, 3 Feb 2004 14:32:56 +0100 (CET) From: Cordula's Web To: freebsd-multimedia@FreeBSD.ORG, cpghost@cordula.ws In-reply-to: <200402021718.i12HI42L039591@lurza.secnetix.de> (message from Oliver Fromme on Mon, 2 Feb 2004 18:18:04 +0100 (CET)) X-Mailer: Emacs-21.3.1/FreeBSD-4.9-STABLE References: <200402021718.i12HI42L039591@lurza.secnetix.de> Message-Id: <20040203133256.AB92040826@fw.farid-hajji.net> Date: Tue, 3 Feb 2004 14:32:56 +0100 (CET) Subject: Re: Transferring the root filesystem to a ramdisk? X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: cpghost@cordula.ws List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Feb 2004 13:33:39 -0000 > > > you could mount the replacement root device on '/' > > > > > > alternatively you could make init do the chroot (you have source no? :-) > > > > chroot()ing init looks like a good idea, but: > > 1. Isn't /sbin/init itself mmap()ed to the physical device > > which I'd like to turn off later? > > 2. Other processes, forked earlier from init will also > > be mmap()ed to the physical device, so they'll have to die? > > > > 1. means that chroot() can only happen before /sbin/init is > > created, somewhere around /usr/src/sys/kern/init_main.c:mi_startup() > > > > 2. means that all these processes will die, when the device > > is turned off. > > No, they won't die, they'll just block for a brief moment > while the drive is coming back online. Note that "ataidle" > does not turn the device off, but it merely causes the disks > to spin down after a certain idle time. As soon as some > process tries to access the disk, they'll spin up again. Hmmm, let's see: * / is mounted on, say, /dev/da0s1a * some processes (including /sbin/init) have open files from / * /sbin/init chroot()s to something else. * new processes spawned by init inherit the chroot() settings. * /dev/da0 is powered down * ??? What happens now to /sbin/init? What happens to the filesystem that (was) mounted on /? > You should not physically remove the drive, though (if it's > in a removable drive bay), nor switch off power from the > drive. Yep, that's the catch. The drive should be powered off, and it should be potentially removable/replacable. It's remarkable that it is so difficult to change the root device on-the-fly. I didn't expect it to be so difficult :( > So the chroot solution is probably the easiest solution. > The init process is idle most of the time, so chances are > that it doesn't want to spin up your disk. Init only wakes > up when you send it a HUP signal (i.e. after modifying the > /etc/ttys file), or when one of the daemons from that file > dies (i.e. a getty process). And upon shutdown, of course. Any process that gets orphaned will be inherited by init. This means that the PPID of that process will change to 1. But will init not be notified of this, therefore reactivated? Yes, init is idle most of the time, but is it safe to assume that it will not access its own drive or backing store? > > * A new syscall foo(device_t) is needed. > > * foo() manipulates the vnode for "/", effectively mounting the > > memory device. > > I think that would be prohibitively complicated. Keep in > mind that all existing open files on that disk depend on > the vnode, so you would have to manipulate a _lot_ of > data. All memory mappings, locks etc. would have to be > renewed somehow. It's a huge can of worms. Yes, that's exactly the problem. It means a nearly full reboot, but not 100%, because that would kill e.g. the ramdisk. Hairy it is... > Regards > Oliver > > PS: Uhm, why is this in the -multimedia list anyway? :-) No idea. This started on questions@, but migrated somehow. Sorry if it is off topic here. What would the appropriate place be? Thanks, -cpghost. -- Cordula's Web. http://www.cordula.ws/