Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Systemd: umount sequence at shutdown - Squash Portage
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
musv
Advocate
Advocate


Joined: 01 Dec 2002
Posts: 3254
Location: de

PostPosted: Thu Jul 23, 2015 5:29 am    Post subject: Systemd: umount sequence at shutdown - Squash Portage Reply with quote

Hi there,

I'm running Systemd now already for a couple of years. For me it's ok so far. But there's one problem left. I try it explain somehow briefly.

  • My portage tree is outsourced to my NAS server. It's stored in a SquashFS image.
  • When I want to use portage, I just start the squash_portage.service, which mounts the Portage directory from NAS via nfs and mounts afterwards the SquashFS image to /usr/portage.

Works great and has the advantage to sync the portage only once and have it available on every machine in the network.

My scripts:

/etc/systemd/system/squash_portage.service:
[Unit]
Description=Squash Portage
Requires=local-fs.target var-portage.mount usr-portage.mount
After=local-fs.target var-portage.mount usr-portage.mount

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/squash_portage.conf
ExecStart=-/etc/systemd/scripts/squash_portage_start_overlay
ExecStop=/etc/systemd/scripts/squash_portage_update
ExecStopPost=-/bin/umount -t overlay "$PORTDIR"
ExecStopPost=-/bin/rm -rf "$PORTAGE_UPPER"
ExecStopPost=-/bin/rm -rf "$PORTAGE_WORK"

[Install]
WantedBy=multi-user.target


/etc/systemd/system/var-portage.mount:
[Unit]
Description=/var/portage Portage vom Nas
BindsTo=squash_portage.service
Before=squash_portage.service usr-portage.mount

[Mount]
What=nas:/portage
Where=/var/portage
Type=nfs4
Options=rw,intr,noatime,nodiratime,hard,rsize=32768,wsize=32768,vers=4.1


/etc/systemd/system/usr-portage.mount:
[Unit]
Description=/usr/portage Squash-Portage
BindsTo=squash_portage.service
Before=squash_portage.service
After=var-portage.mount

[Mount]
What=/var/portage/portage-current.sqfs
Where=/usr/portage
Type=squashfs
Options=loop,nodev,noexec


/etc/conf.d/squash_portage.conf:

# /etc/conf.d/squash_portage.conf

# SQFS_DIRNAME points to the directory that will contain the sqfs
# images, recommended value is /var/tmp
SQFS_DIRNAME="/var/portage"

# Leave PORTAGE_RW empty for use with tmpfs, a ram-based filesystem,
# This is recommended unless you are short of RAM
PORTDIR="/usr/portage"
# alt aufs
PORTAGE_RW="/dev/shm/.portage-rw"
PORTAGE_UPPER="/dev/shm/.portage_upper"
PORTAGE_WORK="/dev/shm/.portage_work"

SQFS=CUR="$SQFS_DIRNAME/portage.sqfs"
SQFS_NEW="$SQFS_DIRNAME/portage-current.sqfs"
SQFS_OLD="$SQFS_DIRNAME/portage-old.sqfs"
SQFS_OTPS="-force-uid portage -force-gid portage -no-duplicates -comp xz"


/etc/systemd/scripts/squash_portage_update:

#!/bin/sh
# /etc/systemd/scripts
# Rechte: 755

# parse make.conf
[ -f /etc/conf.d/squash_portage.conf ] && source /etc/conf.d/squash_portage.conf || exit 1

# check overlay dir
[ -d "$PORTAGE_UPPER" ] || exit 1

if [ $(du -s $PORTAGE_UPPER | cut -f 1) -gt 4 ]; then
   logger "Squash_Portage: changes detected"
   mv -f $SQFS_NEW $SQFS_OLD
   mksquashfs $PORTDIR $SQFS_NEW $SQFS_OPTS 2> /dev/null
   ln -sf $SQFS_NEW $SQFS_CUR
   rm -f $SQFS_OLD
else
   logger "Squash_Portage: No changes detected, skipping update."
fi


The issue:
  • stopping squash_portage.service: works fine and unmounts the 2 directories without problems.
  • shutdown the machine without stopping squash_portage.service before: hangs, when trying to unmount /usr/portage for some reason.


Idea:
Instead of unmounting the directories independently by the system. The unmount request of /usr/portage or /var/portage should call first:
Code:
systemctl stop squash_portage

How do I do that?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum