linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* RE: Can I run linux without a file system?
@ 2002-06-21 21:13 Cameron, Steve
  2002-06-21 21:23 ` Wolfgang Denk
  2002-06-21 22:35 ` Conn Clark
  0 siblings, 2 replies; 26+ messages in thread
From: Cameron, Steve @ 2002-06-21 21:13 UTC (permalink / raw)
  To: Dr. Craig Hollabaugh, Jerry Van Baren, linuxppc-embedded


Dr. Craig Hollabaugh wrote:
>
> I can say that a minimum RedHat install uses 29,296 files -
> 382.020MB, debian 10,734 files - 67.428MB, my minimal root
> filesystem 82 files and 4.8MB.
>

Hmm, my minimal rootfs is (so far) 7 Mb, (as reported by du -s).
Or, is this 4Mb you cite compressed?  I wonder because my
libc.so is over 5 Mb. (which I got from DENX eldk-1.0)

Instead of ldd, I used "objdump -x $library | grep NEEDED"
which has the advantage that you can (er, that I know how to :-)
run it in a cross environment, so I don't have to fire up the
powerpc just to run ldd on a bunch of binaries.  (maybe
there's a way to cross run ldd? ) Using that, I wrote a script
(just today, as a matter of fact) to scan all the executables
and their libraries (and links to libs) iteratively until it
produced a minimal set, then deletes whatever isn't on the list,
which got me down to 7Mb with busybox and tinylogin as my only
apps.  (It occurs to me now that apps using dlopen() could be
a problem, but those are relatively rare.)

Any hints or links to into on crunching down the
individual libraries would be helpful.

BTW, nice book.

-- steve


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 26+ messages in thread
* RE: Can I run linux without a file system?
@ 2002-06-21 21:46 Cameron, Steve
  0 siblings, 0 replies; 26+ messages in thread
From: Cameron, Steve @ 2002-06-21 21:46 UTC (permalink / raw)
  To: Wolfgang Denk; +Cc: linuxppc-embedded


Wolfgang Denk wrote:
> In message
> <45B36A38D959B44CB032DA427A6E10640167CFE3@cceexc18.americas.cpqcorp.net> you wrote:
> >
> > Hmm, my minimal rootfs is (so far) 7 Mb,
[...]
> Have a look at the SELF Makefile... you should run
>
> $(CROSS_PREFIX)strip --remove-section=.note --remove-section=.comment *.so

Whoa! That is better.  ~2.8 Mb now, as reported by du. Thanks!

-- steve


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 26+ messages in thread
* RE: Can I run linux without a file system?
@ 2002-06-21 21:27 Kerl, John
  0 siblings, 0 replies; 26+ messages in thread
From: Kerl, John @ 2002-06-21 21:27 UTC (permalink / raw)
  To: 'Roland Dreier', Kerl, John
  Cc: 'Jerry Van Baren',
	'linuxppc-embedded@lists.linuxppc.org',
	'laitingwai@yahoo.com'


cp -a --- well, you learn something every day.
Guess I can go home now. :)

Thx.


-----Original Message-----
From: Roland Dreier [mailto:roland@topspin.com]
Sent: Friday, June 21, 2002 2:26 PM
To: Kerl, John
Cc: 'Jerry Van Baren'; 'linuxppc-embedded@lists.linuxppc.org';
'laitingwai@yahoo.com'
Subject: Re: Can I run linux without a file system?
Importance: High


>>>>> "John" == John Kerl <Kerl> writes:

    John> * I could bulk-copy (cp -R) from $xroot to the filesystem
    John> image, *but* you can't cp around the files in /dev.  The
    John> script below is hackish in that I list out all the
    John> subdirectories in $xroot except /dev and copy them, then
    John> populate /dev using the mkdevs script (included after
    John> mkramdisk).  (It would be more elegant to use find with grep
    John> -v /dev.)

cp -a works like cp -R except it will copy /dev and symlinks properly.

Best,
  Roland

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 26+ messages in thread
* RE: Can I run linux without a file system?
@ 2002-06-21 21:17 Kerl, John
  2002-06-21 21:26 ` Roland Dreier
  2002-06-21 21:28 ` Wolfgang Denk
  0 siblings, 2 replies; 26+ messages in thread
From: Kerl, John @ 2002-06-21 21:17 UTC (permalink / raw)
  To: 'Jerry Van Baren',
	'linuxppc-embedded@lists.linuxppc.org',
	'laitingwai@yahoo.com'


My filesystem is 5.7 MB uncompressed.  And, for me
(sorry Wolfgang!) I think that *is* minimal.  Well,
not "minimal" in the sense of "as small as humanly
possible", but at least "miniature" -- compared to
more than 1000 MB for my desktop Linux host.  Our board
isn't big: it has 16 MB of flash & 64 MB of RAM,
can serve up telnet sessions & web pages, etc., and
I'm nowhere close to filling up either the flash
or the RAM.  & if I did want to cut space, I'd use
a small libc (now, I use glibc which is over a meg).

<><><><><><><><><><><><><><><><><><><><><><><><><><>

Anyway, here are some notes about the mkramdisk script,
and then the script follows.

My host has a directory called /usr/local/xdev/export
(pointed to by $xroot).  When my PPC board uses NFS root
(i.e.  nfsroot=1.2.3.4:/usr/local/xdev/export on the kernel
command line), it mounts /usr/local/xdev/export.  When the
board is not uisng NFS root, I take that same directory and
essentially pack it into a RAM-disk image.  The script
below just does that packing.

This simple picture is complicated by a few details:

*	One doesn't just make a zip or .tgz file; rather,
	one must must make a filesystem structure per se,
	that Linux on the PPC board can mount.

*	I could bulk-copy (cp -R) from $xroot to the
	filesystem image, *but* you can't cp around the
	files in /dev.  The script below is hackish
	in that I list out all the subdirectories in
	$xroot except /dev and copy them, then populate
	/dev using the mkdevs script (included after
	mkramdisk).  (It would be more elegant to use find
	with grep -v /dev.)

Note that the script below doesn't selectively choose what
to put into the RAM disk; it just copies everything in
$xroot into the RAM disk image.  What do I put in $xroot?
Things I manually create there (e.g. using a text editor on
my desktop host); cross-compiled executables; library files
taken from my cross-tools directory.

Here is the script; it takes no arguments.  It is run in
arch/ppc/mebboot (or wherever appropriate for your kernel
rev) & writes ramdisk.image.gz right where the kernel
makefile expects to find it.  (It must be run as root; note
that nothing else in my build process needs to run as
root.) So, whenever I modify $xroot, I cd to
arch/ppc/mebboot, su, sh mkramdisk, exit, cd to kernel
source base (../../..), make zImage.initrd, TFTP that up to
the board.


================================================================

#!/bin/sh
# mkramdisk
# See the file Documentation/initrd.txt.
# John Kerl
# john.kerl@avnet.com
# Avnet Design Services
# 2002-04-22

if [ -z "$xroot" ]; then
	echo "Must set \$xroot first." 1>&2
	exit 1
fi
src=$xroot
scratch=/ramdisktmp
dst=ramdisk.image

block_size=1024
num_blocks=8192

# ================================================================
if [ -f $scratch ]; then
	echo "$scratch already exists.  Exiting." 1>&2
	exit 1
fi

mkdir $scratch
if [ $? -ne 0 ]; then
	echo "Could not make directory $scratch.  Exiting." 1>&2
	exit 1
fi

echo ">>> Making zero-filled image file $dst ... "
dd if=/dev/zero of=$dst bs=$block_size count=$num_blocks
echo ">>> done."
echo ""

# Make 8MB filesystem in RAM:
#mke2fs -b $block_size $dst $num_blocks
echo ">>> Making empty filesystem in image file ... "
mke2fs -F -m0 $dst
echo ">>> done."
echo ""

echo ">>> Mounting $dst's filesystem to $scratch ... "
mount -t ext2 -o loop $dst $scratch
echo ">>> done."
echo ""

# ================================================================
# Everything other than board's dev can be copied from $xroot.

echo ">>> Copying $src/bin to $scratch/bin ... "
cp -R $src/bin $scratch
echo ">>> done."
echo ""

echo ">>> Copying $src/etc to $scratch/etc ... "
cp -R $src/etc $scratch
echo ">>> done."
echo ""

echo ">>> Copying $src/lib to $scratch/lib ... "
cp -R $src/lib $scratch
echo ">>> done."
echo ""

echo ">>> Making directory $scratch/tmp ... "
mkdir $scratch/tmp
echo ">>> done."
echo ""

echo ">>> Copying $src/var to $scratch/var ... "
cp -R $src/var $scratch
echo ">>> done."
echo ""

echo ">>> Copying $src/\*.txt to $scratch ... "
cp -R $src/*.txt $scratch
echo ">>> done."
echo ""

echo ">>> Copying $src plain files to $scratch ... "
for x in $src/*
do
	if [ -f $x ];then
		echo "      Copying $x to $scratch."
		cp $x $scratch
	fi
done
echo ">>> done."
echo ""

echo ">>> Making empty directories $scratch/dev and $scratch/proc ... "
mkdir $scratch/dev
mkdir $scratch/proc # This will be the mount point for the procfs.
echo ">>> done."
echo ""

# ================================================================
# Create board's /dev.

echo ">>> Populating $scratch/dev with device nodes ... "

sh mkdevs $scratch/dev

echo ">>> done."
echo ""

# ================================================================
umount $scratch
rmdir  $scratch

echo ">>> Compressing $dst to $dst.gz ... "
gzip -f -9 $dst
echo ">>> done."
echo ""

echo ""
echo ">>> RAM disk complete."
echo ""



================================================================
And here is the mkdevs script.
================================================================

#! /bin/sh
# mkdevs
# John Kerl
# john.kerl@avnet.com
# Avnet Design Services
# 2002-04-22

# ----------------------------------------------------------------
usage() {
	echo "Usage: $0 {directory name} {num ttys}" 1>&2
	exit 1
}

# ----------------------------------------------------------------
if [ $# -ne 1 ]; then
	usage
fi
if [ ! -d $1 ]; then
	echo "$0:  $1 is not a directory." 1>&2
	exit 1
fi

devdir=$1

# Maximum number of simultaneous telnet sessions:
num_ttys=32

# ----------------------------------------------------------------
mknod $devdir/console c  5  1

mknod $devdir/tty     c  5  0
mknod $devdir/ttyS0   c  4 64

i=0
while [ $i -lt $num_ttys ]
do
	mknod $devdir/ptyp$i   c  2 $i
	mknod $devdir/ttyp$i   c  3 $i
	i=`expr $i + 1`
done

mknod $devdir/led0    c 42  0
mknod $devdir/led1    c 42  1
mknod $devdir/led2    c 42  2
mknod $devdir/led3    c 42  3
mknod $devdir/led4    c 42  4
mknod $devdir/led5    c 42  5
mknod $devdir/led6    c 42  6
mknod $devdir/led7    c 42  7

mknod $devdir/mem     c  1  1
mknod $devdir/null    c  1  3
mknod $devdir/zero    c  1  5

mknod $devdir/ram0    b  1  0
mknod $devdir/ram1    b  1  1
ln -s $devdir/ram1 $devdir/ram


-----Original Message-----
From: Kerl, John
Sent: Friday, June 21, 2002 1:42 PM
To: 'Jerry Van Baren'; linuxppc-embedded@lists.linuxppc.org
Subject: RE: Can I run linux without a file system?


It's not *that* bad, is it? ;)

I have to admit I stumbled around for a while before
I got it right, but I do have a shell script for making
a RAM disk image, and I use it all the time.  Is anyone
interested in a copy?

-----Original Message-----
From: Jerry Van Baren [mailto:vanbaren_gerald@si.com]
Sent: Friday, June 21, 2002 1:12 PM
To: linuxppc-embedded@lists.linuxppc.org
Subject: Re: Can I run linux without a file system?



You need at least a RAM file system for "/" and a bunch of subdirectories
such as /dev, /lib, etc.  The common way to do this on a minimalistic
system is to create a file system image in ROM (often compressed) and copy
it to RAM on start up.  Given the questions you are asking, I am very
confident creating a minimal RAM disk image will challenge you sufficiently
:-).  I'm not being snide, lots of people with lots of linux knowledge have
tried and failed.  Most people use someone else's pre-configured minimal
file systems and add/subtract (mostly add :-) programs to it.  This is
because it is very, very hard to create a minimal file system (that works,
that is).

Pointers to development systems with example RAM disk images:
   http://www.denx.de/solutions-en.html
     ftp://ftp.denx.de/pub/LinuxPPC/usr/src/SELF/
   http://www.mvista.com/
   (there are others, I'm just too lazy to do the google search for you)

Trying to run linux without a file system of any sort would require you to
rewrite of pretty much everything and the three or four things you didn't
rewrite, you would have to rebuild (static link, no shared
libraries).  There are a lot of software engineers and hackers that would
turn down the opportunity to do this at any price.  On the other hand, a
lot of naivety and a even more coffee sometimes generates remarkable
results :-).

You really want to look at eCOS or one of the other light weight tasking
OSs.
   http://www.redhat.com/embedded/technologies/ecos/

gvb


At 12:42 PM 6/21/2002 -0700, Tim Lai wrote:

>I am interested in both input/output operation
>on the console. If I just set CONFIG_SERIAL_CONSOLE,
>will I be able read input from the console?
>The main application will be started from init(),
>and the application will need to read and write
>to the console. Are there are method to communicate
>to the serial port other than open("/dev/ttyS0")?
>
>
> >
> > You don't need a filesystem to get output on the
> > serial console
> > you just need to enable the console with
> > CONFIG_SERIAL_CONSOLE=y
> > in your kernel configuration (atleast for mpc860
> > that all)
> > but you will have a hard time producing much more
> > than a blinking
> > cursor if you boot a Linux kernel and have no
> > application that
> > it then can run on the root-filesystem - what would
> > be the point
> > of such a setup - 1MB kernel code for a blinking
> > cursor on a
> > serial port seems expensive.
> >
> > hofrat
>
>


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 26+ messages in thread
* RE: Can I run linux without a file system?
@ 2002-06-21 20:41 Kerl, John
  0 siblings, 0 replies; 26+ messages in thread
From: Kerl, John @ 2002-06-21 20:41 UTC (permalink / raw)
  To: 'Jerry Van Baren', linuxppc-embedded


It's not *that* bad, is it? ;)

I have to admit I stumbled around for a while before
I got it right, but I do have a shell script for making
a RAM disk image, and I use it all the time.  Is anyone
interested in a copy?

-----Original Message-----
From: Jerry Van Baren [mailto:vanbaren_gerald@si.com]
Sent: Friday, June 21, 2002 1:12 PM
To: linuxppc-embedded@lists.linuxppc.org
Subject: Re: Can I run linux without a file system?



You need at least a RAM file system for "/" and a bunch of subdirectories
such as /dev, /lib, etc.  The common way to do this on a minimalistic
system is to create a file system image in ROM (often compressed) and copy
it to RAM on start up.  Given the questions you are asking, I am very
confident creating a minimal RAM disk image will challenge you sufficiently
:-).  I'm not being snide, lots of people with lots of linux knowledge have
tried and failed.  Most people use someone else's pre-configured minimal
file systems and add/subtract (mostly add :-) programs to it.  This is
because it is very, very hard to create a minimal file system (that works,
that is).

Pointers to development systems with example RAM disk images:
   http://www.denx.de/solutions-en.html
     ftp://ftp.denx.de/pub/LinuxPPC/usr/src/SELF/
   http://www.mvista.com/
   (there are others, I'm just too lazy to do the google search for you)

Trying to run linux without a file system of any sort would require you to
rewrite of pretty much everything and the three or four things you didn't
rewrite, you would have to rebuild (static link, no shared
libraries).  There are a lot of software engineers and hackers that would
turn down the opportunity to do this at any price.  On the other hand, a
lot of naivety and a even more coffee sometimes generates remarkable
results :-).

You really want to look at eCOS or one of the other light weight tasking
OSs.
   http://www.redhat.com/embedded/technologies/ecos/

gvb


At 12:42 PM 6/21/2002 -0700, Tim Lai wrote:

>I am interested in both input/output operation
>on the console. If I just set CONFIG_SERIAL_CONSOLE,
>will I be able read input from the console?
>The main application will be started from init(),
>and the application will need to read and write
>to the console. Are there are method to communicate
>to the serial port other than open("/dev/ttyS0")?
>
>
> >
> > You don't need a filesystem to get output on the
> > serial console
> > you just need to enable the console with
> > CONFIG_SERIAL_CONSOLE=y
> > in your kernel configuration (atleast for mpc860
> > that all)
> > but you will have a hard time producing much more
> > than a blinking
> > cursor if you boot a Linux kernel and have no
> > application that
> > it then can run on the root-filesystem - what would
> > be the point
> > of such a setup - 1MB kernel code for a blinking
> > cursor on a
> > serial port seems expensive.
> >
> > hofrat
>
>


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 26+ messages in thread
[parent not found: <200206211835.g5LIZDL01282@hofr.at>]
* RE: Can I run Linux without a file system?
@ 2002-06-21 19:22 Hihn Jason
  2002-06-21 19:35 ` Tim Lai
  0 siblings, 1 reply; 26+ messages in thread
From: Hihn Jason @ 2002-06-21 19:22 UTC (permalink / raw)
  To: 'Tim Lai', linuxppc-embedded


There are people here who can help you more than I, but I'll take a gander.
This is what I believe to be correct:
Yes. You will always have SOME kind of filesystem. But this begs another
question. How much do you know about Linux, and what are you really asking?
The /proc filesystem is not really on any disk, just like /dev (I think)
isn't on any disk, though they look like to us users that they are
filesystems.

If you want to run a program, where will it come from? There are filesystems
made for RAM, like cramfs or ramdisks, or flash filesystems complete with
wear-leveling. Maybe you can just jump to an offset and start executing code
if all you have is just a kernel and a program. If that is the case then
maybe you'll have to call your program 'init' or change the source of the
kernel to invoke your program.

Does this help?

I reserve the right to be wrong.


-----Original Message-----
From: Tim Lai [mailto:laitingwai@yahoo.com]
Sent: Friday, June 21, 2002 11:09 AM
To: linuxppc-embedded@lists.linuxppc.org
Subject: Can I run linux without a file system?



I am porting linux on a custom board.
I am using the bootrom to load vmlinux onto
RAM, and I am in the middle of getting the console/
serial driver to work.
All the documents I read have refer the console as
/dev/ttyS, and state that to communicate to the
console, I have to set it up with open("/dev/ttyS").

Does that means I have to have some sort of file
system in linux?

Thanks.


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 26+ messages in thread
* Can I run linux without a file system?
@ 2002-06-21 15:08 Tim Lai
  2002-06-21 19:54 ` Wolfgang Denk
  0 siblings, 1 reply; 26+ messages in thread
From: Tim Lai @ 2002-06-21 15:08 UTC (permalink / raw)
  To: linuxppc-embedded


I am porting linux on a custom board.
I am using the bootrom to load vmlinux onto
RAM, and I am in the middle of getting the console/
serial driver to work.
All the documents I read have refer the console as
/dev/ttyS, and state that to communicate to the
console, I have to set it up with open("/dev/ttyS").

Does that means I have to have some sort of file
system in linux?

Thanks.


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

end of thread, other threads:[~2002-06-22  4:52 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-21 21:13 Can I run linux without a file system? Cameron, Steve
2002-06-21 21:23 ` Wolfgang Denk
2002-06-21 22:35 ` Conn Clark
  -- strict thread matches above, loose matches on Subject: below --
2002-06-21 21:46 Cameron, Steve
2002-06-21 21:27 Kerl, John
2002-06-21 21:17 Kerl, John
2002-06-21 21:26 ` Roland Dreier
2002-06-21 21:28 ` Wolfgang Denk
2002-06-21 20:41 Kerl, John
     [not found] <200206211835.g5LIZDL01282@hofr.at>
2002-06-21 19:42 ` Tim Lai
2002-06-21 20:12   ` Jerry Van Baren
2002-06-21 20:28     ` Tim Lai
2002-06-21 20:31     ` Dr. Craig Hollabaugh
2002-06-21 20:49       ` Tim Lai
2002-06-21 20:49         ` John W. Linville
2002-06-21 20:54         ` Dr. Craig Hollabaugh
2002-06-22  3:06           ` Tim Lai
2002-06-21 20:58       ` Jerry Van Baren
2002-06-22  4:52         ` David Blythe
2002-06-21 21:06       ` Wolfgang Denk
2002-06-21 19:22 Can I run Linux " Hihn Jason
2002-06-21 19:35 ` Tim Lai
2002-06-21 19:50   ` Dan Malek
2002-06-21 20:18     ` Tim Lai
2002-06-21 15:08 Can I run linux " Tim Lai
2002-06-21 19:54 ` Wolfgang Denk

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).