setting up crypto softraid
I have found myself replicating a tiny script that sets up crypto on most of my recent machines, either in rc.local directly or calling it from rc.local. Is this the right way to do it, or is there some support for it in rc(8) already that I missed? Jan #!/bin/sh RAIDPART=/dev/sd0o CRYPTOFS=/dev/sd1a MOUNTDIR=/crypto bioctl softraid0 | grep CRYPTO \ || bioctl -v -c C -l $RAIDPART softraid0\ && fsck $CRYPTOFS \ && mount -v -s -o rw,nodev,nosuid,noatime,softdep $CRYPTOFS $MOUNTDIR
Re: setting up crypto softraid
On Thu, 29 Jul 2010 13:38:18 +0200 Jan Stary wrote: > I have found myself replicating a tiny script that sets up crypto > on most of my recent machines, either in rc.local directly or calling > it from rc.local. Is this the right way to do it, or is there some > support for it in rc(8) already that I missed? > > Jan > > > #!/bin/sh > > RAIDPART=/dev/sd0o > CRYPTOFS=/dev/sd1a > MOUNTDIR=/crypto > > bioctl softraid0 | grep CRYPTO\ > || bioctl -v -c C -l $RAIDPART softraid0 \ > && fsck $CRYPTOFS \ > && mount -v -s -o rw,nodev,nosuid,noatime,softdep $CRYPTOFS $MOUNTDIR > > I use following, right after swapctl in /etc/rc, I'm happy with that ;) for try in 1 2 3 ; do bioctl -c C -l /dev/sd0d softraid0 2>/dev/null ; rc=$? if [ $rc -eq 0 ]; then break elif [ $try -eq 3 ]; then halt -qp else : fi done
Re: setting up crypto softraid
Or you can try this, also in /etc/rc. # Configure raid devices. until bioctl -c C -l /dev/sd0d softraid0; do done for dev in 0 1 2 3; do if [ -f /etc/raid$dev.conf ]; then raidctl -c /etc/raid$dev.conf raid$dev fi done On 07/29/10 22:04, Jiri B. wrote: > On Thu, 29 Jul 2010 13:38:18 +0200 > Jan Stary wrote: > > I use following, right after swapctl in /etc/rc, I'm happy with that ;) > > for try in 1 2 3 ; do > bioctl -c C -l /dev/sd0d softraid0 2>/dev/null ; rc=$? > if [ $rc -eq 0 ]; then > break > elif [ $try -eq 3 ]; then > halt -qp > else > : > fi > done
Re: setting up crypto softraid
On 2010-07-29, Jan Stary wrote: > I have found myself replicating a tiny script that sets up crypto > on most of my recent machines, either in rc.local directly or calling > it from rc.local. Is this the right way to do it, or is there some > support for it in rc(8) already that I missed? > > Jan > > > #!/bin/sh > > RAIDPART=/dev/sd0o > CRYPTOFS=/dev/sd1a > MOUNTDIR=/crypto > > bioctl softraid0 | grep CRYPTO\ >|| bioctl -v -c C -l $RAIDPART softraid0 \ > && fsck $CRYPTOFS \ > && mount -v -s -o rw,nodev,nosuid,noatime,softdep $CRYPTOFS $MOUNTDIR The problem is that you can't be sure that the new device that softraid attaches will be sd1. For example if you have a umass(4) connected when you boot things will get mixed up. Earlier today I thought about writing a script based on the hw.sensors.softraid0.drive0 sysctl value which will tell you whether it has been attached correctly and what device was attached. Best regards, Jona -- Worse is better Richard P. Gabriel
Re: setting up crypto softraid
On Jul 29 23:03:18, Tomas Vavrys wrote: > Or you can try this, also in /etc/rc. That's not what I meant. I don't want to tweak /etc/rc itse;f. What I was asking is whether there are variables I could set in rc.conf.local, as with other features. Probably not, so I will continue using my tiny scripts.
Re: setting up crypto softraid
Hi, On Fri, Jul 30, 2010 at 7:28 AM, Jan Stary wrote: > On Jul 29 23:03:18, Tomas Vavrys wrote: >> Or you can try this, also in /etc/rc. > > That's not what I meant. I don't want to tweak /etc/rc itse;f. > What I was asking is whether there are variables I could set > in rc.conf.local, as with other features. > > Probably not, so I will continue using my tiny scripts. Without touching rc, I use this tiny bits in rc.securelevel: for TRY in 1 2 3; do bioctl -c C -l /dev/sd0m softraid0 if [ $? -eq 0 ]; then DRIVE=$( expr "$(sysctl -n hw.sensors.softraid0.drive0)" : 'online (\(sd[0-9]\)), OK' ) fsck -p /dev/${DRIVE}d \ && mount -o softdep /dev/${DRIVE}d /home break fi done Ciao, D.