Page 1 of 6
Porteus module activation status
Posted: 29 Sep 2016, 06:42
by jssouza
Hi,
I wrote a small program using gtkdialog to quickly check the activated modules and activate/deactivate modules. This is especially helpful when load= and noload= cheatcodes have been used, so even the porteus/modules directory may not have all modules loaded.
Code: Select all
#! /bin/bash
export NUMENTRIES=0
export LOADEDENTRIES=0
export MODULE_LOAD_DIR="/mnt/live/memory/images"
export TMPFILE="/tmp/port_modules"
function load_modules
{
NUMENTRIES=0
LOADEDENTRIES=0
local PORTMODULES="$(find $PORTDIR -name "*.xzm" | sort)"
for PORTMODULE in $PORTMODULES
do
local MODNAME="$(basename -a $PORTMODULE)"
local MODDIR="$(basename -a $(dirname $PORTMODULE))"
local OUT="${MODNAME}|${MODDIR}"
if [ -e "${MODULE_LOAD_DIR}/${MODNAME}" ]; then
echo "gtk-yes|${OUT}" >> "$TMPFILE"
LOADEDENTRIES=$((LOADEDENTRIES+1))
else
echo "gtk-no|${OUT}" >> "$TMPFILE"
fi
NUMENTRIES=$((NUMENTRIES+1))
done
}
function activate_module
{
local MODULE="$(find $PORTDIR -name $1)"
local MODNAME="$(basename -a $MODULE)"
if [ -e "${MODULE_LOAD_DIR}/${MODNAME}" ]; then
deactivate "$MODULE"
else
activate "$MODULE"
fi
rm -f "$TMPFILE"
load_modules
}
export -f load_modules
export -f activate_module
load_modules
export MODULES_MAIN='
<window window_position="1" title="Porteus Modules ('$NUMENTRIES')" default-height="550" default-width="400" icon-name="cdr" resizable="true">
<vbox>
<tree selection-mode="1" file-monitor="true">
<variable>ENTRY</variable>
<label>"Module Name |Containing Directory "</label>
<input file icon_column="0">'$TMPFILE'</input>
<action signal="row-activated">"activate_module $ENTRY"</action>
<action signal="file-changed" type="refresh">ENTRY</action>
</tree>
<hseparator default-width="300"></hseparator>
<hbox>
<button space-fill="true">
<label>Exit</label>
<action>exit:0</action>
</button>
</hbox>
</vbox>
</window>
'
gtkdialog --program=MODULES_MAIN -c
rm -f $TMPFILE
I save it as /usr/local/bin/lsmodules.sh and create a .desktop entry for it in the ~/Desktop and in ~/.local/share/applications.
I also have an gtkdialog question on the above. The
Code: Select all
title="Porteus Modules ('$NUMENTRIES')
was originally meant to be
Code: Select all
title="Porteus Modules ('$LOADEDENTRIES'/'$NUMENTRIES')
But I was not able to refresh the number of loaded modules in the gtkdialog titlebar after a module activation/deactivation, even though the $LOADEDENTRIES itself is updated. Could anyone help me on this please?
Thanks!
Re: Porteus module activation status
Posted: 01 Oct 2016, 02:36
by brokenman
Useful little tool. A couple of things.
http://imgur.com/sectJRh
1) The tools is not showing some modules I have activated. Extra modules activated after booting.
2) If I exit the script with ctrl + c it seems to keep the $TMPFILE and so the next run doubles the entries (see screeny)
3) As for the title module count. It may be better to put this at the bottom so you can give it a variable. In the titlebar I am not so sure you can refresh it.
Re: Porteus module activation status
Posted: 01 Oct 2016, 04:46
by Ed_P
Interesting. What does the export do? I've never seen it used before.
Re: Porteus module activation status
Posted: 01 Oct 2016, 15:12
by jssouza
Ed_P wrote:What does the export do? I've never seen it used before.
Hi Ed_P,
Export is used to pass the variable to the subsequent child environments also.
Re: Porteus module activation status
Posted: 01 Oct 2016, 15:33
by jssouza
Hi brokenman,
Thank you very much for your inputs.
I have done some changes to the script.
Code: Select all
#! /bin/bash
export MODULE_LOAD_DIR="/mnt/live/memory/images"
export TMPFILE="/tmp/${$}_port_modules"
export LOADEDENTRIES="grep -c gtk-yes $TMPFILE"
export NUMENTRIES="wc -l $TMPFILE | cut -f 1 -d ' '"
trap sigint_handler INT
sigint_handler()
{
rm -f "$TMPFILE"
}
function load_extra_modules
{
local PORTMODULES="$(ls $MODULE_LOAD_DIR | sort)"
for PORTMODULE in $PORTMODULES
do
local MODNAME="$(basename -a $PORTMODULE)"
if ! grep -q "$MODNAME" "$TMPFILE"; then
echo "gtk-yes|${MODNAME}|external" >> "$TMPFILE"
fi
done
}
function load_modules
{
local PORTMODULES="$(find $PORTDIR -name "*.xzm" | sort)"
for PORTMODULE in $PORTMODULES
do
local MODNAME="$(basename -a $PORTMODULE)"
local MODDIR="$(basename -a $(dirname $PORTMODULE))"
local OUT="${MODNAME}|${MODDIR}"
if [ -e "${MODULE_LOAD_DIR}/${MODNAME}" ]; then
echo "gtk-yes|${OUT}" >> "$TMPFILE"
else
echo "gtk-no|${OUT}" >> "$TMPFILE"
fi
done
load_extra_modules
}
function activate_module
{
if [ "$1" = "" ]; then return; fi
local MODULE="$(find $PORTDIR -name $1)"
if [ "$MODULE" = "" ]; then
MODULE="$1"
fi
local MODNAME="$(basename -a $MODULE)"
if [ -e "${MODULE_LOAD_DIR}/${MODNAME}" ]; then
deactivate "$MODULE"
else
activate "$MODULE"
fi
rm -f "$TMPFILE"
load_modules
}
export -f load_modules
export -f load_extra_modules
export -f activate_module
load_modules
export MODULES_MAIN='
<window window_position="1" title="Porteus Modules" default-height="550" default-width="400" icon-name="cdr" resizable="true">
<vbox>
<text use-markup="true">
<label>"<span weight='"'bold'"'>Modules Activated</span>"</label>
</text>
<text>
<variable>ENTRIES</variable>
<input>'$LOADEDENTRIES'</input>
</text>
<tree selection-mode="1" file-monitor="true">
<variable>ENTRY</variable>
<label>"Module Name |Containing Directory "</label>
<input file icon_column="0">'$TMPFILE'</input>
<action signal="row-activated">"activate_module $ENTRY"</action>
<action signal="file-changed" type="refresh">ENTRY</action>
<action signal="file-changed" type="refresh">ENTRIES</action>
</tree>
<hseparator default-width="300"></hseparator>
<hbox>
<button space-fill="true">
<label>Exit</label>
<action>exit:0</action>
</button>
</hbox>
</vbox>
</window>
'
gtkdialog --program=MODULES_MAIN -c
rm -f $TMPFILE
I am now able to refresh the number of loaded entries.
I also added a sigint handler to handle ctrl-c. I also saw that running 2 instances of the script also doubled the entries, so I made the temp file unique per session.
brokenman wrote:The tools is not showing some modules I have activated. Extra modules activated after booting.
I am assuming the extra activated modules were not under the $PORTDIR/porteus. I have done changes now, that will also show the extra activated modules. Unfortunately, as soon as I deactivate them, they would just disappear from the dialog, since I am not able to locate the source directory of these mounted modules. I checked mount, /proc/mounts, df but they show the source as /dev/loopX, not the actual source directory. Any command that would give the actual source directory?
Thanks!
Re: Porteus module activation status
Posted: 02 Oct 2016, 20:08
by jssouza
Any command that would give the actual source directory?
Found out about a command called
losetup that shows the source directory of a loop mount. Unfortunately it requires root access. So, I made the whole program to be executable in root mode. Advantage of course is that the password prompt would not be shown for each activation/deactivation of a module from the program.
Now, the program shows the path of even an externally loaded module.
Code: Select all
#! /bin/bash
if [ "$UID" -ne 0 ]; then
if [ "$DISPLAY" ]; then
ktsuss $0
else
echo "Enter root password"
su -c $0
fi
exit
fi
export MODULE_LOAD_DIR="/mnt/live/memory/images"
export TMPFILE="/tmp/${$}_port_modules"
export LOADEDENTRIES="grep -c gtk-yes $TMPFILE"
export NUMENTRIES="wc -l $TMPFILE | cut -f 1 -d ' '"
trap sigint_handler INT
sigint_handler()
{
rm -f "$TMPFILE"
}
function load_extra_modules
{
local PORTMODULES="$(ls $MODULE_LOAD_DIR | sort)"
for PORTMODULE in $PORTMODULES
do
local MODNAME="$(basename -a $PORTMODULE)"
if ! grep -q "$MODNAME" "$TMPFILE"; then
local MODDIR="$(/sbin/losetup -O BACK-FILE | grep $MODNAME)"
echo "gtk-yes|${MODNAME}|${MODDIR}" >> "$TMPFILE"
fi
done
}
function load_modules
{
local PORTMODULES="$(find $PORTDIR -name "*.xzm" | sort)"
for PORTMODULE in $PORTMODULES
do
local MODNAME="$(basename -a $PORTMODULE)"
local MODDIR="$(dirname $PORTMODULE)"
local OUT="${MODNAME}|${MODDIR}"
if [ -e "${MODULE_LOAD_DIR}/${MODNAME}" ]; then
echo "gtk-yes|${OUT}" >> "$TMPFILE"
else
echo "gtk-no|${OUT}" >> "$TMPFILE"
fi
done
load_extra_modules
}
function activate_module
{
if [ "$1" = "" ]; then return; fi
local MODULE="$(find $PORTDIR -name $1)"
if [ "$MODULE" = "" ]; then
MODULE="$1"
fi
local MODNAME="$(basename -a $MODULE)"
if [ -e "${MODULE_LOAD_DIR}/${MODNAME}" ]; then
deactivate "$MODULE"
else
activate "$MODULE"
fi
rm -f "$TMPFILE"
load_modules
}
export -f load_modules
export -f load_extra_modules
export -f activate_module
load_modules
export MODULES_MAIN='
<window window_position="1" title="Porteus Modules" default-height="550" default-width="500" icon-name="cdr" resizable="true">
<vbox>
<text use-markup="true">
<label>"<span weight='"'bold'"'>Modules Activated</span>"</label>
</text>
<text>
<variable>ENTRIES</variable>
<input>'$LOADEDENTRIES'</input>
</text>
<tree selection-mode="1" file-monitor="true">
<variable>ENTRY</variable>
<label>"Module Name |Containing Directory "</label>
<input file icon_column="0">'$TMPFILE'</input>
<action signal="row-activated">"activate_module $ENTRY"</action>
<action signal="file-changed" type="refresh">ENTRY</action>
<action signal="file-changed" type="refresh">ENTRIES</action>
</tree>
<hseparator default-width="300"></hseparator>
<hbox>
<button space-fill="true">
<label>Exit</label>
<action>exit:0</action>
</button>
</hbox>
</vbox>
</window>
'
gtkdialog --program=MODULES_MAIN -c
rm -f $TMPFILE
Re: Porteus module activation status
Posted: 02 Oct 2016, 21:01
by brokenman
Very nice.
You may also simply deactivate the module directly in /mnt/live/memory/images
Re: Porteus module activation status
Posted: 02 Oct 2016, 23:44
by Ed_P
Porteus 3.2rc5 Cinnamon 64-bit
A very neat script
jssouza. Thank you for sharing it.
Code: Select all
guest@porteus:~$ ./modules.sh
glibtop(c=2174): [DEBUG] open.c:53 glibtop_open_l(): SIZEOF: 40 - 65648 - 248 - 65624 - 224 - 65624
glibtop(c=2174): [DEBUG] open.c:163 glibtop_open_l(): Calling sysdeps open function.
glibtop(c=2174): [DEBUG] init.c:229 glibtop_init_s(): init_s with features=0x7ffffff and flags=0
find: `/mnt/isoloop': No such file or directory
grep: /tmp/2198_port_modules: No such file or directory
ENTRIES="15
"
ENTRY="changes"
EXIT="0"
guest@porteus:~$
The GUI is initially too narrow, it only shows half of my Containing Directory names. Can the default width be changed? And can module names and/or directory be highlighted and copied?
Code: Select all
guest@porteus:~$ ls /mnt/sda5/porteus3.2/Modules/
009-caches.xzm*
firefox-47.0b9-x86_64-1.xyzm*
firefox-48.0b6-x86_64-1.xzm*
flashplayer-plugin-11.2.202.635-x86_64-1alien.xyzm*
flashplayer-plugin-22.0.0.209-x86_64-1.xzm*
flashplayer-plugin-23.0.0.162-x86_64-1.xzm*
iwlwifi-7265-ucode-25.30.14.0/
nemo-actions-fix-by-blaze.xzm*
pepperflash-23.0.0.162-x86_64-1.xzm*
printing-3.2-lite-drivers.xzm*
printing-3.2-lite.xzm*
wine-1.9.15-x86_64-bundle.xyzm*
xf86-video-amdgpu-1.1.1-x86_64.xzm*
xf86-video-ati-7.7.1-x86_64.xzm*
guest@porteus:~$
Re: Porteus module activation status
Posted: 03 Oct 2016, 15:54
by jssouza
Thanks brokenman. You are right. I just wanted to show the source path of activated modules that were not part of porteus base/modules/optional directories.
Thanks Ed_P. I am still pretty new to gtkdialog, so not sure if individual rows could be copied. I guess one method could be to make a text input field at the bottom that shows the current entry which would be copyable.
Can the default width be changed?
This is easy. Just change
to the width that suits you.
Re: Porteus module activation status
Posted: 04 Oct 2016, 03:41
by brokenman
It's great to see someone diving into gtkdialog! You are picking it up quickly.
Re: Porteus module activation status
Posted: 04 Oct 2016, 14:35
by jssouza
Thank you brokenman. Your encouragement helps a lot.
Hopefully I can come up with more scripts.
Re: Porteus module activation status
Posted: 04 Oct 2016, 17:18
by Ed_P
jssouza I tried your script in my Porteus 3.0.1 RazorQT 64-bit system and got many iterations of this in terminal window:
Code: Select all
For more details see losetup(8).
/sbin/losetup: invalid option -- 'O'
Usage:
losetup [options] [<loopdev>]
losetup [options] -f | <loopdev> <file>
Options:
-a, --all list all used devices
-d, --detach <loopdev> [...] detach one or more devices
-D, --detach-all detach all used devices
-f, --find find first unused device
-c, --set-capacity <loopdev> resize device
-j, --associated <file> list all devices associated with <file>
-e, --encryption <type> enable encryption with specified <name/num>
-o, --offset <num> start at offset <num> into file
--sizelimit <num> device limited to <num> bytes of the file
-p, --pass-fd <num> read passphrase from file descriptor <num>
-P, --partscan create partitioned loop device
-r, --read-only setup read-only loop device
--show print device name after setup (with -f)
-v, --verbose verbose mode
-h, --help display this help and exit
-V, --version output version information and exit
For more details see losetup(8).
/sbin/losetup: invalid option -- 'O'
It did deactivate a module but wouldn't reactivate it. It was also missing the directories for most of the files.
Re: Porteus module activation status
Posted: 04 Oct 2016, 18:43
by jssouza
I was not around during the time of Porteus 3.0.1 so I am assuming a couple of things:
1. $PORTDIR was not set at that time.
Could you let me know the output of
If it is not set, then please let me know the output of
Code: Select all
grep -A1 "Porteus data found in" /var/log/porteus-livedbg
Hopefully this file existed even then.
2. The version of losetup was old and did not have a -O option then (as seen by your output). As root could you please show the output of
Re: Porteus module activation status
Posted: 04 Oct 2016, 19:43
by Ed_P
As you requested sir.
Code: Select all
guest@porteus:~$ echo $PORTDIR
guest@porteus:~$
guest@porteus:~$ grep -A1 "Porteus data found in" /var/log/porteus-livedbg
# Porteus data found in:
/mnt/isoloop/porteus
guest@porteus:~$
guest@porteus:~$ losetup -a
/dev/loop0: [2053]:19967 (/mnt/sda5/ISOs/Porteus-RazorQT-v3.0.1-x86_64-nu.iso)
/dev/loop1: [1792]:1668 (/mnt/live/mnt/isoloop/porteus/base/000-kernel.xzm)
/dev/loop2: [1792]:1671 (/mnt/live/mnt/isoloop/porteus/base/001-core.xzm)
/dev/loop3: [1792]:1674 (/mnt/live/mnt/isoloop/porteus/base/002-xorg.xzm)
/dev/loop4: [1792]:1677 (/mnt/live/mnt/isoloop/porteus/base/003-razor.xzm)
/dev/loop5: [2053]:77 (/mnt/sda5/porteus3.0/Modules/001-core_alldesktops-150124.xzm)
/dev/loop6: [2053]:202 (/mnt/sda5/porteus3.0/Modules/002-xorg_alldesktops-150119.xzm)
/dev/loop7: [2053]:12124 (/mnt/sda5/porteus3.0/Modules/002-xorg_alldesktops-150126.xzm)
/dev/loop8: [2053]:22142 (/mnt/sda5/porteus3.0/Modules/04-firefox.xzm)
/dev/loop9: [2053]:22075 (/mnt/sda5/porteus3.0/Modules/07-printing.xzm)
/dev/loop10: [2053]:22108 (/mnt/sda5/porteus3.0/Modules/OOoLight1.1_120606_LinuxX86-64.xzm)
/dev/loop11: [2053]:22109 (/mnt/sda5/porteus3.0/Modules/Wine-1.7.26-x64-GeckoMono-1.xzm)
/dev/loop12: [2053]:12165 (/mnt/sda5/porteus3.0/Modules/bash-4.2.048-x86_64-2_slack14.1.xzm)
/dev/loop14: [2053]:12207 (/mnt/sda5/porteus3.0/Modules/flashplayer-plugin-11.2.202.635-x86_64-1alien.xzm)
/dev/loop15: [2053]:21561 (/mnt/sda5/porteus3.0/Modules/gweled-0.9.1-4.38.x86_64-1phhpro.xzm)
/dev/loop16: [2053]:21562 (/mnt/sda5/porteus3.0/Modules/java-builder-1.1_noarch.xzm)
/dev/loop17: [2053]:22512 (/mnt/sda5/porteus3.0/Modules/jre-8u101-x86_64-1.xzm)
/dev/loop18: [2053]:21565 (/mnt/sda5/porteus3.0/Modules/keepassx-0.4.3-x86_64-2_slack.xzm)
/dev/loop19: [2053]:21567 (/mnt/sda5/porteus3.0/Modules/kpat-4.10.5-x86_64-bundle.xzm)
/dev/loop20: [2053]:22019 (/mnt/sda5/porteus3.0/Modules/mozilla-firefox-45.1.1esr-x86_64-1gv.xzm)
/dev/loop21: [2053]:209 (/mnt/sda5/porteus3.0/Modules/openssl-1.0.1s-x86_64-1_slack14.1.xzm)
/dev/loop22: [2053]:22114 (/mnt/sda5/porteus3.0/Modules/syslinux-4.06-x86_64-1.xzm)
/dev/loop23: [2053]:21569 (/mnt/sda5/porteus3.0/Modules/testdisk-6.14-x86_64-2sl.xzm)
/dev/loop24: [2053]:21570 (/mnt/sda5/porteus3.0/Modules/tree-1.6.0-x86_64-1.xzm)
/dev/loop25: [2053]:22072 (/mnt/sda5/porteus3.0/Modules/xscreensaver-5.29-x86_64-1_slack14.1.xzm)
/dev/loop26: [2053]:22105 (/mnt/sda5/porteus3.0/Modules/z-MyWines.xzm)
/dev/loop27: [2053]:22139 (/mnt/sda5/porteus3.0/changes/porteussave.dat)
guest@porteus:~$
I should have noted that I boot Porteus as a ISO rather than an installed system.
This is what I use to determine a boot device:
Code: Select all
# http://forum.porteus.org/viewtopic.php?f=53&t=3801&start=30#p28472
BOOTDEV=`grep -A1 "Booting" /var/log/porteus-livedbg|tail -n1|sed 's^//^/^g'`
if [ "$BOOTDEV" == "/mnt/isoloop" ]; then
BOOTDEV=`grep -A1 "ISO=" /var/log/porteus-livedbg`
BOOTDEV=${BOOTDEV:4:9}
fi
Re: Porteus module activation status
Posted: 04 Oct 2016, 20:05
by jssouza
Here you go. Let me know if this works for you. The same script should also work in 3.2rc5!
Code: Select all
#! /bin/bash
# Check if script has been called by root
if [ "$UID" -ne 0 ]; then
if [ "$DISPLAY" ]; then
ktsuss $0
else
echo "Enter root password"
su -c $0
fi
exit
fi
export MODULE_LOAD_DIR="/mnt/live/memory/images"
export TMPFILE="/tmp/${$}_port_modules"
export LOADEDENTRIES="grep -c gtk-yes $TMPFILE"
export NUMENTRIES="wc -l $TMPFILE | cut -f 1 -d ' '"
export PORTROOTDIR=`grep -A1 "Porteus data found in" /var/log/porteus-livedbg | tail -n1`
trap sigint_handler INT
sigint_handler()
{
rm -f "$TMPFILE"
}
function load_extra_modules
{
local PORTMODULES="$(ls $MODULE_LOAD_DIR | sort)"
for PORTMODULE in $PORTMODULES
do
local MODNAME="$(basename -a $PORTMODULE)"
if ! grep -q "$MODNAME" "$TMPFILE"; then
#local MODDIR="$(/sbin/losetup -O BACK-FILE | grep $MODNAME)"
local MODDIR="$(/sbin/losetup -a | grep $MODNAME | cut -d \( -f2 | cut -d \) -f1)"
echo "gtk-yes|${MODNAME}|${MODDIR}" >> "$TMPFILE"
fi
done
}
function load_modules
{
local PORTMODULES="$(find $PORTROOTDIR -name "*.xzm" | sort)"
for PORTMODULE in $PORTMODULES
do
local MODNAME="$(basename -a $PORTMODULE)"
#local MODDIR="$(basename -a $(dirname $PORTMODULE))"
local MODDIR="$(dirname $PORTMODULE)"
local OUT="${MODNAME}|${MODDIR}"
if [ -e "${MODULE_LOAD_DIR}/${MODNAME}" ]; then
echo "gtk-yes|${OUT}" >> "$TMPFILE"
else
echo "gtk-no|${OUT}" >> "$TMPFILE"
fi
done
load_extra_modules
}
function activate_module
{
if [ "$1" = "" ]; then return; fi
local MODULE="$(find $PORTROOTDIR -name $1)"
if [ "$MODULE" = "" ]; then
MODULE="$1"
fi
local MODNAME="$(basename -a $MODULE)"
if [ -e "${MODULE_LOAD_DIR}/${MODNAME}" ]; then
deactivate "$MODULE"
else
activate "$MODULE"
fi
rm -f "$TMPFILE"
load_modules
}
export -f load_modules
export -f load_extra_modules
export -f activate_module
load_modules
export MODULES_MAIN='
<window window_position="1" title="Porteus Modules" default-height="550" default-width="500" icon-name="cdr" resizable="true">
<vbox>
<text use-markup="true">
<label>"<span weight='"'bold'"'>Modules Activated</span>"</label>
</text>
<text>
<variable>ENTRIES</variable>
<input>'$LOADEDENTRIES'</input>
</text>
<tree selection-mode="1" file-monitor="true">
<variable>ENTRY</variable>
<label>"Module Name |Containing Directory "</label>
<input file icon_column="0">'$TMPFILE'</input>
<action signal="row-activated">"activate_module $ENTRY"</action>
<action signal="file-changed" type="refresh">ENTRY</action>
<action signal="file-changed" type="refresh">ENTRIES</action>
</tree>
<hseparator default-width="300"></hseparator>
<hbox>
<button space-fill="true">
<label>Exit</label>
<action>exit:0</action>
</button>
</hbox>
</vbox>
</window>
'
gtkdialog --program=MODULES_MAIN -c
rm -f $TMPFILE
Ed_P wrote:It did deactivate a module but wouldn't reactivate it..
This is possible if the activated module is not part of the porteus base/modules/optional directory. The script only keeps track of these directories. Any external module would only be shown, and would disappear from the script once deactivated (as mentioned in an earlier post).
Edit: I just saw that you could run the losetup command without being root. Was losetup not in /sbin in Porteus 3.0.2? If it was, how are you able to access commands from /sbin? Looks like a security problem in your 3.0.2 system. This is the output in 3.2rc5
Code: Select all
guest@porteus:~$ which losetup
which: no losetup in (/usr/local/bin:/usr/bin:/bin:/usr/games:/opt/porteus-scripts)
guest@porteus:~$ su
Password:
[root:/home/guest]# which losetup
/sbin/losetup