[Home]Hurd Console Tutorial

University Of Warwick Hurd User Group | RecentChanges | Login

02:18 < bing> there are a lot of consoles in the hurd.
02:19 < bing> one of 'em is the original console
02:19 < bing> it's basically a wrapper around mach.
02:19 < bing> but then marcus brinkmann created the `hurd console'
02:19 < bing> and it's fancy
02:19 < bing> it's a client/server sort of thing
02:19 < bing> where the console server, serves up consoles to users 
              who wish to read and write to them.
02:20 < bing>  /hurd/console is the console server
02:20 < bing>  /bin/console is the console client
02:20 < bing> the console server is a translator that sits on /dev/vcs
02:21 < bing> the console client is a program that talks to the 
              console server and shows you something that looks like 
              what you know as a virtual terminal.
02:21 < bing> and by default we get tty1, tty2 ... tty6.
02:21 < bing> this is because when you install the hurd, the 
              native-install script MAKEDEVs those ttys in /dev
02:21 < bing> showtrans /dev/tty1
02:22 < bing>  /hurd/term /dev/tty1 hurdio /dev/vcs/1/console
02:22 < bing> the tty1 node has a /hurd/term translator sitting on it
02:23 < bing> hurdio means it's talking to the console-server
02:23 < bing> that's console-server speak
02:23 < bing> alright, so how do we start the console-server?
02:23 < bing> well we don't!
02:24 < bing> it's a passive translator on /dev/vcs
02:24  * Casper_ gasps
02:24 < bing> it's just going when we boot
02:24 < bing> so how do we run the console-client?
02:24 < bing> well it's not as simple as running `console'.  we need 
              options.
02:25 < bing> we feed the console client `drivers' that it uses to 
              manage the input and output with the user.
02:26 < bing> we have drivers like:  ncursesw and vga
02:26 < bing> these are output drivers
02:26 < bing> but we also have pc_kbd and a bell one, i can't 
              remember the name of it.
02:26 < bing> to stat the console client in ncurses mode type:
02:26 < bing> console -d ncursesw /dev/vcs
02:27 < bing> the /dev/vcs tells the client what console server we're 
              talking to
02:27 < bing> as the console server is sitting there.
02:27 < bing> as the console server is sitting there.
02:27 < bing> when you do that, your screen turns black (if it wasn't 
              already)
02:28 < bing> and you see a login, and it says you're on tty1
02:28 < bing> hm, i'm not sure how to switch terminals in curses mode!
02:28 < bing> anyone?
02:29 < Casper_> I get a black screen with no login...
02:29 < bing> CTRL-w 2
02:29 < bing> CTRL-w 3
02:29 < FauxFaux> My install segfaults.
02:29 < bing> heehee
02:30 < bing> i'm using hurd 20050513-2
02:30 < bing> are you?
02:30 < Casper_> ii  hurd           20050513-2     The GNU Hurd
02:30 < bing> yikes, hde said the same thing.
02:31 < bing> hmm
02:31 < bing> Casper_: file a bug to azeem
02:31 < bing> anyway i'd like to get to the fun part!
02:32 < Casper_> Will do
02:32 < bing> CTRL-w x makes the console client in ncurses mode quit
02:33 < bing> alright, so what's the relationship between the ttys 
              and the consoles?
02:33 < bing> cd /dev/
02:33 < bing> MAKEDEV tty8
02:33 < bing> # showtrans tty8
02:33 < bing>  /hurd/term /dev/tty8 hurdio /dev/vcs/8/console
02:33 < carlopalma> Hi :)
02:33 < bing> but still our console server doesn't know about it.
02:34 < bing> # ls -l /dev/vcs
02:34 < bing> total 0
02:34 < bing> drwx------  1 root root 0 Jun  8 18:04 1
02:34 < bing> drwx------  1 root root 0 Jun  8 18:04 2
02:34 < bing> drwx------  1 root root 0 Jun  8 18:04 3
02:34 < bing> drwx------  1 root root 0 Jun  8 18:04 4
02:34 < bing> drwx------  1 root root 0 Jun  8 18:04 5
02:34 < bing> drwx------  1 root root 0 Jun  8 18:04 6
02:34 < bing> it's not there yet.
02:34 < bing> becaues nothing has connected to tty8
02:34 < bing>  /etc/ttys tells /libexec/runttys what program to run 
              on what tty
02:35 < bing> # echo "whatever" >> /dev/tty8
02:35 < bing> # ls -ld /dev/vcs/8
02:35 < bing> drwx------  1 root root 0 Jun  8 18:06 /dev/vcs/8
02:36 < bing> what has happened here?
02:36 < bing> the console-server automatically started serving a tty8!
02:36 < bing> we didn't tell it anything, all we did was make a new 
              tty, and then when a program did it's thing and tried 
              to use the tty, the console-server kicked in.
02:37 < bing> starting now the console-server knows about tty8
02:37 < bing> so if we start our console-client again and switch to 
              tty8, we should see what we echoed.
02:37 < bing> console -d ncursesw /dev/vcs
02:37 < bing> CTRL-w 8
02:38 < bing> heehee, it's making a fool of me.  CTRL-w 8 doesn't 
              work!
02:38 < bing> let me try with a vga console.
02:40 < bing> ok
02:40 < bing> cat /dev/tty8
02:40 < bing> ^Z
02:40 < bing> bg
02:40 < bing> echo "whateveragain" >> /dev/tty8
02:40 < bing> then start the console in vga mode
02:40 < bing> console -d vga -d pc_kbd /dev/vcs
02:41 < bing> CTRL-F8
02:41 < bing> and then you see "whateveragain"
02:41 < bing> the key thing here is that /dev/vcs/8 goes away when 
              nothing is using the tty8 anymore
02:41 < bing> so our echo only made /dev/vcs/8 exist for a short 
              period of time
02:42 < bing> by backgrounding the cat, we keep it open.
02:42 < bing> we can only write to the tty because we have permission 
              to.
02:42 < bing> now, let's say we wanted to start another tty with a 
              getty on it.
02:42 < bing> this is where /etc/ttys comes in.
02:43 < bing> tty1    "/libexec/getty 38400"          hurd            
              on      secure trusted console
02:43 < bing> that's a typical line

02:43 < bing> so you just make a new one that's just like tty1, but 
              it has tty8
02:43 < bing> but first be sure to kill that cat we had going :-)
02:43 < bing> and now we have to make runttys do it's thing again.
02:44 < bing> iirc, we just SIGHUP /libexec/runttys
02:44 < bing> debian:/dev/vcs# ps -ef | grep "run"
02:44 < bing>     root     6     1   -  0:00.01 /bin/bash 
              /libexec/runsystem /boot/gnumach.gz
02:44 < bing>     root    59     6   -  0:00.01 /libexec/runttys
02:44 < bing>     root   349   314  p0  0:00.00 grep run
02:44 < bing> either that or runsystem. heh
02:44 < bing> let's try
02:44 < bing> # kill -HUP 59
02:45 < bing> and voila!
02:45 < bing> tty8 now has a login
02:45 < bing> :-)
02:45 < bing> come on now, who isn't impressed by THAT?
02:46  * Casper_ applauds loudly
02:46 < bing> so you can use this process to make ttys on the fly in 
              the hurd.
02:46 < bing> i have no idea if that's possible in linux
02:46 < bing> lol
02:46 < bing> could be
02:46 < bing> it's interesting to note that tty8, had a login 
              showing...
02:46 < bing> but it also still had our "whateveragain" showing
02:47 < bing> any questions other than -- why does my computer 
              completely crap out when i try to run console client?
02:47 < bing> :-)
02:48 < Casper_> When you log in using login, what is the difference 
                 between the different login methods it proposes?
02:48 < bing> Casper_: oh
02:48 < bing> well login has a lot of options
02:49 < bing> Casper_: you're referring to ql and su?
02:49 < Casper_> Yes
02:49 < bing> well
02:49 < bing> this has to do with effective user-ids
02:49 < bing> and not the console :-)
02:50 < bing> first of all try looking at login --help
02:50 < bing> there are a lot of ways to login
02:50 < bing> and logging in is a way of gaining credentials in the 
              hurd
02:50 < bing> to see what credentials you have, you type:
02:50 < bing> ids
02:51 < bing> guest@debian:~$ ids
02:51 < bing> effective uids: 1000(guest)
02:51 < bing> effective gids: 1000(guest)
02:51 < bing> available uids: 1000(guest) 1000(guest)
02:51 < bing> available gids: 1000(guest) 1000(guest)
02:51 < bing> so
02:51 < bing> if i were to interpret what the login shell is telling 
              me:
02:52 < bing> ql starts a shell in the user's home directory but 
              doesn't change his environment.  that's my guess.
02:52 < bing> let's test that
02:52 < bing> nope
02:52 < bing> heh
02:53 < bing> env was different
02:53 < bing> and ids was as if i fully logged in
02:53 < bing> ql is an alias i believe
02:53 < bing> ah right
02:53 < bing> # quick login -- don't act like a login shell, but do 
              cd to $HOME
02:53 < bing> alias ql='exec login -pSL -aMOTD -R-p -R-aHOME -R-aMOTD 
              -R-e_LOGIN_RETRY=yes'
02:54 < bing> so it runs login with a particular set of options
02:54 < bing> these options are presumably somehow different from the 
              normal `login'
02:54 < bing> :-)
02:54 < bing> # login -- a normal login
02:54 < bing> alias login='exec login -p -R-p -R-aHOME -R-aMOTD 
              -R-e_LOGIN_RETRY=yes'
02:54 < Casper_> OK. What other interesting modes and uses does the 
                 Hurd console have? Can different users replace their 
                 ttys?
02:55 < bing> one interesting thing you can do is get your ttys 
              remotely!
02:55 < bing> try ssh'ing into your home hurd box, and then kill the 
              console client that's already running
02:55 < bing> then start up the ncursesw console client
02:56 < bing> whoosh!  there's your screens.
02:56 < bing> you don't have to be at home to see what's happening on 
              tty8
02:56 < bing> i believe you have to kill the console-client because 
              there are sharing issues.  maybe not though :-)
02:56 < Casper_> I will, but I've been having slight problems with ps 
                 recently, so can't see what processes are running...
02:56 < bing> i'll leave it to somebody here to try.
02:57 < bing> it sounds like you guys could have better hurd installs.
02:57 < bing> i used crosshurd
02:57 < Casper_> me too :)
02:57 < bing> and i apt-get upgrade whenever i can
02:57 < Casper_> Yep, I did that today :)
02:58 < bing> Casper_: if ps fails, then i suspect that the proc 
              server isn't doing what it should
02:58 < Casper_> it's quite stable
02:58 < Casper_> uptime
02:58 < Casper_>  3:05:15 AM  up 3.4 weeks,  5 users,  load averages: 
                 0.23, 0.08, 0.04
02:58 < bing> yeah i've noticed a definite increase in stability
02:58 < Casper_> Can I restart proc on the fly?
02:59 < bing> guest@debian:~$ ps -ef | grep "proc"
02:59 < bing>     root     0     1   ?  0:00.76 /hurd/proc
02:59 < bing>    guest   387   168  p0  0:00.00 grep proc
02:59 < bing> pid 0 is a scary thing
03:00 < bing> Casper_: i doubt that your hurd would work at all 
              without it
03:00 < bing> i wouldn't send a HUP signal to my proc server on a bet
03:01 < Casper_> But surely one of the advantages of having a 
                 microkernel is the ability to restart parts of the 
                 OS when they break?
03:01 < bing> sure
03:01 < bing> you can start a subhurd
03:01 < bing> or a neighbourhurd
03:01 < bing> (the same thing)
03:01 < bing> that's definitely for another tutorial though
03:01 < Casper_> Can I then migrate all processes across and then 
                 shut off the old-hurd?
03:02 < bing> heh
03:02 < bing> these are questions that are out of my league
03:02 < Casper_> OK! :)
03:02 < bing> but i'll try to kill my proc server and bring it back
03:02 < bing> what the hey
03:02 < bing> it's time to see the hurd crash :-)
03:02 < bing> hahah
03:02 < bing> kill -QUIT 0
03:02 < bing> ps -ef | grep "proc"
03:02 < bing> hangs
03:02 < bing> :-)
03:03 < bing> now i should just have to run /hurd/proc
03:04 < bing> but i can't run it because i don't have a proc server i 
              think
03:04 < bing> maybe i should've hupped it :-)
03:04 < Casper_> I'll try that :)
03:04 < bing> it'll likely bring down your system
03:04 < bing> hang on while i look at the code for proc
03:05 < Casper_> # kill -HUP 0
03:05 < bing> well it does SOMETHING on hup, i know that much
03:05 < Casper_> closed ssh session
03:05 < Casper_> I sshed back in
03:05 < Casper_> nothing changed (uptime still large, ps still hangs)
03:06 < bing> hmm, actually proc is sending sighups
03:06 -!- rcon [~rcon@fctnnbsch17-156034218131.nb.aliant.net] has 
          joined #console
03:07 < bing> sorry Casper_, i can't answer your question :-)
03:07 < bing> any other crazy questions? lol
03:07 < bing> the console can do utf-8
03:07 < Casper_> Is the mouse translation done by the console also?
03:07 < bing> which is unicode
03:08 < bing> ah
03:08 < Casper_> (do the unicode to!)
03:08 < Casper_> *too
03:08 < bing> mouse support is not supported in the console
03:08 < bing> but it DOES support the idea of repeaters
03:08 < bing> this way we use the console to make X work
03:09 < bing> i don't have a hurd anymore to show you this. lol
03:09 < Casper_> Sorry! :-/
03:09 -!- rcon [~rcon@fctnnbsch17-156034218131.nb.aliant.net] has 
          quit ["Goodnight"]
03:09 < bing> someday somebody will write cut-and-paste for the hurd 
              console
03:09 < bing> and mouse will be involved with that
03:10 < bing> so yes the console knows about mouse, but it doesn't 
              give you gpm-like functionality
03:10 < bing> yet
03:10 < bing> the unicode console is fairly cool
03:10 < bing> to me, all it means is that i can see those crazy 
              chinese characters or russian characters
03:11 < bing> so that's kinda cool
03:11  * Casper_ thinks matrix screensaver
03:11 < bing> any more questions?
03:11 < bing> ahh
03:11 < bing> console screensavers!
03:11 < bing> you can make console screensavers now
03:12 < bing> they can be drivers to the console clients
03:12 < bing> :-)
03:12 < bing> cool eh?
03:12 < Casper_> Yes, that sounds interesting! :)
03:12 < bing> have you ever seen a linux machine with a console 
              screen saver?
03:12 < Casper_> Yes
03:12 < Casper_> :P
03:12 < bing> pfft, but you don't NEED a console screensaver. lol
03:12 < bing> it's just a neat technology
03:12 < bing> however, there was some support for blanking i believe.
03:12 < bing> marco_g knows about this.
03:13 < bing> so yes, one of you could make a matrix screensaver for 
              the hurd console
03:13 < FauxFaux> I could, if only it'd boot :(
03:13 < bing> FauxFaux: lol
03:13 < Casper_> Where would one start if they wanted to?
03:13 < bing> Casper_: i'd start by asking marco_g, and he'd tell you 
              to look at the code
03:14 < bing> :-)
03:14 < Casper_> hehe :-)
03:14 < bing> FauxFaux: have you tried the live-cd?
03:14 < bing> FauxFaux: that will tell you if your hardware is 
              supported.  eg. nic
03:14 < FauxFaux> Hmm, no. Anyone have the url?
03:14 < bing> www.superunprivileged/hurd/live-cd
03:14 < bing> but you can't install from it or anything
03:14 < Casper_> Diocles distributed at Hug meeting last week...
03:15  * FauxFaux has ~8 year old netgear card of win.
03:15 < bing> i used crosshurd for my install and it works fine until 
              i kill the proc server
03:15 < Casper_> hahahaha
03:15 < bing> i don't know how to account for the problems you all 
              are having
03:15 < FauxFaux> Thanks bing.
03:16 < bing> typically you try it on various hardware and it 
              eventually works
03:16 < bing> then you treat that machine like gold :-)
03:16 < bing> FauxFaux: of win?
03:16 < Casper_> bing: so the problems we have are hardware-specific?
03:16 < bing> Casper_: i have noooo idea :-)
03:17 < Casper_> bing: re FauxFaux: "of win" = warwick compsoc speek 
                 for "is fun to use"
03:17 < bing> heh
03:17 < bing> scary
03:17 < bing> any more questions i can't answer?
03:18 < Casper_> LOL
03:18 < bing> anyway, the hurd console is cool
03:18 < bing> i hope you all can try it out sometime
03:18 < bing> nite!

University Of Warwick Hurd User Group | RecentChanges | Login
Login to edit | View other revisions | Search MetaWiki
Last edited June 9, 2005 11:41 am by TimRetout (diff)
Search: