Playing around with software raid

And you don’t even need any physical disks for it….

I don’t use Linux software raid tool mdadm that often so I quickly forget how it works. This is something I used on several occasions, when trying to refresh my mind. The cool thing is that you don’t need physical disks or a lot of space for it to work. The following might vary a bit depending on you system (mine is Ubuntu Edgy Eft on IBM x40).

First create a few “disks”… by creating some empty files and making them into block devices:

dd if=/dev/zero of=disk1 bs=1M count=1 seek=30
dd if=/dev/zero of=disk2 bs=1M count=1 seek=30
dd if=/dev/zero of=disk3 bs=1M count=1 seek=30
losetup /dev/loop0 disk1
losetup /dev/loop1 disk2
losetup /dev/loop2 disk3

This creates 3 files (disk1, disk2 and disk3) with the size of 1MB in the current directory and makes them into block devices (just like normal disks is).

Now create your raid, example:

mdadm --create /dev/md0 --level=5 --raid-devices=2 --spare-devices=1 /dev/loop0 /dev/loop1 /dev/loop2

If you get the error:

mdadm: error opening /dev/md0: No such file or directory

Add the parameter --auto=md to the raid create command.

Now you can see you raid status with:

cat /proc/mdstat

Now play around with it all you want


When you are done you stop the raid and remove it with the following:

mdadm --stop /dev/md0
mdadm --remove /dev/md0

Perhapes you want to remove the md0 device again with (only if you needed the --auto=md parameter:

rm /dev/md0

Cleanup the “disks”:

losetup -d /dev/loop2
losetup -d /dev/loop1
losetup -d /dev/loop0
rm disk3
rm disk2
rm disk1

Now you computer wont have a trace of you your software raid disks… besides you shell history :)

Using ath0 as bridge in VMware... or almost

Well I couldn’t make my Atheros (ath0) work as a bridged network with VMware… but I made a workaround which I want to share with you guys. Anyways I’ll have it documented if I cant remember what I did later on. I have installed VMware on my Ubuntu laptop and a edgy-alternative (server) as a guest OS within VMware. The way I did this was making my laptop into a router between the “VMware host only” net and my wireless net.

You need to have configured a host only network for your VMware machines, mine is called vmnet1 and is using the network:

My laptop has the following ip’s:

wireless:    ath0 (provided by DHCP)
wired:       eth0     * (not used in this example)
VMware net:  vmnet1 (static)
gateway:     default

My Ubuntu edgy server has the following ip’s:

wired:       eth0 (static)

On my laptop I have made a script that does the following:


# Enable router functionality
echo 1 > /proc/sys/net/ipv4/ip_forward

# Enabling SNAT (MASQUERADE) functionality on $EXTERNAL

All my rules are set to accept as default, if yours are not you might want to add something like this:


On my VMware guest I have configured eth0 to have the static ipadress and to use as default gateway. The way you set this up depends on you guest OS, but you can also do this manually with:


ip a add dev $INTERNAL
ip link set $INTERNAL up
route add default gw

Now test by pinging you host’s gateway (my laptop):


Note: You propably want to set you guest OS to be able to use a DNS server.

Random disconnects wit CoovaAP

Through the last week I have played around with CoovaAP on my Linksys WRT54GL… I was just too curious to try it out after my colleague Tomas told me about it :D CoovaAP is a slightly customized version of OpenWRT to make it easy to setup a wireless HotSpot like the one you can connect to on cafés, hotels and such.

CoovaAP comes with pretty much everything out of the box except the FreeRADIUS server. There are some free RADIUS servers around the net which seems to be Coovas intention that people should use. It seems like a really nice pice of software, but for me it was a NO GO.

After installing Coova on my access point I would get randomly kicked off World of Warcraft, even though I was using a wired connection on that machine. Teamspeak and other things seems to be unaffected. I haven’t been digging into what caused this problem, I don’t really have the experience or the time to do anything about it.

Calculate next SID, and why SID already is in base?

Today at work I got an error like the following while I tried to add a new user:

ldapsam_add_sam_account: SID 'S-1-5-21-xxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-3048' already in the base, with samba attributes

I searched the net to find out what the problem was. On some site I found how the SID is calculated:

User-SID: uid*2+sambaAlgorithmicRidBase
Group-SID: gid*2+sambaAlgorithmicRidBase+1

My user had uid 1024 so it seemed to fit just right (I guess sambaAlgorithmicRidBase=1000). But why had another user already got the SID 3048, that would mean that another user had uid 1024?… Exactly! :)

Users for Samba is stored in LDAP. I have split my user- and Windows workstaion accounts (which also needs to be Linux users) into different containers named Users and Computers. When a normal account is created, it only checked for existing uid’s in the Users-container. Because of this I now have 2 users with the uid 1024 (both Windows workstation account and my newly created user account) and now a SID conflict. I should fix the uid check when adding a new user to also check in the Computers-container. Hopes this helps some people with similar problems.

Weblog comments

I just went through a lot of comments which was pending approval. The reason why I haven’t done this before is because I hadn’t noticed that I had pending messages. Though the last few months have been a bit on the slow side. If I had been blogging regular I might have noticed before. Most comments was to my old post about MP3 ripping in sound Juicer. A lot of good tips in between, I’m really sorry guys.

I had like 4000 spam messages which I had to dig through first :(

I’m planning on updating my weblog software soon, perhaps it becomes easier to manage.