Synology DS107
From Gentoo Linux Wiki
Fix me:
|
This tutorial was written in September 2007. It describes how to install a chrooted Gentoo on the Synology DS-107 NAS so that we will not break anything.
Firmware version : 0514.
In this procedure, we use the following settings :
- mount point on linux host : public
- nas hostname : nas
- chrooted gentoo root directory on nas : /volume1/public/gentoo
Warning : with this procedure, nas startup time becomes longer because of quota checks. Do not turn off the nas during startup or you might need to reformat the hdd.
This method uses 2006.1 stage (2005.0 stage does not work).
Contents |
[edit] Steps to chroot
Connect to the nas with root credentials. Use Enable ssh patch from synology. Get stage3 archive on your favourite mirror (current ppc32 stages on ftp.proxad.net). Turn of any p2p to fill bandwith.
Also get last portage version :
Uncompress archive :
We also install portage :
Get some info from base system :
Chroot in the new gentoo environment :
Bonus : you can configure bashrc file.
[edit] Fix and Sync
Now we'd like to sync portage...
You can set your own local rsync server so that you will not abuse mirror and benefit from your local network bandwith. In this case, set your own local rsync mirror :
... but sync fails because python is actually broken. We need to manually install python to fix it :
When python is fine, we can use portage. The following commands will emerge portage and almost fix python :
pycrypto is broken :
File "/usr/lib/portage/pym/portage_checksum.py", line 59, in <module>
md5hash = _generate_hash_function("MD5", MD5.new, origin="pycrypto")
AttributeError: 'module' object has no attribute 'new'
... and portage relies on it. So we remove it, the hard way :
Sync should now work.
[edit] Enjoy !
You can now add new services to your NAS.
[edit] openssh
[edit] Basic configuration
Emerge and generate keys (this is usually done in the init.d script, but I am not able to launch it because of the chrooted environment) :
Fix ssh user updating /etc/passwd :
sshd:x:22:22:sshd:/dev/null:/bin/false
Port 5022 Protocol 2 RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys PasswordAuthentication no Subsystem sftp /usr/lib/misc/sftp-server
You might need to fix /var/empty owner :
Mount /dev/pts :
The -4 (ipv4) option is compulsory to avoid the "all ports in use effect".
You can analyze problems adding the -Ded :) options.
On client :
On the nas in /root/.ssh/authorized_keys (copy the line from .ssh/id_rsa.pub) :
And finally :
[edit] Improving ssh service
We need to fix sshd service dependencies : logger and dns. app-admin/syslog-ng will provide logger. We fake app-admin/syslog-ng dependencies creating symlinks in /var/lib/init.d/started/.
We fake net service status :
It is now seen as running :
nas ~ # /etc/init.d/net.eth0 status * status: started
Start sshd service as usual :
nas ~ # /etc/init.d/sshd start * Starting sshd ... [ ok ]
[edit] grenouille
You can configure your nas to update French network weather data with grenouille.
And just update user.config with username and password.
Install ping :
Mount proc if needed :
[edit] Miscellaneous
Other usefull Gentoo packages :
[edit] linux backup with rsync
We mount volume1 in the root of the chroot system. Run under base system :
# /etc/rsyncd.conf # Minimal configuration file for rsync daemon # See rsync(1) and rsyncd.conf(5) man pages for help # This line is required by the /etc/init.d/rsyncd script pid file = /var/run/rsyncd.pid use chroot = yes read only = yes # Simple example for enabling your own local rsync server #[gentoo-portage] # path = /usr/portage # comment = Gentoo Portage tree # exclude = /distfiles /packages uid = nobody gid = nobody hosts allow=192.168.0.0/255.255.255.0 hosts deny=* pid file = /var/run/rsyncd.pid motd file = /etc/rsyncd.motd log file = /var/log/rsync.log log format = %t %a %m %f %b syslog facility = local3 timeout = 300 [root-backup] path = /volume1/public/DED/linux comment = root backup read only = false uid = root gid = root
If you want to backup /etc to the nas :
You can configure backuping for other users :
- Create accounts on the NAS
- Update rsyncd.conf
- Allow ssh connection
- Configure rsync client (exclusions, etc.)
Important note : it seems that the kernel has been patched so that the file system is not aware of case : it is not possible to have two different files with their names only different in case. This may be a problem because afterwards it becomes really hard to remove the files (see Tips)
[edit] automatic startup
Add the following lines to /etc/fstab
none /proc proc defaults 0 0 none /dev/pts devpts defaults 0 0
Fake runlevel :
Fake rc-update data :
Add some services to current runlevel :
List status of all services :
root@nas ~ # rc-status -a Runlevel: boot keymaps [ started ] clock [ started ] urandom [ stopped ] hostname [ started ] net.lo [ started ] localmount [ started ] modules [ started ] checkfs [ stopped ] consolefont [ stopped ] rmnologin [ stopped ] bootmisc [ started ] checkroot [ started ] Runlevel: default local [ started ] net.eth0 [ started ] sshd [ stopped ] netmount [ started ] Runlevel: nonetwork local [ started ] Runlevel: single Runlevel: UNASSIGNED crypto-loop [ stopped ] dropbear [ stopped ] numlock [ stopped ] rsyncd [ stopped ] syslog-ng [ stopped ]
There may be some differences with your rc-status report as I have manually started some services...
We need to fix status of all services from boot level. Only these two ones are really needed :
It is now possible to start all services :
We will use the rc script to start everything. proc will not be automatically mounted. So we will use the following scripts :
#!/bin/sh rm /var/lib/init.d/started/sshd rm /var/lib/init.d/started/rsyncd rm /var/lib/init.d/started/local umount /proc umount /dev/pts mount|grep proc>>/dev/null || mount /proc mount|grep pts>/dev/null || mount /dev/pts /sbin/runscript /sbin/rc>/var/log/init.log 2>&1 screen -d -m -S frog /root/camlgrenouille-1.28/camlgrenouille.command
It does not work if I run /sbin/rc. I need to explicitely call runner (/sbin/runscript) and I also need to redirect output ! I do not have time to fix this now...
I need to unmount /proc and /dev/pts before because I have not searched yet for a better way to either clean mount table or safely unmounting before reboot.
#!/bin/sh /etc/init.d/rsyncd stop /etc/init.d/sshd stop /etc/init.d/syslog-ng stop killall camlgrenouille umount /proc umount /dev/pts exit
And finally, on base system, add the following startup script :
#/bin/sh
if [ "$1" = "restart" ]; then
$0 stop
sleep 1
$0 start
fi
if [ "$1" = "start" ]; then
chroot /volume1/public/gentoo /root/start
fi
if [ "$1" = "stop" ]; then
chroot /volume1/public/gentoo /root/stop
fi
Telnet is not needed anymore : upload the DisableTelnet.pat firmware to your nas. YES !
[edit] Updates
- Upgraded successfully to firmware 0590, 0600 and 0728. Intermediary patches updates were not tested. You will need to create the S99zgentoo.sh startup script again.
[edit] Tips
[edit] File Input/Output Error
- Synology filesystem cannot handle two files in the same directory if they only differ in case :
- ls returns input/output errors in this folder.
- You are unable to remove any of the files.
- Solution :
- Move extra files to another folder.
- Remove the folder with rm -rf.