Add TTYs in Fedora 9+, Plus More!As extra credit in my Intro to Linux class, I gave a problem that used to be simple but is now (since Fedora 9) slightly more difficult. As an in class assignment, one of the parts was to learn how to switch between text consoles. Once that was learned, the students then had to make a new text console, preferably tty8 since that isn't used by default. The book detailed how to do this by simply adding a line in /etc/inittab. That, however, doesn't work anymore because mostly everything has been moved out of /etc/inittab into their own files. So, once the students hit this point, a barrage of questions flew at me.
I walked over to a student's computer to see what error he was receiving and then proceeded back to my computer. I told them to skip taht part and I would quickly figure it out and tell them what file they needed to edit. Fat chance. I spent about 5 minutes trying to figure out how to add another TTY all while talking them through what I was doing: restarting init, checking the log, cross-referencing errors on the Internet, etc. I'm not the type of professor who will waste the students' time (I know I hated that when I took classes), so I gave them some options. Either they could forget about this part of the assignment and not lose any points, or they could figure out how to add tty8 before the final exam and earn extra credit.
No one bit. So now that the final is over, here's the solution. TTYs are no longer configured in /etc/inittab, they each have their own configuration file located in /etc/event.d.
[root@localhost event.d]# ls control-alt-delete rc0 rc3 rc6 serial tty2 tty5 logd rc1 rc4 rcS sulogin tty3 tty6 prefdm rc2 rc5 rcS-sulogin tty1 tty4So first, let's check out what one of the existing, working TTY files look like:
[root@localhost event.d]# cat tty6 # tty6 - getty # # This service maintains a getty on tty6 from the point the system is # started until it is shut down again. start on stopped rc2 start on stopped rc3 start on stopped rc4 start on started prefdm stop on runlevel 0 stop on runlevel 1 stop on runlevel 6 respawn exec /sbin/mingetty tty6Simple enough. We want our new TTY to be available at all of the same run levels as tty6, so let's just copy that file and replace all occurrences of 'tty6' with 'tty8'.
[root@localhost event.d]# cat tty8 # tty8 - getty # # This service maintains a getty on tty8 from the point the system is # started until it is shut down again. start on stopped rc2 start on stopped rc3 start on stopped rc4 start on started prefdm stop on runlevel 0 stop on runlevel 1 stop on runlevel 6 respawn exec /sbin/mingetty tty8Now here's the stumper. Even if we go as far as rebooting, we still won't have our TTY. If you check the log, you'll see a somewhat vague error message:
Nov 5 19:31:53 localhost /sbin/mingetty: tty8: no controlling tty: Operation not permittedWhat does that mean? My first instinct went back to the first thing people learn about *nix and also the hardest thing to understand: everything is a file. TTYs are just files in /dev, I wonder if tty8 actually exists.
[root@localhost dev]# ls | grep tty8 tty8Crap, it's there. Ok, this may be harder than I originally thought. My next thought was the one that set me on the right path. I figured, if there is something that has to be configured about a TTY, then it must be in some configuration file somewhere. So, tty6 is already working, let's see if it shows up in any configuration files:
[root@localhost etc]# grep -irn tty6 * . . <SNIPPED> . . udev/makedev.d/50-udev.nodes:7:tty6Among other places that don't seem so useful, it seems that tty6 shows up in /etc/udev/makedev.d/50-udev.nodes, so let's take a look there and see what we find:
[root@localhost makedev.d]# head 50-udev.nodes # These device have to be created manually tty1 tty2 tty3 tty4 tty5 tty6 loop0 loop1 loop2A ha! Now we're cookin'. It appears that all TTYs that actually work are listed in this file. Apparently having a file in /dev wasn't enough, the udev process also has to create a node for it; and if it isn't listed in this file, it doesn't get created. So let's add 'tty8' to this file and see what happens.
[root@localhost makedev.d]# head 50-udev.nodes # These device have to be created manually tty1 tty2 tty3 tty4 tty5 tty6 tty8 loop0 loop1I rebooted the machine just to be on the safe side, but you could just also just have init reread it's config. Voila! Upon pressing CTRL+ALT+F8 we can see that our new TTY works.
As promised, here some other tidbits that I came across recently that will hopefully help some people.
- To use a cross-domain web service through AJAX you need to (for the easiest way) enable mod_proxy in Apache and set two rules:
ProxyPass /ws/ http://domain.com/path/to/webservice/
ProxyPassReverse /ws/ http://domain.com/path/to/webservice/
Then you can call it via http://localhost/ws/ServiceName
- You can't count on AJAX to complete requests in a specific order. Instead, change the call to be synchronous (false) via xmlHttp.open("GET", url, false). Then comment out the onreadystatechange call and move the code in the referenced function to directly below the xmlHttp.send call.
- While playing a song on the iPhone, tap the album art to reveal the time bar, shuffle button, and repeat button.