Saturday, September 15, 2012

systemd, getty spawning and kernel messages interference/configuration

Update:
At least Arch now uses a new xserverrc that uses the XDG_VTNR environment variable to set the VT for X to use. To properly set it, put XDG_VTNR=X X being again the number of the VT to spawn X at in ~/.pam_environment.

Original Post:
Hello, World! It's me again!
You can thank a fellow student of mine, moertarguy, for this post. He wanted to keep a reference to the instructions that will follow and thus suggested making a blogpost.

I've recently switched to systemd on my Arch installation. At least on my netbook, I still need to copy over these changes to my laptop (amongst some other configuration I've been planning to carry over as well).

I don't use a graphical boot, so I get a bunch of messages during the boot process. And I don't use a graphical login manager, so once the boot is complete and getty spawns, it will erase the messages and present a (textual) login screen. And sometimes, some messages will be printed in between the login-lines - not a pretty sight.


Before with Archs initscripts I simply had no getty spawn on tty1. Once the gettys spawned and I've switched to tty2, no additional messages would be printed, so no problems there.

Well, I could just setup systemd like this as well, but systemd offers a nice feature to spawn gettys only when they are required, i.e. you switch to that tty the first time. You can not control specific ttys with that however, only tty1-X. You can set that X in /etc/systemd/logind.conf.
Stopping a getty to spawn at tty1 is fairly easy: mv /etc/systemd/system/getty.target.wants/getty@tty{1,2}.service
(or alternatively: systemctl disable getty@tty1.service && systemctl enable getty@tty2.service)

When you reboot now, you will notice that after the boot sequence is done, you get no getty. You need to manually switch to tty2. I did this before with initscripts as well, but I found a way to automate this: chvt. So let's write a systemd service file!
Paste this in /etc/systemd/system/chvt@.service:
[Unit]
Description=Switch to tty%I
#After=getty@tty%I.service

[Service]
Type=oneshot
ExecStart=/usr/bin/chvt %I

[Install]
WantedBy=getty.target


That commented #After line there is purely for your preference. It might make sense to you, but I though I would keep this service-file from launching a getty as well and let some other service take care of doing whatever it deems necessary.
Now just enable it to switch to tty2: systemctl reload-daemons && systemctl enable chvt@2.service

If you reboot now, it'll automatically switch to tty2 for you. But some messages might now be printed between the login-lines. To fix this, append console=tty1 to your kernel parameters in grub.cfg or syslinux.cfg or whatever. By default this is tty0, which corresponds to the currently active tty.

Are we done here? Almost. If you start X, X will, without further configuration, start on tty1. If you want to leave tty1 alone to be able to review the messages there even while X is running you will want to modify that behavior.
For this, edit /etc/X11/xinit/xserverrc and insert vtX to the exec-command just before "$@" with X being the number where you want X to spawn. You will still be able to explicitly specify another vt-parameter to spawn X in with startx/xinit.


Now you're done.
You could also keep getty on tty1 and direct kernel output to some other tty though. Well, now you know how to do that as well!
Keep on kickin'!

Wednesday, November 16, 2011

C and C++ introductory lecture rant

Alright, as announced a small rant about the course I had.

These were two lectures as part of a larger course. One a small C introduction and a follow up for a small C++ introduction, 90 minutes each.
It was annoying for me to listen to it. If my brain had the capability of throwing up, it would have.


To start out, I'm (usually) not an elitist, though I am a standard fetishist. I'm okay with using system-libraries, but I try to keep that to a minimum if reasonable.
I'm not a fan of libraries that are not cross-platform either, but each to their own.

First up, they've announced the C introduction would use some C++ elements, so we should use the cpp extension and compile with g++ (they were also kinda mixing up gcc with g++ and saying that modern C compilers would gladly compile some C++ elements).
The reason for this turned out to be just the bool type (which would be available as _Bool (or typedef'd in stdbool.h) in c99), references (C++-style, not pointers - though they've of course been mentioned as well) and function overloading.
Completely unnecessary.

There were some errors concerning the the sizeof operator (called a function) applied to arrays. Arrays decaying to pointers are ugly, though it was never clearly mentioned.
I would have mentioned that there's some ugly stuff where arrays may decay into pointers, though would have advised to look on the internet for self study if there was further curiosity.

The lecturer did not seem to know much about this himself, so the questions asked by the audience were not answered satisfactorily.


So let's go on to the C++ introduction. There were mistakes concerning the OOP and it was apparent that they've bitten of a byte (ha-ha) more than they can chew. I did not understand why there's the need of introducing TMP or some new C++11 features.
Yes, they're very sweet, but for a 90 minute introduction they should have taken a bit more time on making a conscious choice about the subset to show, since this one was really lacking.
They've also showed the std::vector as an example of the usefulness of the STL (a very fitting example with a vector of vectors °_^).

I didn't listen to the lecture too well, so I don't have as much to tell about it.


I've also had an apparently decent introduction to assembly in this same course (spanned over a (much) longer time than 90 minutes, dunno how much though) - the only 'mistake' was using AT&T/GAS syntax (<- that's a link to a comparison table) instead of Intel (which I've learned a bit before - but that's just my opinion). The reason might be for using inline assembler in gcc, although I'm pretty sure you can toggle that behavior.

We've been instructed on how to use the FPU and SSE instructions, which I did not know how to do before, so I'm happy about it. I've also gotten some more practice using assembly; I'm happy with that too.


So let's move on with our continuing mission: To explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before.

Time, text-mode, cold, stuff

This semester I've been kept quite busy. The courses are not harder than last year, but for some reason they seem to eat more time.
The Red Cross also had some chores in store for me.

I have not had much time to work on personal projects, though I've customized my start-up a little with a small script I am planning to extend a bit; right now it's asking me if it should start openbox and/or wicd (I've been recommended to use just wpa_supplicant instead; I'll take a look).
I've been working some more in text-mode. If you know of a good way to view PDF-files in the terminal, leave a comment; I'd appreciate it.
Right now, fbgs seems the only option. I'm looking at a pdf2html tool next; the text-browser of my choice is ELinks.

My preferred text-editor was nano, though I've learned to handle some basic Vim recently. I'm more accustomed to it already than when I tried to get into Emacs.


I've been sick two weeks ago and still had to do a long paramedical shift due to the little numbers of helping hands and then some volleyball matches, where I've heard some people had already jumped the boat so I didn't want to back out as well, the day after.
Since the temperatures outside have been dropping recently I felt very relieved after I got home, drank a hot tea and lied down in my bed.

The cold went mostly away during the week, I cough seldom and need to blow my nose a few times a day, but I'm feeling quite well again.


Next post - soon to come - is a small rant about a course I had.
Until then, keep yourselves out of trouble! Bye~

Saturday, October 1, 2011

Archlinux

My first experience with Archlinux is ... good. I have the feeling of having a bit more control over my system and I think the startup is a bit faster than my previous Fedora setup.

I knew I would only get a bare base-system after the install, but what I did not expect is that tools like sudo and locate are not part of it.

Pacman is awesome. It's incredibly fast; after using yum a real blessing ;D
It's also faster than apt-get/aptitude.



I already broke my WLAN once after updating Arch, because a bunch of WLAN modules were seemingly randomly blacklisted. Apart from that it's been running smoothly.

I now have Openbox as my WM and actually DE. I use tint2 for my task bar (it's pretty) and a handy, id tech-like drop-down terminal called guake.

I already blogged about my browser choice.


And I guess there's not really much else to say about it. The AUR is cool. The packages are bleeding edge. I love the rolling release. That is all.

Saturday, September 24, 2011

A short, short time ago,

at pretty much this exact same place (relative to the earth) I wrote a blogpost in which I promised a follow up.
Guess what.

I left off saying something about a Co-Op mod for Half-Life 2. So here's the story:


A friend of mine was looking for someone to play the Portal 2 Co-Op with. I still had Fedora at that time, planned to change to Arch, already got Portal 2, though unplayed.
So I thought I can install Windows and Arch, install Steam play Portal and then play the Co-Op with my friend and give the Windows-partition back to Arch afterwards.

So I did and in the process downloaded a couple of mods I wanted to re-play or look how far they've gotten.
Obsidian Conflict is one of them.


While playing it on a server a dev joined, who said that my name sounds familiar and he just implemented and tested my ironsight code.
I found that pretty cool and just asked if they're looking to fill a coder-position in their team, though I won't know how much time I can spend.
Guess what happened.


Thus I am keeping Windows around.

And I'll give a shout out to OccupationCS: Source. Note that the dependency on CS:S is planned to be removed soon.
It's a mod that adds realistic bullet simulation to a Source multiplayer setting. You can also choose different ammo, which results in different performance of course. It also added a more complex health-system.

While it generally aims for realism I don't think the fun gets left out. If you have a Source-game, check this mod out! I love it and the potential it has.

Right now you probably won't find any servers, but the bots are okay to play against until the official server is back up.


Okay. So far so good.
I think I'll do another small blogpost saying a few words about my experiences with Arch Linux so far.
Sayonara

Wednesday, September 21, 2011

A long, long time ago,

at pretty much this exact same place (relative to the earth) I wrote a bunch of blogposts somewhat regularly.

I've already explained that I found less time to blog stuff and just didn't have much to blog about.
While I don't expect to be writing many blogposts now, I do have some stuff to write about and I just got motivated to make a post.


Fedora was replaced by Arch Linux.
Why? Because I wanted to learn a bit more about Linux and I did. No where near a Linux-guru - far from it - but I learned some interesting stuff.
I want to try LFS in a VM at some point.


I've gotten myself a Netbook. Also runs Arch Linux, of course.
I was looking for one with just a long battery lifetime and fairly cheap. Didn't care much about the other specs.

I've been using Midori instead of my usually used browser, Chromium, on there. But it had the tendency to hang and if I opened it myself and then would click on a link in my instant messenger, it'd complain about not being shutdown correctly and open a new window.
So now I'm also using Chromium on there.


I'm now (actually became about 8 months ago) treasurer of our local Red Cross club, woot. Actually it's not great, but I did get some interesting insights.
I'm gonna try it a bit longer to see if I'll stick with it. Right now I'm doubtful.


And I've became coder of the Obsidian Conflict mod, a Co-op mod for Half-life 2 (and its sequels).
Apart from the Singleplayer maps the mod also features many custom maps, some with a traditional FPS style (shoot all enemies, progress, repeat), some with an additional twist (e.g. for each kill you get money, so you can buy larger weapons or other utilities like turrets or mines to overcome the next, bigger wave of enemies) and some with a completely different gameplay.

I must say that I am lazy though. I hope that I can get my ass back up and get some things done.

Since Half-Life 2 is not a Linux native game, you might ask how that came to be. I will (hopefully) answer that in my next blogpost, which I hope to make this or next week.
I just don't wanna blow this one up too much.


So long.

Sunday, June 12, 2011

Welp,

More than a month, no blog post.

Not much to say, not much happened to me.

Almost all of my programming time was for university stuff, all the rest was code snippets on a programming forum.
I've been jogging more, but my legs don't seem to like it much and hurt sometimes - not like a muscle ache though, it's something different. I hope it'll go away if I do more stretching exercises.

I've been pondering to buy a Netbook with a long battery life, something like a Asus 1005P. I'll wait a little more though, since I don't actually have a need for it; it'd be nicer than my current laptop for the university though.


Don't expect another update soon. I don't suspect anything interesting, that I'd wanna tell the world, happening to me in a while.