4/13/2009

LVM Volume Manager on NetBSD

Let’s see how to use NetBSD’s newborn volume manager. It’s sharing much with Linux LVM, so it may be very familiar. You will need NetBSD current (I’m using 5.99.10) and sources.

# cd /usr/src/external/gpl2/lvm2/

# USETOOLS=no MKLVM=yes make

# USETOOLS=no MKLVM=yes make install

# USETOOLS=no MKLVM=yes make clean

# cd /usr/src/sys/modules/dm/

# USETOOLS=no MKLVM=yes make

# USETOOLS=no MKLVM=yes make install

# USETOOLS=no MKLVM=yes make clean

Let’s load it:

# modload dm
# modstat | grep dm
dm              driver  filesys 0       18364   -

# lvm pvcreate /dev/rwd1d /dev/rwd2d
  Physical volume "/dev/rwd1d" successfully created
  Physical volume "/dev/rwd2d" successfully created

# lvm vgcreate volumes /dev/rwd1d /dev/rwd2d
  Volume group "volumes" successfully created

# lvm lvcreate -n vol0 -L 400M volumes
  Logical volume "vol0" created
# lvm lvs
  LV   VG      Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  vol0 volumes -wi-a- 400.00M

# newfs -O 2 -F -s 400M /dev/volumes/rvol0
/dev/volumes/rvol0: 400.0MB (819200 sectors) block size 8192, fragment size 1024
        using 9 cylinder groups of 44.45MB, 5689 blks, 10720 inodes.
super-block backups (for fsck_ffs -b #) at:
144, 91168, 182192, 273216, 364240, 455264, 546288, 637312, 728336,


# mount /dev/volumes/vol0 /mnt
# mount
/dev/wd0a on / type ffs (log, local)
kernfs on /kern type kernfs (local)
ptyfs on /dev/pts type ptyfs (local)
procfs on /proc type procfs (local)
/dev/mapper/volumes-vol0 on /mnt type ffs (local)

11/15/2008

How to compile PCC?

As you may know PCC is a new kid on the C compiler block, though it's based on the historic Unix compiler with the same name. It's currently aiming at full C99 compliance and it already support most of the language features, recently even C99 inline.

As it's still in an early stage of developement, obtaining a copy is recommended from the project's CVS.

First, check out the source tree:
$ cvs -d :pserver:anonymous@pcc.ludd.ltu.se:/cvsroot co pcc

After that, we can build it using autoconf:
$ cd pcc
$ ./configure --prefix=/opt/pcc
$ make
$ make install


Now we should have an /opt/pcc/bin/pcc binary, so we can start playing:

$ pcc -v
pcc 0.9.9 for i386--netbsdelf, replaced@grimnismal.regius.local Sat Nov 15 22:54:49 CET 2008
no input files

11/04/2008

A basic proplib example

I had a little time to try property lists today.
Proplib is an API/lib to create, handle and store property lists.
It was created by Apple but NetBSD also have a clean room implementation in the system, and it's mostly used for implementing sysctl interfaces. It's a somehow limited implementation to make it faster/smaller (maybe extended in the future as demands grow).
Here's a little example code to show some of the basics:

This will create a dictionary and store it as an xml file on the disk:

int
main()
{
prop_dictionary_t d;
bool r;

d = prop_dictionary_create();

if (d == NULL)
goto error;

r = prop_dictionary_set_cstring(d, "name", "Adam");
if (!r)
goto error;
r = prop_dictionary_set_uint32(d, "year", 1986);
if (!r)
goto error;

r = prop_dictionary_externalize_to_file(d, "test.plist");
if (!r)
goto error;

return EXIT_SUCCESS;

error :
fprintf(stderr, "error\n");
return EXIT_FAILURE;
}


And this will read it and display the values:

int
main()
{
prop_dictionary_t d;
uint32_t year;
char *name;
bool r;

d = prop_dictionary_internalize_from_file("test.plist");
if (d == NULL)
goto error;

r = prop_dictionary_get_cstring(d, "name", &name);
if (!r)
goto error;
r = prop_dictionary_get_uint32(d, "year", &year);
if (!r)
goto error;

printf("name: %s, year: %u\n", name, year);

return EXIT_SUCCESS;

error :
fprintf(stderr, "error\n");
return EXIT_FAILURE;
}


You will need to include prop/proplib.h or a similar header file depending on the implementation you use.

Setting the default uid in gpg

It's a bit tricky to do it at the first time as the gpg --edit-key command line is a bit counterintuitive:

gpg --edit-key adam.hoka

you see something like this now:
Command>

type list and lookup the number next to the ID you want to use as a default and enter it.

Example:
Command> 2

It will list the IDs again (note the asterisk next to the selected ID).
Type primary and then save.

Done.

10/25/2008

ARM based netbooks?

It seems the next generation of Cortex CPUs will also be aimed for netbook class portables and I'm pretty sure I saw somewhere a Samsung based ARM netbook too. x86 netbooks never really cought my attention, but I would certainly get my hands on an ARM based one! Especially if it runs NetBSD.

Android's Dalvik Java VM

This video show Androids Java implementation. It has some impressive features.

Haiku pre-alpha

Today I gave a try to Haiku alpha. There was an announcement about a disk image available for testing loaded with devel tools and some applications like Firefox and VLC. Those how may wonder what is Haiku: It's an open source reimplementation of the BeOS operating system and software environment. It's quite developed, though it still needs coding love I think. :)

After trying the image in qemu, the free machine emulator, I thought is should boot it on bare hardware too. Usually that's where in-development OS fail. But haiku did not.

Even if it wasn't as fast as BeOS, it was quite stable and usable. Detected my sound card and network card, but to be honest Realtek and SB Live are not so exotic harware.

I think it will kick ass when released.


The disk image I have tried: http://haiku-files.org/raw/haiku-pre-alpha-r28283.raw.bz2