OpenWrt Forum Archive

Topic: Which method to use USB as pkg destination ?

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

Tex, I wrote the top one - describing what I did for my Asus 500GP and I find it works quite well.
There is some stuff about formatting etc that is fairly universal and explained in the 2nd link - so didn't repeat that.

I have Asterisk and XMail working off my usb that get started once the drive is fschk'd and mounted...
but the rest of the network stuff doesn't wait round for the fsck to finish

I'm currently experimenting with Kamikaze trunk on a wl500gp with a 40GB USB hard disc, and look forward to reading other people's contributions.

I initially tried getting ipkg to install packages to my drive, but found the packages I tried assumed they'd been installed under / and didn't like being under /mnt or /opt or whatever. Adding vast numbers of links seems an inelegant solution. (Yes, I did add the extra directories to my PATH and LD_LIBRARY_PATH.)

I'm now playing with using the pivotroot script from the second of your links, and it seems to be working nicely. I've created a 128MB swap partition, a 2GB root partition and a 38GB (or so) /data partition. I've added the swap and /data partitions to /etc/config/fstab and they get mounted at boot. I've also added a "local" script to /etc/init.d to move a few things from /var to /data/var and redirect syslogd to a file, to keep the ramfs as empty as possible.

If the usb disc isn't there at boot time, the new version of /etc/config/fstab and my local script aren't seen and the unit just boots from flash as normal. I just have to make sure that I keep the flash version of some config files up to date with the disc version.

I'm a complete beginner at OpenWrt (having used Oleg's in the past) so don't put too much faith in my approach.

(Last edited by easter on 2 Jul 2008, 13:33)

ok thanks.
frogonwheels, I'm trying to use your method but I'm a bit confused about the "/etc/rc.common" part.  If I understand correctly, I have to copy
/etc/rc.common to /usb/etc/rc.common and replace the disable, enable and enabled functions with yours. Is that correct ?

Thanks,
Tex

Tex-Twil wrote:

ok thanks.
frogonwheels, I'm trying to use your method but I'm a bit confused about the "/etc/rc.common" part.  If I understand correctly, I have to copy
/etc/rc.common to /usb/etc/rc.common and replace the disable, enable and enabled functions with yours. Is that correct ?

Thanks,
Tex

ok I got it now. The rc.common just has to stay where it is but the  disable, enable and enabled must be modified. I tested it, the K* and S* links are created properly in /usb/etc/rc.d/

The problem is that when I simply want to start the service, it fails because of a wrong path I guess:

ipkg -d usb install  vsftpd
Installing vsftpd (2.0.6-2) to usb...
Downloading file:///mnt/usbdrive/bin/packages/mipsel/./vsftpd_2.0.6-2_mipsel.ipk
Configuring vsftpd
Done.
root@ap:~# /usb/etc/init.d/vsftpd enable
root@ap:~# ls -alR /usb/
/usb/:
      2 drwxr-xr-x    4 root     root         4096 Jul  2 22:09 .
     26 drwxr-xr-x   11 root     root            0 Jan  1  1970 ..
 322561 drwxr-xr-x    4 root     root         4096 Jul  2 22:23 etc
 129025 drwxr-xr-x    4 root     root         4096 Jul  2 22:15 usr

/usb/etc:
 322561 drwxr-xr-x    4 root     root         4096 Jul  2 22:23 .
      2 drwxr-xr-x    4 root     root         4096 Jul  2 22:09 ..
 322564 drwxr-xr-x    2 root     root         4096 Jul  2 22:15 init.d
 322563 drwxr-xr-x    2 root     root         4096 Jul  2 22:24 rc.d
 322566 -rw-------    1 root     root          364 Jun 13 15:01 vsftpd.conf

/usb/etc/init.d:
 322564 drwxr-xr-x    2 root     root         4096 Jul  2 22:15 .
 322561 drwxr-xr-x    4 root     root         4096 Jul  2 22:23 ..
 322565 -rwxr-xr-x    1 root     root          149 Jul  2 21:24 vsftpd

/usb/etc/rc.d:
 322563 drwxr-xr-x    2 root     root         4096 Jul  2 22:24 .
 322561 drwxr-xr-x    4 root     root         4096 Jul  2 22:23 ..
 322567 lrwxrwxrwx    1 root     root           16 Jul  2 22:24 K50vsftpd -> ../init.d/vsftpd
 322562 lrwxrwxrwx    1 root     root           16 Jul  2 22:24 S50vsftpd -> ../init.d/vsftpd

/usb/usr:
 129025 drwxr-xr-x    4 root     root         4096 Jul  2 22:15 .
      2 drwxr-xr-x    4 root     root         4096 Jul  2 22:09 ..
 129026 drwxr-xr-x    3 root     root         4096 Jul  2 22:13 lib
 129032 drwxr-xr-x    2 root     root         4096 Jul  2 22:15 sbin

/usb/usr/lib:
 129026 drwxr-xr-x    3 root     root         4096 Jul  2 22:13 .
 129025 drwxr-xr-x    4 root     root         4096 Jul  2 22:15 ..
 129027 drwxr-xr-x    3 root     root         4096 Jul  2 22:15 ipkg

/usb/usr/lib/ipkg:
 129027 drwxr-xr-x    3 root     root         4096 Jul  2 22:15 .
 129026 drwxr-xr-x    3 root     root         4096 Jul  2 22:13 ..
 129028 drwxr-xr-x    2 root     root         4096 Jul  2 22:15 info
 129035 -rw-r--r--    1 root     root          188 Jul  2 22:15 status

/usb/usr/lib/ipkg/info:
 129028 drwxr-xr-x    2 root     root         4096 Jul  2 22:15 .
 129027 drwxr-xr-x    3 root     root         4096 Jul  2 22:15 ..
 129031 -rw-r--r--    1 root     root           17 Jun 13 15:01 vsftpd.conffiles
 129030 -rw-r--r--    1 root     root          248 Jun 13 15:01 vsftpd.control
 129034 -rw-r--r--    1 root     root          113 Jul  2 22:15 vsftpd.list

/usb/usr/sbin:
 129032 drwxr-xr-x    2 root     root         4096 Jul  2 22:15 .
 129025 drwxr-xr-x    4 root     root         4096 Jul  2 22:15 ..
 129033 -rwxr-xr-x    1 root     root       151163 Jun 13 15:01 vsftpd

And then

root@ap:~#  /usb/etc/init.d/vsftpd start
/etc/rc.common: eval: line 13: vsftpd: not found

Shouldn't the export of PATH and LD_LIBRARY_PATH be in /etc/profile or somewhere else ?

Cheers,
Tex

(Last edited by Tex-Twil on 2 Jul 2008, 21:35)

I also did some minor modification to your script:
- it doesn't tries to start the services if there are no S* files in the rc.d dir
- same for the stop
- some beautification such as variables for the mount device / mount point
- better logging
- ..

Take it or leave it wink
http://openwrt.pastebin.com/f7a9c303f

edit: in the script I forgot to uncomment the         #e2fsck -p $DEV line 60.
Tex

(Last edited by Tex-Twil on 3 Jul 2008, 07:07)

Finally, I think there is another issue:
vsftpd, for example, can't find its vsftpd.conf cons it is looking for it in /etc/ and not /usb/etc/. I guess it will be the same for other config files ..

Tex

Thanks Tex-Twil.  I've taken a few things from that.  Possibly I will extend it to have a defaults/ file to contain the settings.

The couple of things I've installed on the usb drive ( asterisk and xmail) have actually handled it well.  Usually you create an /etc/default/  entry that specified the config file - though it should be created for you.

Submit a patch to the maintainer if it doesn't.

frogonwheels wrote:

Usually you create an /etc/default/  entry that specified the config file - though it should be created for you.

Could you explain more ?

By default, when I install asterisk on /usb, it does 2 things - first is to fill in the line

DEST=/usb/

in the init.d file.  The second is to create a file ${DEST}/etc/default/asterisk  that contains the line

OPTIONS="-C /usb/etc/asterisk/asterisk.conf"

The discussion might have continued from here.