Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 May 2003 13:29:39 +0930
From:      Malcolm Kay <malcolm.kay@internode.on.net>
To:        "Neo" <neo@gothic-chat.de>, <freebsd-questions@freebsd.org>
Subject:   Re: simple way to mount a ramdisk?
Message-ID:  <200305251329.39197.malcolm.kay@internode.on.net>
In-Reply-To: <002701c321a9$52f16fd0$0400a8c0@NEUROMANCER>
References:  <002701c321a9$52f16fd0$0400a8c0@NEUROMANCER>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 24 May 2003 13:32, Neo wrote:
> Hi,
>
> can anyone tell me please, how to "mount a mfs-filesystem for dummies"?
>
> My hdd is /dev/ad0 with two slices /dev/ad0s1a as / and /dev/ad0s1b as

Does this mean you have the trees /usr, /var and /tmp all resident on=20
/dev/ad0s1a ?

> swap, the ramdisk (for example 8 megs in size) should become /ram.
>

Assuming you're running FBSD 4.x then:

If /dev/md0c does not exist then
=09# cd /dev
        # MAKEDEV md0

Next:
        # mkdir /ram

Now follow the man page md(4):
        # disklabel -r -w md0 auto
        # newfs /dev/md0c
        # mount /dev/md0c /ram
        # chmod 1777 /ram

Now:
        # df
should show md0c mounted on /ram

The capacity is set up when the kernel is compiled
and is 20000 sectors of 512 bytes or about 10Mb.
But empty sectors and sectors of uniform data=20
don't consume real memory space.

For automated installation on boot:
The devices /dev/md0 and/dev/md0c should be permanent
once created and so should /ram directory.

You need to add somewhere in the start sequence:

     if [ -e /dev/md0 -a -e /dev/md0c ]; then
             disklabel -r -w md0 auto && \
             newfs /dev/md0c && \
             mount /dev/md0c /ram && \
             chmod 1777 /ram
     fi

This might be for example added to /etc/rc.local  or
created as such if it does not exist.

Or better create a file /usr/local/etc/rc.d/ram.sh
with the lines:
     #!/bin/sh
     if [ -e /dev/md0 -a -e /dev/md0c ]; then
             disklabel -r -w md0 auto && \
             newfs /dev/md0c && \
             mount /dev/md0c /ram && \
             chmod 1777 /ram
     fi

Make sure the file is set to executable:
     # chmod +x /usr/local/etc/rc.d/ram.sh
(The file name must terminate in .sh)


Malcolm



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305251329.39197.malcolm.kay>