linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* initrd help -- umounts root after pivot_root
@ 2003-10-31  0:18 John R Moser
  2003-10-31 18:47 ` Chris Lingard
  0 siblings, 1 reply; 6+ messages in thread
From: John R Moser @ 2003-10-31  0:18 UTC (permalink / raw)
  To: Linux Kernel Mailing List

Been trying with 2.4.20, 2.4.22, 2.6.0-test9, how the heck do I get this 
to work?

I set everthing up on /dev/shm type tmpfs, then 
cd /dev/shm
mkdir initrd
pivot_root . initrd


So yay, it's set up so that the cd is pointed to by a lotta links in 
tmpfs, and the stuff that needs to be rw (like /etc) is on the tmpfs.

That's good.

Of course, the kernel unmounts / and then swears that it can't find init 
when the linuxrc exits.

The documentation says that linuxrc should pivot_root to the real root in 
Documentation/initrd.txt so I thought that's what the script sholud do.  
Apparently the doc is bad/old.

Any ideas?

script follows.


====/linuxrc
#!/bin/sh
                                                                                                                                
# linuxrc for Genoppix initrd
# Basicly mounts the cdrom, sets up rw stuff, spins the root image
# around to the root, and exits.
echo "Genoppix Initrd Loaded, linuxrc executing in 5 seconds..."
sleep 5
mount none -t proc /proc
echo "Mounting cdrom..."
CDROM="/dev/cdrom"
if [ ! -e $CDROM ]; then
  CDROM="/dev/cdroms/cdrom0"
fi
mount $CDROM /mnt/root || (echo "FATAL: Cannot mount cdrom!" && sh)
echo "mounting tmpfs..."
mount none -t tmpfs /dev/shm || (echo "FATAL: Cannot mount tmpfs!" && sh)
echo "Building symlinks to cd root..."
cd /dev/shm
ln -s /mnt/root/* .
sleep 2.5
echo "Setting mnt and home to rw root..."
rm -f root home mnt
mkdir root home mnt
#echo "linking cdroot's new location to what will be cdroot's old 
location..."
#ln -s /mnt/initrd/mnt/root /dev/shm/mnt/root
echo "mounting cdrom at new root..."
mount $CDROM /dev/shm/mnt/root
echo "Pivoting root to shared memory filesystem..."
cd /dev/shm
mkdir initrd
pivot_root . initrd || (echo "Cannot pivot root!" && sh)
mount -t proc none /proc
echo "copying /etc to a rw /etc..."
rm -f etc
mount -t devfs none /dev
cp -R /mnt/root/etc .
echo "Root pivoted, making users..."
sleep 1
echo "creating homes for default users..."
cd /home
mkdir jak
mkdir tails
mkdir fox
mkdir krystal
chgrp users *
chown jak jak
chown tails tails
chown fox fox
chown tails tails
chown krystal krystal
echo "exiting linuxrc and starting init ;)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: initrd help -- umounts root after pivot_root
  2003-10-31  0:18 initrd help -- umounts root after pivot_root John R Moser
@ 2003-10-31 18:47 ` Chris Lingard
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Lingard @ 2003-10-31 18:47 UTC (permalink / raw)
  To: Linux Kernel Mailing List

On Friday 31 October 2003 12:18 am, John R Moser wrote:
> Been trying with 2.4.20, 2.4.22, 2.6.0-test9, how the heck do I get this
> to work?
> I set everthing up on /dev/shm type tmpfs, then
> cd /dev/shm
> mkdir initrd
> pivot_root . initrd

Might be better to do something like:

mount -t devfs  none  /dev
mount -t proc none /proc
mkdir  -p  ram
mount -t tmpfs tmpfs /ram
cd /ram
mkdir proc  cdrom
mount  -t proc  none /ram/proc
/mount_cdrom

This is the start of my linuxrc script and creates the future root at /ram

> Of course, the kernel unmounts / and then swears that it can't find init
> when the linuxrc exits.
>
> The documentation says that linuxrc should pivot_root to the real root in
> Documentation/initrd.txt so I thought that's what the script sholud do.
> Apparently the doc is bad/old.

man pivot_root

mkdir initrd
sbin/pivot_root  .  initrd
mount devfs -t devfs /dev
exec /usr/sbin/chroot . /sbin/init  <dev/console >dev/console 2>&1

(These is no automatic call to /sbin/init)

The documentation is bad insofar as root=/dev/rd/0 now fails

Also you will need to search for a patch to umount your old /initrd.  Please
feel free you email me direct for a very unofficial patch to linux-2.4.22

Chris Lingard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: initrd help -- umounts root after pivot_root
  2003-10-31 21:59 ` H. Peter Anvin
@ 2003-11-03 13:47   ` Bob Chiodini
  0 siblings, 0 replies; 6+ messages in thread
From: Bob Chiodini @ 2003-11-03 13:47 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel

On Fri, 2003-10-31 at 16:59, H. Peter Anvin wrote:
> 	From: H. Peter Anvin <hpa@zytor.com>
> MIME-Version: 1.0
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 8bit
> X-Comment-To: Bob Chiodini <robert.chiodini-1@ksc.nasa.gov>
> Disclaimer: Not speaking for Transmeta in any way, shape, or form.
> Copyright: Copyright 2003 H. Peter Anvin - All Rights Reserved
> 
> Followup to:  <1067604362.5526.15.camel@tweedy.ksc.nasa.gov>
> By author:    Bob Chiodini <robert.chiodini-1@ksc.nasa.gov>
> In newsgroup: linux.dev.kernel
> > 
> > John,
> > 
> > It does not appear that the kernel(s) will support the root fs on
> > tmpfs.  Looking through the init kernel code:  It boils down to a block
> > device with real major and minor number or NFS.
> > 
> 
> Baloney.  See the SuperRescue CD, for example, for a distro which uses
> exactly this.
> 
> 	-hpa

I stand corrected.  I should have been clearer making this statement.  I
did not see a mechanism for mounting a tmpfs in do_mounts.c, or main.c. 
One question:  I see that superrescue execs init and the end of
linuxrc.  Does this cause the kernel initialization to yield in
handle_initrd(), until init exits (reboot/shutdown)?

Bob... 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: initrd help -- umounts root after pivot_root
  2003-10-31 12:46 Bob Chiodini
  2003-10-31 18:13 ` Maciej Zenczykowski
@ 2003-10-31 21:59 ` H. Peter Anvin
  2003-11-03 13:47   ` Bob Chiodini
  1 sibling, 1 reply; 6+ messages in thread
From: H. Peter Anvin @ 2003-10-31 21:59 UTC (permalink / raw)
  To: linux-kernel

	From: H. Peter Anvin <hpa@zytor.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Comment-To: Bob Chiodini <robert.chiodini-1@ksc.nasa.gov>
Disclaimer: Not speaking for Transmeta in any way, shape, or form.
Copyright: Copyright 2003 H. Peter Anvin - All Rights Reserved

Followup to:  <1067604362.5526.15.camel@tweedy.ksc.nasa.gov>
By author:    Bob Chiodini <robert.chiodini-1@ksc.nasa.gov>
In newsgroup: linux.dev.kernel
> 
> John,
> 
> It does not appear that the kernel(s) will support the root fs on
> tmpfs.  Looking through the init kernel code:  It boils down to a block
> device with real major and minor number or NFS.
> 

Baloney.  See the SuperRescue CD, for example, for a distro which uses
exactly this.

	-hpa
-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
If you send me mail in HTML format I will assume it's spam.
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: initrd help -- umounts root after pivot_root
  2003-10-31 12:46 Bob Chiodini
@ 2003-10-31 18:13 ` Maciej Zenczykowski
  2003-10-31 21:59 ` H. Peter Anvin
  1 sibling, 0 replies; 6+ messages in thread
From: Maciej Zenczykowski @ 2003-10-31 18:13 UTC (permalink / raw)
  To: Bob Chiodini; +Cc: linux-kernel

Have you remember to perform
echo 0x0100 > /proc/sys/kernel/real-root-dev
in the /linuxrc init script?

Cheers,
MaZe.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: initrd help -- umounts root after pivot_root
@ 2003-10-31 12:46 Bob Chiodini
  2003-10-31 18:13 ` Maciej Zenczykowski
  2003-10-31 21:59 ` H. Peter Anvin
  0 siblings, 2 replies; 6+ messages in thread
From: Bob Chiodini @ 2003-10-31 12:46 UTC (permalink / raw)
  To: linux-kernel

On Thu, 2003-10-30 at 19:18, John R Moser wrote: 
> Been trying with 2.4.20, 2.4.22, 2.6.0-test9, how the heck do I get this 
> to work?
> 
> I set everthing up on /dev/shm type tmpfs, then 
> cd /dev/shm
> mkdir initrd
> pivot_root . initrd
John,

It does not appear that the kernel(s) will support the root fs on
tmpfs.  Looking through the init kernel code:  It boils down to a block
device with real major and minor number or NFS.

Could you set up a ramdisk to do the same thing as /dev/shm?  Also,
you'll have to tell the kernel where root is, either a boot parameter
(root=xxx) or with the rdev command.

Bob...


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-11-03 13:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-31  0:18 initrd help -- umounts root after pivot_root John R Moser
2003-10-31 18:47 ` Chris Lingard
2003-10-31 12:46 Bob Chiodini
2003-10-31 18:13 ` Maciej Zenczykowski
2003-10-31 21:59 ` H. Peter Anvin
2003-11-03 13:47   ` Bob Chiodini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).