FW: simple way to mount a ramdisk?

Paul Hamilton paulh at bdug.org.au
Wed May 28 00:49:55 PDT 2003


Well done Malcolm, and well written!

Cheers,

Paul Hamilton

-----Original Message-----
From: owner-freebsd-questions at freebsd.org
[mailto:owner-freebsd-questions at freebsd.org]On Behalf Of Malcolm Kay
Sent: Sunday, 25 May 2003 12:00 PM
To: Neo; freebsd-questions at freebsd.org
Subject: Re: simple way to mount a ramdisk?


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
/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
	# 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
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
_______________________________________________
freebsd-questions at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"







More information about the freebsd-questions mailing list