{ ^_^ } sinustrom Solving life, one problem at a time!

i-RAM drive init script for Gentoo

Author: Zoltan Puskas
Categories: linux

I happened to get my hands on an Gigabyte i-RAM drive (RAM based SSD) that I put into my big box. It is a PCI card format device that can hold 4 pcs. of DDR RAM modules and acts as a SATA drive. I have installed 2 pcs. of 1GB 400MHz memory modules into it so I got 2GB of fast disk space. It can be used as swap or for the /tmp directory. My unit however lacks the battery so it cannot be used as a storage across reboots. So I wrote a quick init script for Gentoo to initialize it on every boot as a swap drive.

OpenRC init script

The script is pretty simple. For every disk device it will get the model information using hdparm. If the reported device model is i-RAM, then create a swap file system on it. It also checks if there is a partition table (to be more precise it looks for partition 1) and if not found then creates it beforehand.

# Distributed under the terms of the GNU General Public License v2
# $Header: $
start() {
    ebegin "Preparing i-RAM drive"
    for i in /dev/sd[a-z]; do
        data=`hdparm -i $i 2> /dev/null | grep "Model"`
        if [[ "$data" =~ "$RAMDRIVE" ]]; then
            if [ ! -b ${i}1 ]; then
                parted -s ${i} mklabel pc98
                parted -s ${i} mkpart primary linux-swap 0% 100%
            mkswap -f ${i}1 &> /dev/null
    return 0
stop() {
    return 0
# vim:ts=4

fstab mounting

After this the drive can be mounted through fstab, as primary swap in my case. Relevant line to do this from my /etc/fstab:

/dev/sdb1               none            swap            sw              0 0