From f4cef8f2cd3c61e50c72bdc770c8d4f4a6c20563 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 7 Nov 2016 00:46:26 +0100 Subject: Update the subhurd howto. --- hurd/subhurd.mdwn | 68 ++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 39 deletions(-) (limited to 'hurd/subhurd.mdwn') diff --git a/hurd/subhurd.mdwn b/hurd/subhurd.mdwn index e50ea0d5..13756339 100644 --- a/hurd/subhurd.mdwn +++ b/hurd/subhurd.mdwn @@ -19,7 +19,8 @@ attach to them with gdb from the parent when the instance of gdb stops the server but requires its use. (Note: it is possible to use [[debugging/gdb/noninvasive_debugging]], but this is less flexible.) Vice versa, it is also possible to use a subhurd to debug the -*main* Hurd system, for example, the latter's root file system. +*main* Hurd system, for example, the latter's root file system, but that +requires a privileged subhurd. [[!toc levels=2]] @@ -60,53 +61,40 @@ run the `native-install` step from a chroot or already in a subhurd.) ## Booting -To boot the subhurd, you need a boot script. For historical reasons, usually -`/boot/servers.boot` is used. (Originally, this was also used to boot the main -Hurd, using "serverboot". Nowadays, this isn't used for the main boot anymore, -as GRUB can directly load all the necessary modules.) +If you are using a recent version of the Hurd (>= 0.9), then you can +simply boot the subhurd as an unprivileged user by issuing -However, the canonical `/boot/servers.boot` file is no longer distributed with -[[Debian_GNU/Hurd|running/debian]]. Here is a slightly adopted version: - - # Boot script file for booting GNU Hurd. Each line specifies a file to be - # loaded by the boot loader (the first word), and actions to be done with it. - - # First, the bootstrap filesystem. It needs several ports as arguments, - # as well as the user flags from the boot loader. - /hurd/ext2fs.static --bootflags=${boot-args} --host-priv-port=${host-port} --device-master-port=${device-port} --exec-server-task=${exec-task} -Tdevice ${root-device} $(task-create) $(task-resume) - - # Now the exec server; to load the dynamically-linked exec server program, - # we have the boot loader in fact load and run ld.so, which in turn - # loads and runs /hurd/exec. This task is created, and its task port saved - # in ${exec-task} to be passed to the fs above, but it is left suspended; - # the fs will resume the exec task once it is ready. - /lib/ld.so.1 /hurd/exec $(exec-task=task-create) - - ## default pager - #/dev/sd0b $(add-paging-file) - -/!\ It's very important not to introduce spurious line breaks, so be very -careful when copying! All the options following `ext2fs.static` have to be on -a single line. - -Now actually booting the subhurd is a simple matter of issuing (as root): - - boot servers.boot /dev/hd0s6 + boot /dev/hd0s6 (Replace `hd0s6` by the name of your partition for the subhurd.) /!\ The partition must be unmounted (or mounted read-only) before you boot from it! -(In theory it shouldn't be neccessary to run the subhurd as user `root`, but in -practice [that doesn't work at the -moment](http://savannah.gnu.org/bugs/?17341).) +## Networking You can provide the subhurd with a network card by passing a `-f` option to `boot`. For instance, if you have a second network card `/dev/eth1` in your host hurd, pass `-f eth0=/dev/eth1` to make it appear as device eth0 in the subhurd. +If you don't have a second network card, you can setup the eth-multiplexer +to share one network card. To do so, install the multiplexer + + settrans /dev/eth0m /hurd/eth-multiplexer --interface=/dev/eth0 + +Then configure your main Hurd system to use a virtual network +interface (e.g. `/dev/eth0m/0`) instead. On Debian/Hurd, this can be +accomplished using + + ifdown /dev/eth0 + sed -i -e s#/dev/eth0#/dev/eth0m/0# /etc/network/interfaces + ifup /dev/eth0m/0 + +You can now pass `-f eth0=/dev/eth0m/1` to `boot`. + +## Booting and shutting down + Now the subhurd should boot just like a normal Hurd started directly from GRUB, finally presenting a login prompt. The `boot` program serves as proxy for the subhurd, so you can control it from the terminal where you issued the boot @@ -114,9 +102,9 @@ command. To exit the subhurd, issue `halt` or `reboot`. This should exit it cleanly, but for some reason it doesn't always work; sometimes it will output various -errors and then hang. If that happens, you need to kill the subhurd processes -manually from a different terminal. - +errors and then hang. If that happens, you need to kill the `boot` process +manually from a different terminal. If the `boot` process dies, the +proc server will kill all tasks belonging to the Subhurd. ## Using @@ -132,7 +120,7 @@ If you want to access the subhurd processes from the outside, e.g. for [[debugging_purposes|debugging/subhurd]] (or to get rid of a subhurd that didn't exit cleanly...), you need to find out how main Hurd [[PID]]s correspond to subhurd processes: the subhurd processes appear in the main Hurd (e.g. if doing -`ps -e`) as unknown processes, and vice versa, but the [[PID]]s are different! To +`ps -e`) as unknown processes, but the [[PID]]s are different! To find out which process is which, you can simply compare the order -- while the numbers are different, the order should usually match. Often it also helps to look at the number of threads (e.g. using `ps -l`), as many servers have very @@ -510,6 +498,8 @@ Roland's tutorial about [[running_a_subhurd]]. ## Debugging the *Main* Hurd System +Note: This only works with privileged subhurds. + A subhurd can be used for debugging the *main* Hurd system. This works as long as the subhurd doesn't use any services provided by the main Hurd. For example, if you already have a subhurd running at the time it happens, you can -- cgit v1.2.3 From 005d86e6a9561d9eaae8705e3207bd1b6332ba54 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 20 Nov 2016 19:59:22 +0100 Subject: create /dev/eth0m if needed --- hurd/subhurd.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hurd/subhurd.mdwn') diff --git a/hurd/subhurd.mdwn b/hurd/subhurd.mdwn index 13756339..78aa20ec 100644 --- a/hurd/subhurd.mdwn +++ b/hurd/subhurd.mdwn @@ -81,7 +81,7 @@ subhurd. If you don't have a second network card, you can setup the eth-multiplexer to share one network card. To do so, install the multiplexer - settrans /dev/eth0m /hurd/eth-multiplexer --interface=/dev/eth0 + settrans -c /dev/eth0m /hurd/eth-multiplexer --interface=/dev/eth0 Then configure your main Hurd system to use a virtual network interface (e.g. `/dev/eth0m/0`) instead. On Debian/Hurd, this can be -- cgit v1.2.3 From 7d5e7a5b5f84269081bc2d257c0d1cc144babf24 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 20 Nov 2016 23:04:04 +0100 Subject: Document using debootstrap instead of crosshurd --- hurd/subhurd.mdwn | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'hurd/subhurd.mdwn') diff --git a/hurd/subhurd.mdwn b/hurd/subhurd.mdwn index 78aa20ec..859be377 100644 --- a/hurd/subhurd.mdwn +++ b/hurd/subhurd.mdwn @@ -38,10 +38,11 @@ The system for the subhurd is a normal Hurd installation, which could just as well run standalone. You can use any of the various possible installation methods, or reuse an existing installation if you already have several. If using [[Debian_GNU/Hurd|running/debian]], the easiest is probably to use -[[running/debian/crosshurd]], which you can run directly from your main Hurd to -set up another Hurd on a different partition, without ever rebooting. (You can -run the `native-install` step from a chroot or already in a subhurd.) +debootstrap as root: + mke2fs /dev/hd3s4 + settrans -ca mnt /hurd/ext2fs /dev/hd3s4 + debootstrap sid mnt/ http://httpredir.debian.org/debian ### IRC, freenode, #hurd, 2013-09-15 @@ -66,7 +67,7 @@ simply boot the subhurd as an unprivileged user by issuing boot /dev/hd0s6 -(Replace `hd0s6` by the name of your partition for the subhurd.) +(Replace `hd0s6` by the name of your partition or backing file for the subhurd.) /!\ The partition must be unmounted (or mounted read-only) before you boot from it! -- cgit v1.2.3 From 835b2a7da15bc268365fc78f61acf894f4327428 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 20 Nov 2016 23:07:31 +0100 Subject: use coherent partition names --- hurd/subhurd.mdwn | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'hurd/subhurd.mdwn') diff --git a/hurd/subhurd.mdwn b/hurd/subhurd.mdwn index 859be377..820e493f 100644 --- a/hurd/subhurd.mdwn +++ b/hurd/subhurd.mdwn @@ -40,9 +40,10 @@ methods, or reuse an existing installation if you already have several. If using [[Debian_GNU/Hurd|running/debian]], the easiest is probably to use debootstrap as root: - mke2fs /dev/hd3s4 - settrans -ca mnt /hurd/ext2fs /dev/hd3s4 + mke2fs /dev/hd0s6 + settrans -ca mnt /hurd/ext2fs /dev/hd0s6 debootstrap sid mnt/ http://httpredir.debian.org/debian + settrans -ga mnt ### IRC, freenode, #hurd, 2013-09-15 -- cgit v1.2.3 From 25f0dafbf8e506da8adf93be324409c42119cd04 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 20 Nov 2016 23:13:21 +0100 Subject: there are sometimes remnants after debootstrap --- hurd/subhurd.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hurd/subhurd.mdwn') diff --git a/hurd/subhurd.mdwn b/hurd/subhurd.mdwn index 820e493f..f8e1c321 100644 --- a/hurd/subhurd.mdwn +++ b/hurd/subhurd.mdwn @@ -43,7 +43,7 @@ debootstrap as root: mke2fs /dev/hd0s6 settrans -ca mnt /hurd/ext2fs /dev/hd0s6 debootstrap sid mnt/ http://httpredir.debian.org/debian - settrans -ga mnt + settrans -fga mnt ### IRC, freenode, #hurd, 2013-09-15 -- cgit v1.2.3 From 45e529318e9963a4df0a900bd7b5bd29a6412183 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 21 Nov 2016 00:22:17 +0100 Subject: note that /dev/eth0 should be used to get it working --- hurd/subhurd.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hurd/subhurd.mdwn') diff --git a/hurd/subhurd.mdwn b/hurd/subhurd.mdwn index f8e1c321..c9fe15d2 100644 --- a/hurd/subhurd.mdwn +++ b/hurd/subhurd.mdwn @@ -113,7 +113,7 @@ proc server will kill all tasks belonging to the Subhurd. In the subhurd, you can do basically all the same things as in the main Hurd. You can even set up networking: Just invoke `settrans` on the -`/servers/socket/2` as usual inside the subhurd, only using a different local +`/servers/socket/2` as usual inside the subhurd, using `/dev/eth0`, only using a different local IP than in the main Hurd. This way, the subhurd will be able to communicate to the outside world with its own IP -- allowing for example to do `apt-get` inside the subhurd, or to `ssh` directly into the subhurd. -- cgit v1.2.3