FW: simple way to mount a ramdisk?

From: Paul Hamilton (paulh_at_bdug.org.au)
Date: 05/25/03

  • Next message: Paul Hamilton: "RE: 'top' showing high interrupt rate"
    To: "Freebsd-Questions" <freebsd-questions@FreeBSD.ORG>
    Date: Sun, 25 May 2003 16:02:31 +0800
    
    

    Well done Malcolm, and well written!

    Cheers,

    Paul Hamilton

    -----Original Message-----
    From: owner-freebsd-questions@freebsd.org
    [mailto:owner-freebsd-questions@freebsd.org]On Behalf Of Malcolm Kay
    Sent: Sunday, 25 May 2003 12:00 PM
    To: Neo; freebsd-questions@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@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"

    _______________________________________________
    freebsd-questions@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"


  • Next message: Paul Hamilton: "RE: 'top' showing high interrupt rate"

    Relevant Pages

    • Re: Mounting an FTP space ?
      ... To unsubscribe, ... FOR YOUR COMPUTER Customised software built to your specifications. ... FOR YOU Computer training, software installation + upgrades, computer setups. ...
      (freebsd-questions)
    • Re: grub-install seems to be wiping my partitions
      ... > Check current partition structure ... > Size in sectors ... Find local movie times and trailers on Yahoo! ... To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list ...
      (Fedora)
    • HDD problem research (was HDD questions)
      ... Does any body have Segate drive ST380021A working with FreeBSD? ... > Also, I tryied to read some sectors back and forward, and found out ... > Best regards, ... >> To unsubscribe, send any mail to ...
      (freebsd-hackers)
    • Re: RAID Sizes (was Re: Why do people in the UK put a u in the word color?)
      ... strictly differ between decadic and binary prefixes, ... use 512B sectors, and it's easier to divide number of sectors by 2 than ... Why would I want to divide sectors anyway. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
      (Debian-User)
    • Re: RAID Sizes (was Re: Why do people in the UK put a u in the word color?)
      ... fill up those sectors until the Track/Block/Cluster is ... The cylinder/track/sector used to make sense in the ancient days of DOS ... CHS current addressable sectors: 4128705 ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
      (Debian-User)