Installing Arch Linux on the PogoPlug

Back in 2012 I wrote about how I set up a $30 linux server by installing Debian Squeze on a PogoPlug. I have been using the device for close to two years, but it died. I grabbed an identical replacement few days ago, but for some reason I was having trouble getting Debian working again, despite using identical device, similar thumb drive and following the same procedure. The truth is that Debian is not the best OS to run on this device. Pretty much everyone’s go-to system of choice for these devices is Arch linux which has excellent ARM support.

I’ve been itching to try Arch for a while not but I never really had an opportunity so I figured I might as well use it now. It worked amazingly well, so I figured it would be wroth while to document the procedure for future reference. Especially considering it is slightly different from the Debian procedure. I used this guide but with some significant alterations (see below).

Logging into the PogoPlug

First, you need to figure out the IP of your plug. Best way to do this is to log into your router and match it by name or Mac address. Once you know the IP address you can ssh into it using root as the username and ceadmin as password.

Preparing the Thumb Drive

The default OS on the PogoPlug is locked down pretty tight. Pretty much the only place with write access on the device is /tmp so you won’t be able to install to the internal drive (or rather it is fairly impractical to do). Instead you want to set up Arch on a thumb drive.

First, you will need to figure out which devices is the drive recognized as. I’m fairly sure the top-most USB port on the back of the device always registers as /dev/sda but you can easily check it by plugging it in and then running:

dmesg | tail

The last few lines should reveal which device the system thinks was plugged in. I’ll assume it was /dev/sda. First thing you want to do is to repartition it using fdisk:

/sbin/fdisk /dev/sda

Create two new partitions:

  • Press o to blow away all existing partitions on the drive.
  • Press n to create a partition, p to set it as “primary” and 1 to designate it as first
  • Hit Enter to accept the default starting point
  • Specify size using the format +[size]M where [size] is an actual value in MB. For example, I used +1536M designating majority of the space on my 2GB drive for my primary partition, and leaving 512MB for swap. If you have 4GB drive use +3582 and so on.
  • To set up second partition hit n, p, 2
  • Hit Enter to accept the default starting point
  • Hit Enter once again to use all the remaining space
  • Hit t then 2 to change the filesystem on partition 2 and use 82 (Linux Swap)
  • Hit a, 1 to make first partition bootable
  • Hit w to write changes to the disk

When you’re done the p command should return something like:

/dev/sda1   *           1         911     3501853  83 Linux
/dev/sda2             912        1018      411308  82 Linux swap

Since arch uses ext3 file system we will want to format the primary partition /dev/sda1 as such. Unfortunately the default OS on the PogoPlug does not ship with support for ext3 so we will need to download the mke2fs tool from the arch website and then use it to format the partition:

cd /tmp
wget http://archlinuxarm.org/os/pogoplug/mke2fs
chmod +x mke2fs
./mke2fs -j /dev/sda1
mkdir alarm
mount /dev/sda1 alarm

Installing Arch

Now we are ready to download the Kirkwood Arch binaries. The latest builds are close to 200MB in size, which was too big to fit in on the PogoPlug system partition. I recommend downloading it it to the newly formatted drive instead:

cd alarm
wget http://archlinuxarm.org/os/ArchLinuxARM-kirkwood-latest.tar.gz

The official PogoPlug write-up on the Arch website tells you to use bsdtar to extract this archive. This may or may not work for you. I had major issues unpacking that way due to a locale mismatch and the UTF-8 encoding being used for file paths within the compressed bundle. Extracting the file the old fashioned way however worked just fine which is what I recommend you do:

tar -xzvf ArchLinuxARM-kirkwood-latest.tar.gz
sync
cd ..
umount alarm

Finally, download the U-Boot installer which will flash the ROM memory of the PogoPlug and force it to boot off the USB drive. Note that this step can brick the device (though I’ve done it a dozen times by now and never had any issues):

wget http://archlinuxarm.org/os/armv5te/boot/pogo_e02/pogo_e02.sh
chmod +x pogo_e02.sh
./pogo_e02.sh

Once this is done, reboot manually:

/sbin/reboot

If everything worked correctly the device should now boot into Arch. When the device reboots, log in with username root and password root.

Configuring Arch

First thing you will probably want to do is to update the system. You use the default Arch package manager pacman for that:

pacman -Syu

Next, you probably want to change a root password and add a new regular user for yourself (remember to add yourself to the wheel group):

passwd
useradd -m -g users -G wheel -s /bin/bash luke
passwd luke

The Kirkwood install is very bare bones and it does not ship with sudo so you will probably want to install it:

pacman -S sudo

Configure it with visudo and append the following to the end of the file:

%wheel      ALL=(ALL) ALL

This will give your regular user and all the other potential future members of the wheel group access to sudo command. At this point it may be a good idea to log out and log back in to make sure the user account you just created works, and that you can use su and sudo to elevate your privileges. If everything works, you may want to disable the remote access to the root account like this:

passwd -l root

You will probably want to change the devices hostname. On Arch this is done via the hostnamectl command:

hostnamectl set-hostname mypogoplug

If you’re on a Windows network and you want to be able to use the hostname instead of the ip address when you ssh you will need to install samba and give it a netbios name:

pacman -S samba
cp /etc/samba/smb.conf.default /etc/samba/smb.conf

Modify the smb.conf file to include:

workgroup = MYWORKGROUP
netbios name = mypogoplug

Now start samba and set it to start on boot:

systemctl start samba
systemctl enable samba

You should now be able to ssh into your plug using mypogoplug rather than the IP address from Windows machines. If you have Apple machines on the network and you want to be able to access them using mypogoplug.local then you will need to install two additional packages: avahi and nss-mdns:

pacman -S avahi nss-mdns

Now open the /etc/nsswitch.conf file and change the following line:

hosts: files dns myhostname

into:

hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname

Finaly, start the avahi-daemon and set it to be run on boot:

systemctl start avahi-daemon
systemctl enable avahi-daemon

At this point your device should be discoverable on the network and more or less ready to go for whatever purpose you may want to use it.

Posted in sysadmin notes | Tagged | 2 Comments

Minion Academy

Have I mentioned that the nemesis system in Shadow of Mordor was really cool? Because it was. Playing that game made me wander what else could be done with it. For example, I have always been fond of RPG oracles and general random generators for pen and paper RPG games. I am firm believer that every NPC and/or enemy, no matter how minor or unimportant should have a name and a few distinguishing features. A good game master can usually make up such details on the spot, but keeping track of dozens of throw away characters which may or may not die or conversely become important at some point can be difficult. So random generators are GM’s best friend – especially when trying to populate the game world with diverse collection of characters and not just standard “dwarf with brown beard, elf with blond hair” type stand-ins which is what you usually come with when you need to make up a character on the spot.

While there are dozens of random NPC generators, I figured I might as well write my own. It seemed like a fun and quick side project. How would one go about procedurally generating non player characters though?

First and foremost I figured it should be easy to modify and expand. Instead of hard coding values into the generator itself, I figured it should be stored as some sort of a structured list. I went with YAML because unlike many data serialization formats what claim to be “human readable” it actually is. Well, at least for me it is – your opinion may of course vary and it is not like YAML is without a lot of weird quirks. But I basically just needed a simple data format that could be easy to edit by hand, and that could be consumed by my code without doing a lot of parsing. Seeing how in Ruby can slurp a YAML file into an associative array in a single line of code, it was more or less perfect.

Moreover, I wanted my generator not to be “fully” random but rather use weighted probability scores for specific things. For example, it should be relatively rare to see a Rogue wearing a plate armor, but it would be common to see it on Warrior characters. How do you implement that? There is a few ways. For example you could find the discrete cumulative density function (CDF) of your list, generate a random number in the range between 0 and the sum of all weights, do a binary search to find this number… Actually, no. Scratch that. This is a solved problem and there is literally no reason to re-invent it other than as a classroom exercise maybe (or if you are worrying about performance). Instead of spending hours writing and debugging CDF code, we could just grab a gem such as this one and be done with it.

The basic idea was to let me write a weighted list like this in YAML (higher the number, the better likelihood the item gets picked):

race:
    Human     : 6
    Elf       : 6
    Dwarf     : 6
    Orc       : 6
    Goblin    : 5
    Halfling  : 4
    Hobgoblin : 3
    Kobold    : 2
    Ogre      : 2
    Troll     : 1
    
class:
    Fighter  : 4
    Soldier  : 3
    Cleric   : 1
    Bard     : 1
    Diplomat : 2
    Ranger   : 5
    Rogue    : 5
    Sage     : 1
    Scout    : 3
    Warrior  : 6

social:
    Commoner : 5
    Noble    : 2

Then in Ruby I could pull stuff out of it like this:

require 'yaml'
require 'pickup'
 
data = YAML.load_file('stuff.yml')
race = Pickup.new(data['race']).pick(1)
class = Pickup.new(data['class']).pick(1)

This was basically as complex as the code would get. As it is usually the case with this kind of projects the bulk of the work went into actually generating the data files that would yield not only a good deal of variety but also return both mundane and ordinary foot soldiers as well as funky and exceptional fun characters from time to time. It is more of a creative endeavor rather than programming.

What kind of weapons are appropriate for a rogue? What kind of armor should be worn by scouts? What color can Orc eyes be, and would this be any different for goblins? What kind of scale colors are most popular amongst the Kobolds? These were the sort of questions I had to answer while making this tool.

If you follow me on Twitter (as you should) you have probably seen me posting screenshots of the minions I was generating on the console:

This is back when I still had “barbarian” as a class which I later decided against including. Why? Well, to me it seems like every other class (warrior, rogue, bard, cleric, etc..) is something you choose to be. Barbarian, on the other hand is something you are. It is more often than not used to describe a social caste or grouping of people rather than a profession / calling. So I removed it and replaced it with Fighter and Soldier to have 3 solid close combat classes. In my mind warriors fight out of conviction (they have a duty, seek glory, want justice, etc..), fighters do it because they like it (they are the brawler, trouble-maker types that start fights in taverns for shits and giggles) and soldiers do it strictly for money.

Creating plausibly sounding names proved to be a whole separate problem. I knew that when it came to elves and Dwarfs, I could just shamelessly crib from Tolkien if I wanted to because there are billions of good names for both of these races in the Middle Earth lore. But I didn’t just want to have gigantic copy pasted lists. So I opted for something slightly more clever. I grabbed some interesting names, broke them into (usually) two parts, and then randomly recombined them. For example, here is a sample of Orc name table:

Orc:
    given:
        Male:
            prefix:
                grish: 5
                gor: 5
                muz: 5
                maz: 5
                lag: 5
                lat: 5
                lar: 5
                lir: 5
                rad: 5
                shá: 5
                rag: 5
                rat: 5
                urf: 5
                goth: 5
                núr: 5
                nir: 5
                fár: 5

            postfix:
                nákh: 5
                bag: 5
                gash: 5
                gnash: 5
                bash: 5
                mash: 5
                gol: 5
                mol: 5
                duf: 5
                buf: 5
                rúf: 5
                muf: 5
                dúr: 5
                grat: 5
                gnat: 5
                thrak: 5
                lúk: 5
                múk: 5
                mog: 5
                rog: 5

This particular selection can yield names like Grishnákh, Gorbag and Muzgash (all of whom are named characters from Lord of the Rings) as well as dozens more or less plausibly sounding names.

Most races have gendered first names and last names dictated by social status. So for example a noble’s name may include the name of their estate, or name of their father, whereas the names of commoners are typically nicknames or trade profession related. Elves, Hobgoblins and Trolls ended up with gender neutral names just because of how alien they sounded and because I wanted to have at least one group which did not have a concept of gendered names.

Once I had basic data files created, I wrapped it up in a bit nicer interface and started generating minions by dozens. It was interesting just to read their short descriptions and try to imagine how they would look and what their personalities would be. At some point I even noticed emergent little micro-stories popping up every once in a while. For example, here are two randomly generated Orcs I got the other day:

I found it interesting that they were both ambitious and feared losing face. It felt like they were connected somehow. Ragma was a noble born warrior while Mizni one was a commoner and a ranger. Possibly Ragma’s attendant and a guide? They were likely traveling companions: Ragma young, impetus, and irresponsible, but eager to make a name for herself. The older, wiser Mizni was likely appointed by her parents to keep the young warrior in check, and make sure she returns home safely from their adventures. They both driven by their ambition. Ragma wants to prove she can live up to the high standards of heroism set by her parents. Mizni wants to prove her value to the family by taking on a challenge of keeping the wild and irresponsible Ragma in check. You could literally write a short story about them, just based on this relationship.

This is the beauty of randomly generated content: sometimes a short little blurb can strike a chord with you and your imagination will immediately fill in the blanks creating interesting and meaningful relationships and scenarios. I figured it was worth sharing this little thing that I have done with others.

Minion Academy Screenshot

Minion Academy Screenshot

I set it up on Heroku cloud platform, and named it Minion Academy, mainly because I managed to snag that as a URL. So it is now up at minion.academy. When you visit the page you will get five randomly generated NPC’s and you can refresh the page for five new ones. It’s very basic, and still rather rough around the edges. There is still some work I want to do with it.

For example, I want to add more armor choices. Right now it’s basically just cloth, leather, chain or plate. I would like to expand it so that you could have a wide variety of different armor types for each of these categories. You might have also noticed there are no magic user types being generated right now. This is partly by design (I was initially trying to make a minion specific generator which kinda grew to cover all kind of NPC’s) but I’d like to add some wizards and sorcerers at some point.

If you notice a bug, I have the source code on Github so feel free to submit a bug report. As usual, let me know what you think in the comments.

Posted in programming | Leave a comment

Shadow of Mordor

Back in the 90’s I used to play Middle Earth: The Lidless Eye which was a collectible card game about being a Ringwraith. Unlike Magic The Gathering and similar games, MELE was not as much about defeating the opponent, but about being the best minion of the Dark Lord possible. Your mission was to recover ancient artifacts, recruit powerful allies and convince major Middle Earth factions to side with Mordor. Whichever Ringwraith secured more resources won. You could also play against someone with Middle Earth: The Wizards deck, who would be doing the same thing, but for the good guys. The players could only fight directly if their minions visited the same location at the same time (a rare occurrence, and easy to avoid if you did not want a direct confrontation) and instead they would try to thwart each-others efforts by playing environmental hazard cards as the enemy minions traveled.

It was more of a board game with quasi-RPG mechanics, but this was why I loved it. Most of my Friends had Istari based decks, full of Dwarfs, Elves and Hobbit heroes. My deck was full of Orcs, Trolls and evil men and I loved it that way. So did they actually, because it was fun to play these good vs evil games. It felt like there was much more at the stake.

You know what I loved best about that game? That Orcs, Trolls and The Nine fallen kings were given names (not always cannon names mind you, but I did not care). It is a simple thing really: give an entity a name, and it becomes a person. It becomes imbued with life and personality. I could write an entire sitcom worth of stories about Gorbag, Grishnákh and Muzgash – the three plucky Uruk Hai minion-friends who got into all source of trouble all across the Middle Earth.

In Shadow of Mordor I became frenemies with Ronk The Flame Monger, who just wanted to learn how to ride a caragor beast while wearing his absolutely awesome flame hat.

Ronk Flame Monger

Ronk Flame Monger

No, seriously guys, lets take a moment and take in the glory that is Ronk’s hat. As far as I could tell it was unique in my game, and I have never seen it repeated on another Orc captain. I don’t know how it works, or how Ronk prevents his head from being over-heated, but I do think the looks magnificent. He quickly became my favorite and I was overjoyed to help him win duels with other, less fashion conscious Uruks. I loathed having to kill him but the game said I had to. It is a systems thing: in most video games your objective is to bring about a positive change via destructive force. You are always killing enemies, destroying their infrastructure, toppling evil tyrants and etc.. Hardly ever do you get to affect the game world in a positive way by adding something to it – you are almost always a force of destruction and erasure.

Ronk died without ever fulfilling his dream because he had the misfortune of being an Orc leader whose path intersected with half-man half elven wraith assassin and the titular Shadow of Mordor. Oh, you thought that was about Sauron? Nope, that’s you: the protagonist. The silent assassin, ghostly killer, Robert Neville of Mordor but without the “I am legend” epiphany. Your objective in the game is to perpetrate a campaign of terror against the Uruk-Hai natives of Mordor. You use bodies of slain Orc captains to get to their War Chiefs and you use their deaths to draw out and slay the big-boss minions who take their direct orders from the Dark Lord. And when taking Orc lives is not enough your Wraith-half, teaches you how to take over their bodies.

The void that the death of Ronk Flame Monger left in my life was not filled until I met Lûga the Literate One.

Lûga the Literate One

Lûga the Literate One

Perhaps he did not look as cool as Ronk, but his love of literature has won me over. From the moment we crossed swords, I knew this was going to be a long lasting bromance. At that time I had already learned how to “brand” orcs, making them into friendly NPC’s. And so, after defeating Lûga I used my wraith powers to convert him into my own minion. This was really the only way to save his life. If he was not one of “my” Orcs he would continue being an obstacle in my way, and would have to be toppled. We had a good system going: Lûga would challenge another captain to a duel, I would swoop in and either shank his opponent in the back, or brand him. Lûga would take the credit for the victory, quickly rising in the ranks. Soon he became a War Chief and helped me to either brand or topple all the other War Chiefs.

My Minions

My Uruk-Hai Minions

I had a full control of the local Orc society – all of the War Chiefs and captains were branded, and loyal to me. When I heard there was a new captain who rose to power on my turf, I quickly sent Lûga to challenge him. I dodn’t want him dead – I just wanted his eyes to glow blue. As I was branding the plucky upstart, I had a sudden epiphany: I was the new Dark Lord or Mordor. And it felt good. Almost too good. I presume that this is precisely how the Nine Kings fell and became Ringwraiths in the service of Sauron. Because they were offered the same kind of power.

In fact, I realized that perhaps my power was actually more sinister than than theirs. Both the Nine Kings and the game’s antagonists such as The Hammer of Sauron and The Tower ruled by fear and respect. Orcs followed them either because they dared not to refuse their orders, or because they looked up to them as strong leaders. But a disgruntled Uruk-Hai in their armies had options: he could walk away, challenge his superiors, plot revenge. My minions could not do that: my power over them was absolute. I don’t even know what books Lûga liked to read, because I was using him as a tool. He became a weapon in my arsenal without any agency of his own. He was an empty shell, forever bound to my will.

Tûmûg and me did not get along very well.

Tûmûg and me did not get along very well.

The Uruks of Mordor keep human slaves which is one of the many ways the game tries to justify the terrible violence and destruction you unleash upon them. But even though their bodies are bound and broken, the spirits of these slaves are free. As you explore the game world, you can often hear the slaves talk amongst each other: they tell stories filled with hope, they sing songs and sometimes even laugh. Orcs whom I branded can’t do any of that. They just stand there, their eyes glowing with the unearthly wraith energy. What I have done to them is a hundred times worse than what they have been doing to the humans. I have chained not their bodies but their minds. I became a monster: an absolute, irredeemable villain masquerading as a hero of the people. I have fallen lower than anyone in the Tolkien lore, and I did not even have a cursed ring to blame for my moral lapse.

You might be tempted to blame Celebrimbor for this, because it is his power that was used in branding, and he has been guiding your hands throughout the game. But while he is not necessarily a good guy, his ultimate goal was to strike a blow against Sauron, and put things right after his own greed and lust for power destroyed his own kingdom and put all of Middle Earth in peril. At the end of the game, he is ready to move on and leave the mortal realms behind. I thought this was a good thing. Both Celebrimbor and Talion would get their final rest, and all the Uruks who survived their reign of terror would be freed from under their influence. They would go back to doing whatever it is that Orcs do when they are not being lead to war by some dark power. But at the last minute Talion convinces Celebrimbor to stay and continue their partnership – you know, in case of a sequel. And that’s absolutely frightening.

It actually shows how little self-awareness the designers had when they crafted the games mechanics. At the very core, the game is very much an exploration of colonialism. Talion is a “civilized” outsider who finds himself among “barbarians” who he neither understands, nor respects. He sets out to disrupt and neutralize their power by coercing or assassinating their leaders to impose his own cultural and moral values onto those people. Mechanics reinforce this, but the story refuses to acknowledge these dark undertones and instead it pretends to be a heroic power fantasy. It is almost as if the story and the game mechanics were designed by two separate teams who did not communicate with each other – which seems to be a common trend in modern video games.

You can’t divorce game mechanics from the story any more than you can do with visuals and music. All of these parts contribute to the overall player experience, and all of them come together to tell a story. Shadow of Mordor is a great example of a really fun game in which the story and mechanics are at odds with each other. You can identify with Talion as a heroic figure only up until you actually realize the implications of the “branding” mechanic which becomes fairly important in the later game. An apt storyteller would try to capitalize on this, and depict Tallion’s inner struggle. But the hero never actually thinks about what he is doing to the Orcs. He hates them, and considers them inhuman monsters to be used as tools in his campaign against the Dark Lord… But you wanted to represent them as sub-human monsters, then why give them all names, goals, dreams and fears? The answer is obvious if you read the developer interviews. It is mechanics: engineered and designed completely separately from the story.

I want to give the writing team some credit for capturing the essence of Tolkien’s Uruk society, for crafting cool villains and aptly telling the story of Celebrimbor despite having to work against conflicting mechanics. But can I really do that? I mean, they did enough research to do deeply hook their story into Silmarilion lore, but not enough to comment on the Orks as subaltern people critiques of the text? The discussion about colonialism in Tolkien’s writing have been an academic staple for decades now – it’s not like we’re breaking a new ground here.

Perhaps this is a symptom of what I like to call a “professional fan fiction writer syndrome” – which is what happens when you tell a die-hard fan to write an adaptation of their favorite thing. They tend to be too close to the source material to step back and objectively look at the critique of the text, and thus unknowingly amplify the source works biases and problematic themes. So perhaps I could forgive them for being over-eager fans and trying really hard to do Tolkien justice.

But if I’m going to do that, then I also have to mention that their story would be ripe for Tropes vs. Women analysis. There are three female NPC’s in the game: first gets put in the fridge to provide motivation for the protagonist, second is remote controlled by Saruman and the third gets damseled and you literally have to carry her out of an Orc stronghold.

Litrhaiel

There is about 20 minutes of game play between the moment you meet the brave warrior Litrhaiel and the point where she gets super-damseled and you need to carry her to safety.

This is quite sad, especially seeing how that entire rescue mission was not only pointless but annoying from purely mechanical standpoint. It combined all the worst qualities of an escort mission while at the same time forcing you to move at an excruciatingly slow rate. I guess the writers really wanted to have a heroic moment for Talion to remind players he is not just a shadowy assassin and they figured the best way of doing so is to throw a woman under the train.

There is also that thing where your assassination tutorial consists of sneaking up on your wife to give her a surprise snog which is is weird and unsettling for a whole plethora of reasons.

Did I have fun though? Hell yes. Painting the Orc leader-board blue with my Wraith Flame was more satisfying than it had any right to be. The game actually helped me to find a whole new level of appreciation for Frodo and the temptation he must have felt while carrying the ring. I did not even have a ring, and I was having way to much fun being a pseudo-Ringwraith. The Nemesis system is really cool, and I hope that procedural NPC generation really catches on. I’m looking forward to seeing what other games will do with it.

That said, once I have killed or branded all the Orcs on the board, the game lost a little bit of it’s charm. The only thing left for me to do was to hunt for collectibles, do timed trial missions (bleh) or finish up the story. I wish I could have done more with my hordes of minions. All I really wanted was to be able to issue constructive orders. Like, how awesome would it be to order my underlings to free their slaves, to put Uruks to work repairing strongholds or rebuilding villages. If the game suddenly turned from revenge power fantasy into a city building simulator where you get to manage your armies, make sure they are fed, equipped, trained and have to resolve local disputes as an impartial judge, I would not mind at all.

In fact, I kinda wish the whole branding mechanic would not even be there. After all, Orcs follow strong leaders, no? So what if you could simply defeat an Orc leader in a duel and take his place as a leader? What if you could earn loyalty and gratitude of orcs by sparing their lives, helping them win a duel, or rescuing them from a Caragor. Wouldn’t that make more sense? Wouldn’t that remove at least some of the uneasiness that came from enslaving hordes of Uruks and using them as weapons?

Posted in video games | Tagged | 4 Comments