DiskStation Hacks¶
Various hacks for DiskStations.
Enable Telnet¶
Those who are familiar with Linux and want to poke around in the system, I provide (again, no warranty and such) a patch to enable telnet access on the DiskStation (any model, any firmware release known so far). Instructions on how to use this are in the included README.txt file.
- syno-telnet-r4.zip (8 kb)
See also EnableTelnet at Synology’s wiki.
This patch has an advantage over Synology’s EnableTelnet.pat
(and DisableTelnet.pat
). At least the versions I looked at would overwrite /etc/inetd.conf
and therefore destroy any other changes you might have added (rsyncd
, svn
, etc.).
Bash¶
The bash(1) shell that installs with Optware seems not to work as expected regarding the .bashrc
and .bash_profile
files. The culprit seems to be Synology and not Optware.
Bash login shells (i.e. bash --login
or bash setup via /etc/passwd
) load /root/.bash_profile
for all users. This is because the DS does not correctly set $HOME
for the user logging in. $HOME
is always /root
independent from who is logging in. /opt/etc/profile
is not loaded.
You could use something like this:
In /etc/passwd
I have a line for me:
flip:x:1026:100:flip:/volume1/flip:/opt/bin/bash
I set up the necessary links to load /opt/etc/profile
for all cases (i.e. bash --login
and bash
with correctly and with incorrectly set $HOME
).
ln -s /opt/etc/profile /root/.bash_profile ln -s /opt/etc/profile /root/.bashrc ln -s /opt/etc/profile /volume1/flip/.bash_profile ln -s /opt/etc/profile /volume1/flip/.bashrc
And my /opt/etc/profile
looks like this:
# # Bash initialisation script # PS1="u@h w $ " PS2="> " PS4="+ " PATH=/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin export PS1 PS2 PS4 LD_LIBRARY_PATH=/opt/lib:${LD_LIBRARY_PATH} export LD_LIBRARY_PATH OUTPUT_CHARSET=latin1 MANPATH=/opt/man:${MANPATH} if [ `/usr/bin/id -u` -eq 0 ]; then HOME=/root else HOME=/volume1/`/usr/bin/id -n -u` fi EDITOR=vim PAGER=less TERM=linux TERMINFO=/opt/lib/terminfo MANPAGER='less -isrR' RSYNC_RSH=ssh export PATH OUTPUT_CHARSET MANPATH HOME EDITOR PAGER TERM MANPAGER RSYNC_RSH TERMINFO alias less='less -ir' alias rm='rm -i' alias ll='ls -l --color=auto' alias la='ls -a --color=auto' alias lla='ls -la --color=auto' alias l='ls -F --color=auto' alias ls='ls --color=auto' alias mc='mc -tac' alias vi=vim # eof
See also bashrc.
And I have an ~/.inputrc
:
# Be 8 bit clean. -> Umlaute, see readline(3) set input-meta on set output-meta on set convert-meta off # command line scrolling set horizontal-scroll-mode on "e[3~": delete-char # this is actually equivalent to "C-?": delete-char # rxvt and konsole (i.e. the KDE-app...) "e[7~":beginning-of-line "e[8~":end-of-line
This works for me in a Cygwin rxvt window using telnet to login to the DS. See also cygwin.
If you use bash(1) from SSODS, it will be automatically setup like this. It will load /volume1/SSODS/etc/profile
.
Swap File on USB Stick / Harddisk Standby¶
Some research on using a USB stick as a swap device have been done in the Slimdevices forum with the aim to solve harddisk standby issues when running SSODS. But it is still unclear if the issue is really related to swapping. A few notes I took while trying to install a swap file on an USB memory stick are available in the dsusbswap document. Since the DS firmware lacks of the necessary tools to manage swap space (mkswap
, swapon
, et al.) these binaries are available for download here. A simple bash(1) script to monitor swapping and paging activity (watch_swap.sh
, alternative: vmstat
) as well as a tool to quickly create large empty files (mkfile
) are included as well.
- ssods-usbswap-20061030.tar.gz (30 kb)
The German c’t magazine has an interesting article about the durability of USB memory sticks (vol. 23-2006, page 136, http://www.heise.de/ct/06/23/136/).
The article suggests that modern USB memory sticks (cigars, as I call them) use sophisticated algorithms to avoid problems with destroyed cells. It’s something like the ‹spare sectors› (or whatever that is called) on SCSI disks (and I think nowadays also on (S)ATA disks). The logic on the cigar will recover data from bad cells and won’t use them any more. I don’t know how many spare cells there are. The algorithm also makes sure that all cells are used and none is used (much) more often than another. So even if you use only 10% or so of the memory, all cells will be used sooner or later. The author of the article has not been able to destroy a cigar trying to write repeatetly to the same file even after 16*10^6 writes. He also says that these algorithms make the «problems» independent from the filesystem in use (although most of them are probably optimised for FAT).
Glem01 has summarised a number of hints regarding harddisk standby on customised diskstations. He runs a mail server, Slimserver and some other programs on his diskstation and managed to make the disk go standby. Read his article «Howto reactivate standby on a tuned Synology DS-106» to find out more. Many thanks, glem01!
- ds-106-standby.pdf (240 kb)
rsync¶
The following setup is used to backup files using rsync(1) (from Optware or from SSODS). dsx
and cs406
are the host names of two DiskStations.
dsx:/etc/inetd.conf
:
44444 stream tcp nowait root /opt/bin/nice -19 /opt/bin/rsync rsyncd --daemon --config=/volume1/BACKUP/rsyncd.conf
dsx:/volume1/BACKUP/rsyncd.conf
:
log file = /volume1/BACKUP/rsyncd.log pid file = /volume1/BACKUP/rsyncd.pid lock file = /volume1/BACKUP/rsyncd.lock hosts allow = 192.168.1.0/255.255.255.0 [cs406] path = /volume1/BACKUP/cs406 comment = backups of cs406 uid = flip gid = users read only = no list = yes hosts allow = cs406
cs406:/opt/etc/crontab
:
0 16,4 * * * flip /volume1/flip/.backup.sh
cs406:/volume1/flip/.backup.sh:
#!/bin/sh date >> /volume1/flip/.backup.log /opt/bin/nice -19 /opt/bin/rsync -rav --delete --stats /volume1/flip rsync://flip@dsx:44444/cs406 >> /volume1/flip/.backup.log # eof
Loading Stuff into ppcboot over Network¶
The ppcboot installed on the DiskStation (DS-106 and CS-406 series) allows loading files into RAM over network. To do so you need a second machine (a DS, or an other Linux machine) that runs
- a RARP server (rarpd(8)),
- and a TFTPD server (tftpd).
If you have a second DS you can take the raprd
binary from Debian. Then, add the MAC and the IP adress of the machine to /etc/ethers
and start raprd
like this:
rarpd -v -e -b /opt/tftpboot
You’ll then need two (I think) dummy files in /opt/tftpboot
(in contradiction to the -b
flag). If the IP address is (in hex) 0x01.0x02.0x03.0x04
the two files would be 01020304.bin
and 04030201.bin
.
Then hook into ppcboot using a serial line (see hardware) and use the rarp
command to load the file, e.g.:
_MPC824X > rarp 3000000 vmlinux.img RARP broadcast 1 TFTP from server 192.168.1.13; our IP address is 192.168.1.101 Filename 'vmlinux.img'. Load address: 0x3000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ##### done Bytes transferred = 1355028 (14ad14 hex) _MPC824X > iminfo ## Checking Image at 03000000 ... Image Name: Linux-2.6.20-flipflip-2 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 1354964 Bytes = 1.3 MB Load Address: 00000000 Entry Point: 00000000 Verifying Checksum ... OK _MPC824X > bootm 03000000 ## Booting image at 03000000 ... Image Name: Linux-2.6.20-flipflip-2 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 1354964 Bytes = 1.3 MB Load Address: 00000000 Entry Point: 00000000 Verifying Checksum ... OK Uncompressing Kernel Image ... OK
The kernel did boot but was lacking support for the SATA port and had wrong boot parameters. So it eventually failed with
VFS: Cannot open root device "hda1" or unknown-block(2,0) Please append a correct "root=" boot option Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0) <0>Rebooting in 180 seconds..
This is on-going research.. :-)
Ultimately we want to load a custom U-Boot boot loader.
See also DS-106 Series.