OpenWrt Forum Archive

Topic: opkg and installing to external media

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Is it possible to install opkg's on USB disk without setting up the USB disk as the root filesystem and still have init.d scripts execute and such?

I've tried setting "dest opt /opt" in my /etc/opkg.conf, but installing something simple as transmission-daemon will put a init.d script in /opt/etc/init.d/transmission and that is never executed on boot. It easy enough to add /opt/usr/bin (and others) to /etc/profile and fix any PATH or LD_LIBRARY_PATH issues, but...

If I don't want to boot off the external media, and just use /opt like ipkg-opt (how it is in DD-WRT), am I responsible for any executing any startup scripts (like executing them manually via rc.local) or is there some clever thing I could do in /etc/opkg.conf??

Router: D-LINK DIR-825 B1
OpenWrt: SVN Trunk build

I am facing the same issue using 10.03/2.6 on a WL-500gd.

jruhe

Hi!

Make a script somewhere (e.g.: vi /opt/opkg-link) with this content:

#!/bin/sh
COMMAND=$1
PACKAGE=$2
setdest () {
for i in `grep dest /etc/opkg.conf | cut -d ' ' -f 3`; do
if [ -f $i/usr/lib/opkg/info/$PACKAGE.list ]; then
DEST=$i
fi
done
if [ "x$DEST" = "x" ]; then
echo "Can not locate $PACKAGE."
echo "Check /etc/opkg.conf for correct dest listings";
echo "Check name of requested package: $PACKAGE"
exit 1
fi
}
addlinks () {
setdest;
cat $DEST/usr/lib/opkg/info/$PACKAGE.list | while read LINE; do
SRC=$LINE
DST=`echo $SRC | sed 's%'$DEST'%%'`
DSTNAME=`basename $DST`
DSTDIR=`echo $DST | sed 's%/'$DSTNAME'%%'`
test -f "$SRC"
if [ $? = 0 ]; then
test -e "$DST"
if [ $? = 1 ]; then
mkdir -p $DSTDIR
ln -sf $SRC $DST
else
echo "Not linking $SRC to $DST"
echo "$DST Already exists"
fi
else
test -d "$SRC"
if [ $? = 0 ]; then
test -e $DST
if [ $? = 1 ]; then
mkdir -p $DST
else
echo "directory already exists"
fi
else
echo "Source directory $SRC does not exist"
fi
fi
done
}
removelinks () {
setdest;
cat $DEST/usr/lib/opkg/info/$PACKAGE.list | while read LINE; do
SRC=$LINE
DST=`echo $LINE | sed 's%'$DEST'%%'`
DSTNAME=`basename $DST`
DSTDIR=`echo $DST | sed 's%/'$DSTNAME'%%'`
test -f $DST
if [ $? = 0 ]; then
rm -f $DST
test -d $DSTDIR && rmdir $DSTDIR 2>/dev/null
else
test -d $DST
if [ $? = 0 ]; then
rmdir $DST
else
echo "$DST does not exist"
fi
fi
done
}
mountdest () {
test -d $PACKAGE
if [ $? = 1 ]; then
echo "Mount point does not exist"
exit 1
fi
for i in $PACKAGE/usr/lib/opkg/info/*.list; do
$0 add `basename $i .list`
done
}
umountdest () {
test -d $PACKAGE
if [ $? = 1 ]; then
echo "Mount point does not exist"
exit 1
fi
for i in $PACKAGE/usr/lib/opkg/info/*.list; do
$0 remove `basename $i .list`
done
}
case "$COMMAND" in
add)
addlinks
;;
remove)
removelinks
;;
mount)
mountdest
;;
umount)
umountdest
;;
*)
echo "Usage: $0 "
echo " Commands: add, remove, mount, umount"
echo " Targets: , "
echo "Example: $0 add kismet-server"
echo "Example: $0 remove kismet-server"
echo "Example: $0 mount /mnt/usb"
echo "Example: $0 umount /mnt/usb"
exit 1
;;
esac
exit 0

Than make this script executable:

chmod +x /opt/opkg-link

After you install a package to /opt, you can easy make all symlinks for files with:

/opt/opkg-link add packagename

You can remove the symlinks with:

/opt/opkg-link remove packagename

Or, when you have more packages installed, than you can make all symlink for packages installed to opt with:

/opt/opkg-link mount /opt

You can remove all symlink with

/opt/opkg-link umount /opt

The original script is from http://wiki.openwrt.org/oldwiki/usbstor … .than.root, but I have fixed it.


dirtyfreebooter wrote:

Is it possible to install opkg's on USB disk without setting up the USB disk as the root filesystem and still have init.d scripts execute and such?

I've tried setting "dest opt /opt" in my /etc/opkg.conf, but installing something simple as transmission-daemon will put a init.d script in /opt/etc/init.d/transmission and that is never executed on boot. It easy enough to add /opt/usr/bin (and others) to /etc/profile and fix any PATH or LD_LIBRARY_PATH issues, but...

If I don't want to boot off the external media, and just use /opt like ipkg-opt (how it is in DD-WRT), am I responsible for any executing any startup scripts (like executing them manually via rc.local) or is there some clever thing I could do in /etc/opkg.conf??

Router: D-LINK DIR-825 B1
OpenWrt: SVN Trunk build

Use block-extroot package...

Dogge wrote:

Use block-extroot package...

Did you not read the first sentence?
"Is it possible to install opkg's on USB disk without setting up the USB disk as the root filesystem"

or are you telling me that is only way? vargalex's solution with symlinks seems ok... Plus the wiki warns against external rootfs on kernel 2.6 setups..

Dogge wrote:

decide for yourself...

I will smile That is half the fun. Its a home router. I don't want to lose too much sleep over it. Plus I have a fine old WRT54GL running Tomato and a WRT610Nv2 running DD-WRT as backups if I really knock my DIR-825 out of commission while experimenting..

I used a dual-nic linux box as a router for so long, that I relatively new to linux on your home router scene. I mistakenly got the WRT610N. Its a fine router, but I don't like the GPL issues surrounding DD-WRT, the lack customization that DD-WRT provides (building DD-WRT from SVN basically impossible), so I opted for this D-LINK and OpenWrt. And I still have to read up exactly why DD-WRT is excused of GPL violations and such, I'd like to know more about issues surrounding broadcom binary drivers, etc. Eventually, once I get things settled down with OpenWrt, I'd like to start contributing to the project.


Anyway, with 8MB of flash, I've decided the best course of action is to really, really, limit my OpenWrt build and only use the USB external disk for transmission storage and samba storage. So far I've been able to keep my build under 5.2MB and I think I make it even smaller and still have all the things I like to have on my router.

I have one remaining issue with the DIR-825, and that is the shaky wireless in the 5 GHz radio. I have intermittent problems associating with the 5 GHz radio using 11na mode and WPA2+aes and the N-only 5 GHz speeds are awful compared the WRT610Nv2 and its antennae are internal on top of everything. Maybe that could be my first contribution to OpenWrt...

That was a little off-topic. Sorry about that.

dirtyfreebooter wrote:
Dogge wrote:

Use block-extroot package...

Did you not read the first sentence?
"Is it possible to install opkg's on USB disk without setting up the USB disk as the root filesystem"

or are you telling me that is only way? vargalex's solution with symlinks seems ok... Plus the wiki warns against external rootfs on kernel 2.6 setups..

Hi!

With external rootfs have I no problem on my DIR-825 B2. (The only disadvantage is, that you must build your own firmware.)

vargalex

vargalex wrote:

With external rootfs have I no problem on my DIR-825 B2. (The only disadvantage is, that you must build your own firmware.)

And this is not a disadvantage. It's good if users build OpenWrt from source by them selfs.

Hi

i  having a problem with my WRT350N V2 on wich i install openwrt blackfire 10.03 "orion" image

i am was planning to extend the overlay to could install more package that is why i follow this howto for 10.3: http://wiki.openwrt.org/inbox/howto/con … ge-overlayWhen follow all instructions i can see that the overlay is extend but when i installl package it still install to the root directory .End when the root directory is full i have a segmentation fault while status still showing me a lot of free space on the overlay that did not move att all even after installing packages...
But when i change the destination in opkg.conf to " dest root /overlay " instead of " dest root /' the new mounted overlay grown u and confirm that packages are installed on new overlay but it seem that those packages are not load when system boot from external storage ...( i mean menu did not show ..like when i install coovachilli and webif lua coova chilli...) i have even try to add to etc/profile PATH bin lib and usr / bin or sbin but menu still don't show

i enven try your tuto but nothing

is there anything i haven't tried....please need a help...

(Last edited by delacosta456 on 13 Sep 2010, 06:20)

to vargalex

Hi, I'm use your script when installed transmission on external device, and symlink were created. But when I use commad "/etc/init.d/transmission start" on my router dir-320 transmission not start and output is clear. If I use same command on virtalbox transmission start. You can help me?

vargalex wrote:

Hi!

Make a script somewhere (e.g.: vi /opt/opkg-link) with this content:

#!/bin/sh

This needs a bump, attheveryleast.

The discussion might have continued from here.