You are not logged in.

#1 2012-10-31 08:21:31

jwhendy
Member
Registered: 2010-04-01
Posts: 537

Re-write 32bit chroot daemon in systemd service format?

I followed the Arch wiki instructions quite successfully and have been using the daemon script to use a 32bit chroot. I just switched over fully to systemd (at least I think so) and no longer have the ability to start it since rc.conf no longer exists in the 64bit system (and gets copied in the 32bit chroot daemon script).

Systemd is quite foreign and I find it a bit overwhelming at the moment, not having had time to digest it yet -- I was sort of forced in due to a recent upgrade.

In any case, are there suggestions of how to re-write this in systemd language and enable as a service?

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

# Add '/var/run /var/lib/dbus' to the list to enable pulseaudio.
dirs=(/dev /dev/pts /dev/shm /tmp /home)

case $1 in
    start)
        stat_busy "Starting Arch32 chroot"
        for d in "${dirs[@]}"; do
         mount -o bind $d /opt/arch32$d
        done
        mount -t proc none /opt/arch32/proc
        mount -t sysfs none /opt/arch32/sys
        add_daemon arch32
        stat_done
        ;;
    stop)
        stat_busy "Stopping Arch32 chroot"
        for (( i = ${#dirs[@]} - 1; i >= 0; i-- )); do
         umount "/opt/arch32${dirs[i]}"
        done
        umount /opt/arch32/{proc,sys}
        rm_daemon arch32
        stat_done
        ;;
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        echo "usage: $0 {start|stop|restart}"
esac
exit 0

It looks like most of it is just bash code, but things like stat_busy and rm_daemon are no longer commands on my system (perhaps provided by initscripts or sysvinit?).

I can add this to the wiki page for other services once I have it figured out, as I'm guessing some others use it and will stumble into the same issue. I don't know what stat_done and others do; like I said, most of it would just be storing this somewhere and having systemd call it on boot, but I don't want to break something by missing an important step because I don't know any better (properly unmounting a drive on service shutdown, for instance).

Thanks for any suggestions/assistance.

Offline

#2 2012-10-31 09:53:45

brain0
Developer
From: Aachen - Germany
Registered: 2005-01-03
Posts: 1,382

Re: Re-write 32bit chroot daemon in systemd service format?

I'd use mount units for this.

Offline

#3 2012-10-31 12:02:14

nomorewindows
Member
Registered: 2010-04-03
Posts: 2,956

Re: Re-write 32bit chroot daemon in systemd service format?

This is what someone came up with at http://pastebin.com/esbRg3AK (haven't tried it yet myself, but it looks like it could some damage):

##/etc/systemd/system/arch32.service:
[Unit]
Description=32-bit chroot

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/arch32 start
ExecStop=/usr/local/bin/arch32 stop

[Install]
WantedBy=multi-user.target
##/usr/local/bin/arch32:
#!/bin/bash

# Add '/var/run /var/lib/dbus' to the list to enable pulseaudio.
dirs=(/dev /dev/pts /dev/shm /tmp /home)

case $1 in
    start)
        for d in "${dirs[@]}"; do
            mount -o bind $d /opt/arch32$d
        done
        ;;
    stop)
        for (( i = ${#dirs[@]} - 1; i >= 0; i-- )); do
            umount "/opt/arch32${dirs[i]}"
        done
        umount /opt/arch32/{proc,sys}
        ;;
    *)
        echo "usage: $0 (start|stop)"
        exit 1
esac

Edit: These are two separate files, the second one should match the original lines in the original post.

Last edited by nomorewindows (2012-11-02 14:44:27)


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Online

#4 2012-10-31 13:33:48

jwhendy
Member
Registered: 2010-04-01
Posts: 537

Re: Re-write 32bit chroot daemon in systemd service format?

Thanks for the script -- looks like it does what the old one did, which isn't to say it's proper/right... just that it worked long enough that I'd trust it in a new format.

Out of curiosity, is there a difference between executing at start up and "persisting" like a service? For example, the wiki has instructions about re-writing rc.local in systemd terms, so I did this:

[Unit]
Description=/etc/rc.local

[Service]
Type=oneshot
ExecStart=/usr/local/bin/rc.local
TimeoutSec=0
RemainAfterExit=0

[Install]
WantedBy=multi-user.target

It's nearly verbatim with the wiki rc-local.service... I have a line in /usr/local/bin/rc.local.service (my old rc.local file) to mount a truecrypt volume, but I'm no longer prompted for my password when I boot up. Just wondering if any of this would affect the chroot as well? It appears rc.local.service isn't executing even though `systemctl list-units-all` yields "loaded inactive dead" for rc.local.service.

Still don't really understand all the changes.


Thanks again!

Offline

#5 2012-10-31 13:49:34

nomorewindows
Member
Registered: 2010-04-03
Posts: 2,956

Re: Re-write 32bit chroot daemon in systemd service format?

You want to mount your volumes before going into chroot.  What happened in chroot stays in chroot.
You can bind-mount your volumes for your chroot so that you don't have to mount them again.

Last edited by nomorewindows (2012-10-31 13:50:52)


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Online

#6 2012-11-02 13:43:47

jwhendy
Member
Registered: 2010-04-01
Posts: 537

Re: Re-write 32bit chroot daemon in systemd service format?

@nomorewindows: I just manually executed the arch32 actions manually, which just came down to `mount -o bind` with all of the points listed.

I went to start Lotus Notes, the whole reason I have a 32bit choot... and at login it says "Notes not installed," along with an obscure error code. This didn't happen before upgrading to systemd. Is there anything besides drive mounting that initscripts might have been fulfilling that systemd isn't when it comes to the chroot?

Or what about those lines with rc.conf and rc.d/functions -- do I perhaps need to run those somehow before chrooting in?

Offline

#7 2012-11-02 14:29:15

nomorewindows
Member
Registered: 2010-04-03
Posts: 2,956

Re: Re-write 32bit chroot daemon in systemd service format?

jwhendy wrote:

@nomorewindows: I just manually executed the arch32 actions manually, which just came down to `mount -o bind` with all of the points listed.

I went to start Lotus Notes, the whole reason I have a 32bit choot... and at login it says "Notes not installed," along with an obscure error code. This didn't happen before upgrading to systemd. Is there anything besides drive mounting that initscripts might have been fulfilling that systemd isn't when it comes to the chroot?

Or what about those lines with rc.conf and rc.d/functions -- do I perhaps need to run those somehow before chrooting in?

It needs to be modified.  It needs to have a line in start to mount proc and sys. 
Under stop, it unmounts proc and sys that it never mounted.

If you use the original lines you posted above and use the systemd file for arch32 and point it to that file in ExecStart/ExecStop then you should be fine.

Last edited by nomorewindows (2012-11-02 14:43:08)


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Online

#8 2012-11-02 17:41:56

jwhendy
Member
Registered: 2010-04-01
Posts: 537

Re: Re-write 32bit chroot daemon in systemd service format?

Do you think that would affect my Lotus Notes issue? After following the script commands manually, here is the relevant info:

$ mount
dev on /opt/arch32/dev type devtmpfs (rw,nosuid,relatime,size=1986024k,nr_inodes=496506,mode=755)
devpts on /opt/arch32/dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /opt/arch32/dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /opt/arch32/tmp type tmpfs (rw,nosuid,nodev,relatime)
/dev/mapper/root on /opt/arch32/home type ext4 (rw,noatime,commit=600,data=ordered)
none on /opt/arch32/proc type proc (rw,relatime)
none on /opt/arch32/sys type sysfs (rw,relatime)

It looks like I hit the necessary files?

The one that stands out is /dev/mapper/root on /opt/arch32/home, but that's what results with:

$ sudo mount -o bind /home /opt/arch32/home

I'm a bit puzzled about that one... Doing `ls /opt/arch32/home` after mounting, however, does show my user folder in there, and `ls -l` shows they're my permissions (jwhendy:users).

I do appreciate the help!

Offline

#9 2012-11-02 19:51:57

nomorewindows
Member
Registered: 2010-04-03
Posts: 2,956

Re: Re-write 32bit chroot daemon in systemd service format?

jwhendy wrote:

Do you think that would affect my Lotus Notes issue? After following the script commands manually, here is the relevant info:

$ mount
dev on /opt/arch32/dev type devtmpfs (rw,nosuid,relatime,size=1986024k,nr_inodes=496506,mode=755)
devpts on /opt/arch32/dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /opt/arch32/dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /opt/arch32/tmp type tmpfs (rw,nosuid,nodev,relatime)
/dev/mapper/root on /opt/arch32/home type ext4 (rw,noatime,commit=600,data=ordered)
none on /opt/arch32/proc type proc (rw,relatime)
none on /opt/arch32/sys type sysfs (rw,relatime)

It looks like I hit the necessary files?

The one that stands out is /dev/mapper/root on /opt/arch32/home, but that's what results with:

$ sudo mount -o bind /home /opt/arch32/home

I'm a bit puzzled about that one... Doing `ls /opt/arch32/home` after mounting, however, does show my user folder in there, and `ls -l` shows they're my permissions (jwhendy:users).

I do appreciate the help!

The mount bind for home is actually the way it is supposed to be.  This is the intended behaviour.  It gives you verbatim access to whatever it is bound to.
Are you actually in the chroot when you start Lotus Notes?  Even though the host architecture shouldn't matter, running 32-bit applications in the chroot should behave correctly.  In the past 32-bit chroot's there was another bash binary called arch32 that did your chroot /opt/arch32, but you can still do that manually.

Last edited by nomorewindows (2012-11-02 20:03:54)


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Online

#10 2012-11-03 22:06:29

jwhendy
Member
Registered: 2010-04-01
Posts: 537

Re: Re-write 32bit chroot daemon in systemd service format?

@nomorewindows

Re. the mount results, sounds good. I guess that's as it is supposed to be.

Regarding my steps:
- Open terminal
- $ sudo chroot /opt/arch32
- $ su jwhendy
- $ /opt/ibm/lotus/notes/notes &

That typically does the trick.

If I'm going to run pacman, I do `$ sudo linux32 chroot /opt/arch32`

But yes, I'm in the chroot when I start Notes. I reinstalled and get the same results.

I ran the mount commands manually from my original posted scripts and then chrooted. Do I need to run the add_daemon command? There's got to be something going wrong here. If I can't get it within a few days, I'm thinking of contaminating my system with lib32 files as I really need this to be able to continue using Linux at work. Notes has a web interface, but it lacks a lot of the functionality of the desktop application, unfortunately.

Offline

#11 2012-11-04 00:38:21

nomorewindows
Member
Registered: 2010-04-03
Posts: 2,956

Re: Re-write 32bit chroot daemon in systemd service format?

The add_daemon is needed, however it is usually just to allow it to determine whether it is working. 
You can still run the old script using /etc/rc.d/arch32 just fine, I don't know that having a systemd script is really that much of a requirement.  Systemd calls the script anyways.  The 32-bit chroot is there so you can run 32-bit applications. 
I usually run the pacman with the arch=i686 and -r=/opt/arch32 options outside of the chroot jail.  But I don't try to run a 32-bit pacman on a 64-bit installation.  The db gets all messed around. 
What I've done, is make /opt/arch32 on a separate partition all it's own, running a 32-bit regular installation.  I can actually boot into it, just add the necessary lines to your bootloader configuration. 
Then I had the nfs module and net hook to its' /etc/mkinitcpio.conf and serve it up for PXE clients as well.  So I have it usable for 32-bit chroot jails as well as PXE clients.  It's really that simple.  Sometimes I have to work and forth between the PXE client and chroot jails just depending on which one seems easier or which one I have available.

Last edited by nomorewindows (2012-11-04 00:42:43)


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Online

#12 2012-11-04 17:25:22

jwhendy
Member
Registered: 2010-04-01
Posts: 537

Re: Re-write 32bit chroot daemon in systemd service format?

@nomorewindows

- add_daemon is not on my system anymore, presumably because it was provided by initscripts?

- so systemd still calls everything in /etc/rc.d? I don't show any of those drives mounted prior to doing it manually.

- re. pacman... it doesn't do anything to my pacman db since there's an isolated copy of it in the 32bit chroot. Chrooting in with `linux32` in the options gives "i686" when I do -uname. I've never had an issue with updating this way, but your way *is* more careful!

- I can't do a separate installation, or at least it wouldn't make it worth it to have 64bit at all; I need Lotus Notes for work, so there'd be no reason to have 64bit if I needed 32bit to handle email/celendaring stuff.


--------------------
Update: It had nothing to do with systemd! This is still extremely helpful, as I can re-create the daemon for systemd vs. mounting all of that manually, but I finally caught a line in the error output for Lotus Notes complaining about a missing library, libpangox. Searching pacman for pangox revealed the package pangox-compat, which once installed has Notes working again! Very happy!

Thanks for the persistence and help in re-writing the above. I'll give these things a whirl and see where I get.

I did note that in the chroot pacman now complains about a bunch of missing files in /sys/fs/cgroup with respect to calculating size requirements for packages. From the one other error I could find like this on Arch forums, seems like it's nothing to worry about?

Offline

Board footer

Powered by FluxBB