04-28-2011 10:13 PM - edited 04-28-2011 10:22 PM
dm wrote:Hi, check out
http://www.nslu2-linux.org/wiki/Optware/Samba2
for an example of samba stuff
this seems interesting....
i didnt thinkg of other stuff other than logs
Runing samba on FLASH (USB stick) memory
To minimize FLASH wear, redirect all logs and temporary databases to /tmp/samba directories. One way to do is to create startup script like
#!/bin/sh
if [ -n "`pidof smbd`" ] ; then
echo "Stopping smbd:"
killall smbd
fi
if [ -n "`pidof nmbd`" ] ; then
echo "Stopping nmbd:"
killall nmbd
fi
#sleep 2
echo "Starting smbd:"
if [ ! -d /tmp/samba ]; then
mkdir /tmp/samba
mkdir /tmp/samba/log
rm -rf /opt/var/log/samba
ln -s /tmp/samba/log /opt/var/log/samba
rm -rf /opt/var/samba
ln -s /tmp/samba /opt/var/samba
fi
/opt/sbin/smbd -D;
echo "Starting nmbd:"
/opt/sbin/nmbd -D;
@dm,
Cool! I'll add this into the autorun.sh script. Since you've installed opt on your USB drive, you could use iotop to verify if samba only writes to /tmp after you've done this? I've run out of space on /usr/local/etc
and have not tried installation on USB yet.
Regarding user/password, I will see if we can add that restricted access share.
@jea
In the optware-install.sh script, change OPTDIR="/usr/local/etc" to OPTDIR="tmp/usbmounts/sda1" (or whatever the USB drive letter is sdb1, sdc1,...) and it should be enough. samba-install.sh installs to /opt and after you've installed optware,you got /opt mounted to your USB drive already so no change needed.
04-29-2011 03:04 PM
I installed Optware and samba on the flash drive.
Now I have script problems.
Before I did a reboot I ran the S80samba script. When the script finished a PS showed smbd was running but nmbd was not. When I rebooted sda1 was mounted ro so I added a umount and mount to the new autorun script. After the next reboot sda1 was still mounted ro. I manually ran the autorun script and it found sda1, mounted it rw and mounted /opt. I manually ran S80samba script and once again smbd was running and nmbd was not. I did notice that syslogd was running. I added the lines to move the log to tmp and rebooted – no change
The good news is that when I restore the original autorun script and removed the flash drive everything works as before (I haven't remove optware from usr/local/etc).
cat autorun.sh
#!/bin/sh
# start busybox ftp and syslogd
cd /usr/local/etc
./busybox-mipsel tcpsvd -vE 0.0.0.0 21 ./busybox-mipsel ftpd -w / &
./busybox-mipsel syslogd -C200
search_list='sda1 sdb1 sdc1'
search_done=0;
for usb_drive in $search_list; do
if test $search_done -eq 0 && [ -d /tmp/usbmounts/$usb_drive/oleg-optware ]; then
search_done=1;
echo "Found optware on usb $usb_drive";
opt_dir="/tmp/usbmounts/$usb_drive/oleg-optware";
umount -l /tmp/usbmounts/$usb_drive;
mount /dev/$usb_drive /tmp/usbmounts/$usb_drive;
fi;
done;
if test $search_done -eq 1; then
echo "Found optware in " $opt_dir
umount -l /opt
mount -o bind $opt_dir /opt
echo "mounted /opt at " $opt_dir
else
if [ -d /usr/local/etc/oleg-optware ]; then
echo "Found optware in /usr/local/etc";
opt_dir="/usr/local/etc/oleg-optware";
umount -l /opt
mount -o bind $opt_dir /opt
echo "mounted /opt at " $opt_dir
else
echo "oleg-optware not found"
fi;
fi;
exit 0
janderso@PC7:~$
janderso@PC7:~$
cat S80samba
#!/bin/sh
if [ -n "`pidof smbd`" ] ; then
echo "Stopping smbd:"
killall smbd
fi
if [ -n "`pidof nmbd`" ] ; then
echo "Stopping nmbd:"
killall nmbd
fi
#sleep 2
echo "Starting smbd:"
if [ ! -d /tmp/samba ]; then
mkdir /tmp/samba
mkdir /tmp/samba/log
rm -rf /opt/var/log/samba
ln -s /tmp/samba/log /opt/var/log/samba
rm -rf /opt/var/samba
ln -s /tmp/samba /opt/var/samba
fi
/opt/sbin/smbd -D;
echo "Starting nmbd:"
/opt/sbin/nmbd -D;
janderso@PC7:~$
reboot
/ # Connection closed by foreign host.
janderso@PC7:~$ telnet 172.24.80.184
Trying 172.24.80.184...
Connected to 172.24.80.184.
Escape character is '^]'.
Venus login: root
warning: cannot change to home directory
BusyBox v1.1.3 (2010.08.17-14:27+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
/ # mount
/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
none on /proc type proc (rw,nodiratime)
devpts on /dev/pts type devpts (rw)
none on /sys type sysfs (rw)
none on /tmp type ramfs (rw)
/dev/mtdblock/2 on /usr/local/Resource type squashfs (ro)
/dev/mtdblock/3 on /usr/local/etc type yaffs (rw,noatime)
/dev/rd/0 on /mnt/rd type vfat (rw,nodiratime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1)
/dev/mtdblock/3 on /opt type yaffs (rw,noatime)
/dev/scsi/host2/bus0/target0/lun0/part1 on /tmp/usbmounts/sda1 type ext3 (ro)
/ # cd /usr/local/etc
/usr/local/etc # ls -l autorun.sh
-rwxrwxrwx 1 root root 1008 Apr 29 21:09 autorun.sh
/usr/local/etc # ./autorun.sh
tcpsvd: bind: Address already in use
Found optware on usb sda1
Found optware in /tmp/usbmounts/sda1/oleg-optware
mounted /opt at /tmp/usbmounts/sda1/oleg-optware
/usr/local/etc # mount
/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
none on /proc type proc (rw,nodiratime)
devpts on /dev/pts type devpts (rw)
none on /sys type sysfs (rw)
none on /tmp type ramfs (rw)
/dev/mtdblock/2 on /usr/local/Resource type squashfs (ro)
/dev/mtdblock/3 on /usr/local/etc type yaffs (rw,noatime)
/dev/rd/0 on /mnt/rd type vfat (rw,nodiratime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1)
/dev/sda1 on /tmp/usbmounts/sda1 type ext3 (rw)
/dev/sda1 on /opt type ext3 (rw)
/usr/local/etc # cd /opt/etc/init.d
/opt/etc/init.d # ls
S80samba samba
/opt/etc/init.d # ./S80samba
Starting smbd:
Starting nmbd:
/opt/etc/init.d #
04-29-2011 03:50 PM
I fixed the nmbd problem. When I installed to the flash drive I got the unmodified smb.conf. I replaced it with my modified smb.conf and both smbd and nmbd start.
So my only problem appears to be with autorun.sh. If I manually run it and then run the S80samba script I now have samba running from the flash drive.
04-29-2011 05:23 PM - edited 04-29-2011 06:07 PM
@jea,
Im not sure by TO BE SAFE>>>>>>
Always add like
pause 20 or something to the beginning of the autorun.sh
if not and something breaks the system you'll maybe never get in.
this gives a 20second wait before the script runs.
i thnk thats also good to give the time to find everything.
IF things get wierd. POWER OFF (umount something if it never pwoers off and kills the telnet)
then PULL the powerr. try again.
@bodhi,
I actually am using it on the /usr/local/etc now ![]()
i cant make up my mind ![]()
i tried busybox iotop and i did nt see specific directories. what commands should I use?
FOR the password setup, WELL as far as I can tell password user on the samba will need a user on the passwd file, so other than changing the etc password file just
mount bind it from usr/local/etc (make a copy...)
then ADD a user to it, maybe guest or whatever the default is.
I think when I tried with the setting of NOT public, it went to use venus/guest as a user but guest does not exist. So make anew passwd file with guest added with a password of wahtever? then sambapass -add the user?
btw, why do we want syslogd running?
ps...
/usr/local/etc # bin/busybox-mipsel mountpoint /opt
/opt is a mountpoint
/usr/local/etc # bin/busybox-mipsel mountpoint /opt123
mountpoint: /opt123: No such file or directory
/usr/local/etc # bin/busybox-mipsel mountpoint /usr
/usr is not a mountpoint
/usr/local/etc #
@ *
Do we really need to do this every time?
rm -rf /opt/var/log/samba
ln -s /tmp/samba/log /opt/var/log/samba
rm -rf /opt/var/samba
ln -s /tmp/samba /opt/var/samba
, the /tmp DIR will be absant every time we boot right? since its /tmp ..so, that should be more if the ln part doesnt exist in our case?
@Bodhi, how about this to resolve double mount..
### OPTWARE STARTUP
if bin/busybox-mipsel mountpoint /opt ; then
echo /opt already mounted
else
echo Mounting /opt
mount -o bind /usr/local/etc/oleg-optware /opt
fi
###
so no worry to mount if its mounted already? PS this needs the new busybox somewhere...lala
04-29-2011 05:55 PM - edited 04-29-2011 06:02 PM
dm wrote:@jea,
Im not sure by TO BE SAFE>>>>>>
Always add like
pause 20 or something to the beginning of the autorun.sh
if not and something breaks the system you'll maybe never get in.
this gives a 20second wait before the script runs.
i thnk thats also good to give the time to find everything.
IF things get wierd. POWER OFF (umount something if it never pwoers off and kills the telnet)
then PULL the powerr. try again.
@bodhi,I actually am using it on the /usr/local/etc now
i cant make up my mind
i tried busybox iotop and i did nt see specific directories. what commands should I use?
FOR the password setup, WELL as far as I can tell password user on the samba will need a user on the passwd file, so other than changing the etc password file just
mount bind it from usr/local/etc (make a copy...)
then ADD a user to it, maybe guest or whatever the default is.
I think when I tried with the setting of NOT public, it went to use venus/guest as a user but guest does not exist. So make anew passwd file with guest added with a password of wahtever? then sambapass -add the user?
btw, why do we want syslogd running?
@ *
Do we really need to do this every time?
rm -rf /opt/var/log/samba
ln -s /tmp/samba/log /opt/var/log/samba
rm -rf /opt/var/samba
ln -s /tmp/samba /opt/var/samba
, the /tmp DIR will be absant every time we boot right? since its /tmp ..so, that should be more if the ln part doesnt exist in our case?
@dm,
I'm glad it works
IMHO, using the USB flash drive is too much of a hassle. Because the drives move around, currently my USB thumb drive is stuck at sdb1. I think this was because the Ext3 USB thumb drive mounting. And I also experienced a power OFF problem similar to you've reported, only after using the Ext3 drive for a while (I have not even mounted /opt on it). Beside, if anyone wants to run transmission, it's already in optware. ...Wish we have more flash memory then it's a moot point!
I'm not sure, I think we do need the samba log setup like that because the /tmp will be there but it will be empty. I have not tried to pull the power cord to see what will happen.
syslogd does not take up much space, and it's handy when you want to see cron jobs running. I'm setting up one to run every 5 minutes to test one of my theories to keep the FAT+ running 24/7. But other than that, it doesn't show much (hotplug activities did not show up when I run logread).
PS. to run iotop #iotop -o -b -qqq
04-29-2011 06:14 PM
i think you may have missed my edit of
### OPTWARE STARTUP
if bin/busybox-mipsel mountpoint /opt ; then
echo /opt already mounted
else
echo Mounting /opt
mount -o bind /usr/local/etc/oleg-optware /opt
fi
###
04-29-2011 06:27 PM
dm wrote:i think you may have missed my edit of
### OPTWARE STARTUP
if bin/busybox-mipsel mountpoint /opt ; then
echo /opt already mounted
else
echo Mounting /opt
mount -o bind /usr/local/etc/oleg-optware /opt
fi
###
Nice! so this will avoid unmounting /opt and remount, and we dont need to do the search?
04-29-2011 07:08 PM
search.. not sure
Im guessing most people will just use the /usr/local/etc
if someone knows how to format their external SDA as ext3 then they know enough on how to fix the scripts ![]()
other than that, i saw, have a text file in the oleg-optware dir that says _USEME_ ![]()
if that is there mount that opt and not another? no idea.
this is good enough i guess
im still playing with samba passwords
so for i got...
fist in the script...
cp /etc/passwd /opt/etc/passwd
mount -o bind /opt/etc/passwd /etc/passwd
then we can edit passwords for the system.
technically then you can passwd protect your system.
BTW, *** put a pause in your autorun.sh or people may get toasted.... you need enough time to telnet in and rm /usr/local/etc/autorun.sh ![]()
04-29-2011 07:27 PM
/opt # bin/iotop -o -b -qqq
Could not run iotop as some of the requirements are not met:
- Linux >= 2.6.20 with I/O accounting support (CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, CONFIG_TASK_IO_ACCOUNTING): Not found
- Python >= 2.5 or Python 2.4 with the ctypes module: Found
04-29-2011 07:32 PM
You're right about ext3 and people who know how to use it will change the autorun script to deal with it. I'll just leave the autorun.sh like it currently is (no mounting /opt) . So no chance of causing problem ![]()
©2012 Seagate Technology LLC