0

since I switched to linux a couple of days ago, I try to configure my machine. The last thing is: I have a physical RAM drive with 16GB DDR2 Ram. This device mounts as a real physical SATA harddrive. Normally this is connected to an external power supply so that it will hold the information until the next start of the computer.

Now I like to connect this to the internal PSU to save some energy. If the machine boots then the RAM drive is empty an unformatted. How can I format this during boot process, before fstab occurs?

I am using elementaryOS. I know that there are locations with startup scripts, but I have no idea how to write my own "auto-partition-Hyperdrive" script. Such a script should be placed some where before fstab takes place so that I can mount /tmp to the RAM drive.

Does anybody can help me please?

Best Martin

1 Answer 1

0

It took quite a while to find a solution. I am not sure if this is a proper and convenient way to do that, but it works for me.

The following script will do the automated formatting and mounting stuff:

#!/bin/bash

# search the device name 'ANS9010_22222222' and construct the path to it
DEV='/dev/'$( lsblk -n -o name,MODEL | grep ANS | cut -f 1 -d ' ' )

echo $DEV # this schould give something like /dev/sda

# This is now specific to the device
# set the disc label
parted -s $DEV mklabel msdos

# make the partition
parted -s $DEV unit kB mkpart primary 34 100%

# now we have to work with the 1st partition e.g. /dev/sda1
# so we must generate a $DEVP variable
# finally initialize the filesystem and give it a name
DEVP=$DEV'1'
mkfs.ext3 -L HYPERDRIVE $DEVP

# mount it via a 3 way change of dirs
echo '+++ make-dirs +++'
# make a temporary dir for the hyperdrive and mount it to that
mkdir /tmp_hyp
echo '+++ mount +++'
mount /dev/sda1 /tmp_hyp
# move everything to /tmp_hyp
echo '+++ move +++'
mv -f /tmp/* /tmp_hyp

# unmount, clean and remount as /tmp
echo '+++ umount +++'
umount /tmp_hyp
rmdir /tmp_hyp

echo '+++ remount /tmp +++'
mount -t ext3 -o defaults $DEVP /tmp

# !! very important !! change permissions to tms's defaults
chmod 0777 /tmp

Having that, we must achieve, that this script is executed during boot. Since the method via rc.locale is still tricky, adding a line to '/etc/crontab' solved this:

# m h dom mon dow user  command
... ... ... ... ... ... ...
@reboot     root    /usr/local/etc/auto-format-hyperdrive.sh

The important thing here is the 'root' user and the '@reboot', which tells cron to execute the script as root at each reboot. "TaTahha" and this works fine for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .