gpart on top of eli inside a slice is not working

Bjoern A. Zeeb bzeeb-lists at lists.zabbadoz.net
Wed Mar 25 15:15:29 PDT 2009


Hi,

assume you get a laptop with the usual pre-install that you must not
and cannot change but still want to add a freebsd to the wastefull
emptyness at the end of the large disk.

So you have 3 classic slices:
1 compaq recovery
2 ntfs
3 dos (free)

So I tried to play a bit with that and tried to install freebsd on slice 3
inside eli. To try gjournal as well I thought I go with gpart directly
as it will be the tool in the future instead od bsdlabel and created
3 paritions: 1 for the journal, 2 for swap and 2 for the data.
All was fine. I rebooted. and there was garbage.

Here´s a script to reproduce this on head. It will create a swap
backed memory disk and a $0.key file.  If unsure run the steps by hand
to avoid the script accidentally go wild.

It's quickly hacked together so it's not nice but did the job on a
8-current here.

It does not yet create the journal or newfs anything as I tried the
minimum to reproduce this. Leaving out the fdisk and the s=${md}s3
it will work fine.  So I guess it a problem of stacking things.
And before you are going to ask - changing slice 3 to 165 (freebsd)
does not change anything.

Any ideas?

----- 8< 8< 8<----------------------------------------------------------
#!/bin/sh

case `id -u` in
0) ;;
*) echo "Run as super user" >&2
    exit 1
    ;;
esac

md=`mdconfig -a -t swap -s 32901120 -x 63 -y 64`
case "${md}" in
md*) echo "Created swapped backed memory disk ${md}" ;;
*) echo "ERROR creating memory disk">&2
    exit 1 ;;
esac

echo ¨creating initial set¨
echo " ..fdisk"
# cannot get this to work
fdisk -q -i -f - /dev/${md} <<EOFDISK
# 80000 2 63 255 0 2048 0
g c4 h64 s63
p 1 18 63 3969
p 2 7 4095 3969
p 3 6 8064 44352
a 3
EOFDISK
fdisk /dev/${md}

# slice we use
s=${md}s3

echo " ..eli key"
dd if=/dev/random of=$0.key bs=64 count=1
echo " ..eli init, attach"
geli init -s 4096 -P -K $0.key /dev/${s}
geli attach -p -k $0.key /dev/${s}
echo " ..part create,add,add,add,commit,show"
gpart create -s GPT ${s}.eli
gpart add -b 1024 -s 1024 -t freebsd-ufs /dev/${s}.eli
gpart add -b 2048 -s 1024 -t freebsd-swap /dev/${s}.eli
gpart add -b 3072 -s 2048 -t freebsd-ufs /dev/${s}.eli
# just to be on the save side
gpart commit ${s}.eli
gpart show ${s}.eli
echo " ..eli detach"
geli detach /dev/${s}.eli

echo ¨re-attaching and showing so you can compare¨
geli attach -p -k $0.key /dev/${s}
ls -l /dev/${md}*
gpart show ${s}.eli
geli detach /dev/${s}.eli

echo "Cleaning up.."
# mdconfig also accpets mdN as unit.
mdconfig -d -u ${md}

# end
----- 8< 8< 8<----------------------------------------------------------


/bz

-- 
Bjoern A. Zeeb                      The greatest risk is not taking one.


More information about the freebsd-geom mailing list