Wednesday, November 28, 2012

Running Rsync as Daemon on Centos 6.2

Configuring /etc/rsyncd.conf
# mcedit /etc/rsyncd.conf
max connections = 2
motd file = /etc/rsync.motd
log file = /var/log/rsync.log
pid file = /var/run/rsync.pid
lock file = /var/run/rsync.lock
timeout = 300
[Test] comment = "Backup Testing" path = /mnt/share uid = root gid = root list = true use chroot = no read only = no list = yes auth users = root, merkurius, venus, jupiter secrets file = /etc/rsyncd.secrets hosts allow = 192.168.1.0/255.255.255.0
Creating the secrets file on /etc/rsyncd.secrets, and add the usernames and the passwords, one per line, separated by a colon (:)
# mcedit /etc/rsyncd.secrets
root:password merkurius:Password venus:passworD jupiter:PassWord
Finally, change the permission of this file so it can't be read or modified by other users.
# chmod 600 /etc/rsyncd.secrets
Edit /etc/xinetd.d/rsync
# mcedit /etc/xinetd.d/rsync
service rsync { disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += USERID }
Testing from Localhost
# rsyncd root@localhost::
Test "Backup Testing"
or
#rsync rsync://root@localhost
Test "Backup Testing"
Testing from another computer
# rsync -avzr root@192.168.77.194::Test /tmp/test/
Password:******* receiving incremental file list ./ new.txt sent 76 bytes received 216 bytes 83.43 bytes/sec total size is 71 speedup is 0.24
As another user : merkurius
# rsync -avzr merkurius@192.168.77.194::Test /tmp/test/
Password:***** receiving incremental file list ./ install.log sent 81 bytes received 8707 bytes 2510.86 bytes/sec total size is 35011 speedup is 3.98
Check Result
# ls -al /tmp/test/
total 48 drwxr-xr-x 2 root root 4096 Nov 28 17:08 . drwxrwxrwt. 14 root root 4096 Nov 28 17:01 .. -rw-r--r-- 1 root root 34940 Nov 28 17:08 install.log -rw-r--r-- 1 root root 71 Nov 28 16:57 new.txt
As shown above, all file are belong to root, because we specify uid and gid as root, when rsync run as daemon, we can specify which user and group owns the files that are transfer from and to.

Done

Monday, November 26, 2012

Playing MKV Files On Windows Media Player 12 On Windows 7 64 Bit

You will need to install all this application.
1. Install the latest stable version from ffdshow tryout, because some aplication still running on 32 Bit, so i download all ffdshow version :
3. Install Win7DSFilterTweaker

Configuring
1. Running Win7DSFilterTweaker



Here's my setting for Preferred Decoders, checked all ffdshow checkbox (uncheck all Microsoft checkbox).



For Microsoft Codec Tweaks, i disabled all Microsoft Audio and Video Decoder, both 32 Bit and 64 Bit



And for the last setting, i did nothing to it :D


Done

Thursday, November 22, 2012

OpenWRT - miniDLNA Server

Install folowing packages
# opkg install minidlna
# opkg install luci-app-minidlna
Edit /etc/config/minidlna
# vi /etc/config/minidlna
config minidlna 'config'
        option port '8200'
        option inotify '1'
        option notify_interval '900'
        option serial '12345678'
        option model_number '1'
        option root_container '.'
        option album_art_names 'Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg'
        option interface 'eth0,wlan0'
        option friendly_name 'My DLNA Server'
        list media_dir 'media_dir=A,/home/dlna/audio'
        list media_dir 'media_dir=P,/home/dlna/picture'
        list media_dir 'media_dir=V,/home/dlna/video'
        option db_dir '/home/minidlna/db/'
        option log_dir '/home/minidlna/log/'
        option enabled '1'
Make sure miniDLNA run everytime router booting
 # /etc/init.d/minidlna enable
Start miniDLNA using this command
# /etc/init.d/minidlna start
Use this command to force scan your DLNA server
# /usr/bin/minidlna -f /tmp/minidlna.conf  -d -R
To stop miniDLNA using this command
# /etc/init.d/minidlna stop
Now Open windows Media Player and browse to your DLNA server.




My miniDLNA Setting




OpenWRT - Proftp Server

Install Proftp server
# opkg install proftpd
Edit /etc/proftpd.conf
# vi /etc/proftpd.conf
ServerName "ProFTPD Server" ServerIdent on "FTP Server ready." ServerType standalone DefaultServer on DefaultAddress 127.0.0.1 RequireValidShell off Port 21 UseIPv6 off Umask 022 MaxInstances 10 User nobody Group nogroup AuthUserFile /etc/passwd DefaultRoot /home AllowOverwrite on MaxClients 10 MaxClientsPerHost 10 MaxClientsPerUser 10 MaxHostsPerUser 10 DeleteAbortedStores on UserAlias anonymous ftp
Adding new user for ftp account by editing /etc/passwd, in my case i added user openwrt, copy paste configuration from user ftp, but change user ID number and group name.
# vi /etc/passwd-
root:$1$nvFplbd8$l05HR0mdTHcGprNaMg8QA1:0:0:root:/root:/bin/ash daemon:*:1:1:daemon:/var:/bin/false ftp:*:55:55:ftp:/home/ftp:/bin/false network:*:101:101:network:/var:/bin/false nobody:*:65534:65534:nobody:/var:/bin/false openwrt:*:65538:55:openwrt:/home:/bin/false
Adding password for user openwrt
# passwd openwrt
Enabling proftpd service upon start
# /etc/init.d/proftpd enable
To start proftpd service
# /etc/init.d/proftpd start
To stop proftpd service
# /etc/init.d/proftpd stop
Now start proftpd for debug and access it using ftp client and see if any errors
# proftpd -n -d 10
If everything ok, you should see something similar with this picture when accessing proftpd server


Done

OpenWRT - Samba Server

Install samba36-server and luci-app-samba
# opkg install samba36-server
# opkg install luci-app-samba
Edit /etc/config/samba
# vi /etc/config/samba
config samba
        option name 'OpenWrt'
        option workgroup 'WORKGROUP'
        option description 'OpenWrt'
        option homes '0'

config sambashare
        option name 'dlna'
        option read_only 'no'
        option users 'diantokam'
        option create_mask '0777'
        option dir_mask '0777'
        option path '/home/dlna'
        option guest_ok 'yes'

config sambashare
        option name 'hidden$'
        option users 'diantokam'
        option read_only 'no'
        option create_mask '0777'
        option dir_mask '0777'
        option path '/home/old'
        option guest_ok 'yes'
Edit /etc/passwd and add user diantokam,copy paste user nobody configuration, leave everything same as user nobody, except for user ID and group name.
# vi /etc/passwd
root:$1$nvFplbd8$l05HR0mdTHcGprNaMg8QA1:0:0:root:/root:/bin/ash daemon:*:1:1:daemon:/var:/bin/false network:*:101:101:network:/var:/bin/false nobody:*:65534:65534:nobody:/var:/bin/false diantokam:*:65535:65534:diantokam:/var:/bin/false
Create password for user diantokam
# passwd diantokam
Adding diantokam to samba user
# smbpasswd -a diantokam
Enable samba service on startup
# /etc/init.d/samba enable
To start samba service
# /etc/init.d/samba start
To stop samba service
# /etc/init.d/samba stop
To accesses samba share from windows type \\samba_server_name on address bar, in my case it is \\openwrt



or using  \\ip_address in my case, it is \\192.168.1.1



and insert username and password for diantokam that you give for smbpasswd



Done.

How to Creating Partition table on linux using fdisk

I will create two partitions, the first one for data and one for swap, for data I would use 8 GB. while the remaining 500 MB for the swap. let's get started: D I need to know, where is my disk attached, there is a lot way to know, where is my device attached, but here i use my way :D
# dmesg | grep blocks:
   sd 2:0:0:0: [sda] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB)
   sd 3:0:0:0: [sdb] 16777216 512-byte logical blocks: (8.58 GB/8.00 GiB)
Or
# cat /proc/partitions
   major minor  #blocks  name
   8        0   20971520 sda
   8        1   10240000 sda1
   8        2    1024000 sda2
   8        3    9706496 sda3
   8       16    8388608 sdb
Or
# fdisk -l
Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table
Oke, i know my new disk attached to /dev/sdb and i can start creating partititon table on my new disk with following step :
# fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe690b018

Start creating first partition, which contains 8GB  data and 500 MB swap
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): +8000MB 

Creating swap partition
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (975-1044, default 975):
Using default value 975
Last cylinder, +cylinders or +size{K,M,G} (975-1044, default 1044):
Using default value 1044

Choosing swap file type for partition number 2
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Write all what you done :D
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
Check what you done :D
# fdisk -l /dev/sdb
Device Boot      Start        End      Blocks   Id  System
/dev/sdb1           1         974     7823623+  83  Linux
/dev/sdb2         975        1044      562275   82  Linux swap / Solaris
Done

Wednesday, November 21, 2012

OpenWrt Attitude Adjustment (Trunk) Exrootfs (Jail Break)

First, plug your external drive to linux and follow this step. Update your packages database
$ opkg update
   Downloading http://192.168.77.246:8080/Packages.gz.
   Inflating http://192.168.77.246:8080/Packages.gz.
   Updated list of available packages in /var/opkg-lists/attitude_adjustment.
Install following package
$ opkg install kmod-usb-core # Kernel support for USB
$ opkg install kmod-usb2 # Kernel support for USB2 (EHCI) controllers
$ opkg install kmod-usb-ohci #Kernel support for USB OHCI controllers
$ opkg install kmod-usb-storage #Kernel support for USB Mass Storage devices
$ opkg install block-mount
$ opkg install kmod-fs-ext4 # Kernel module for the filesystem with which you formatted the partition you want to mount
$ opkg install fdisk # utility to create partitions table
To install package, you can always you this syntax
$ opkg install package_name
Before you step forward, you must prepare your disk partition, i choose fdisk for creating partition table, and i make 3 partition table, two partitions for my data and one for swap file. you can see here for instruction using fdisk. Now, it is time to create filesystem on it, i choose ext3.
$ mkfs.ext3 /dev/sda1 for my data
$ mkfs.ext3 /dev/sda2 for my openwrt rootfs
$ mkswap /dev/sda3 for swap
Next step is create mount point and edit /etc/config/fstab, so every time you restart router, everything back as before :D
$ mkdir -p /home --> mount point /dev/sda1
$ mkdir -p /mnt/rootfs --> mount point /dev/sda2
Editing /etc/config/fstab, my fstab file looks like this
$ vi /etc/config/fstab
config global 'automount'
        option from_fstab '1'
        option anon_mount '1'

config global 'autoswap'
        option from_fstab '1'
        option anon_swap '0'

config mount
        option target '/home'
        option device '/dev/sda1'
        option fstype 'ext3'
        option options 'rw,sync'
        option enabled '1'
        option enabled_fsck '0'
 
config mount
        option target '/mnt/rootfs'
        option device '/dev/sda2'
        option fstype 'ext3'
        option options 'rw,sync'
        option enabled '1'
        option enabled_fsck '0'

config swap
        option device '/dev/sda3'
        option enabled '1'
Reboot it, after reboot check your mount point
$ df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    1.1M    652.0K    436.0K  60% /
/dev/root                 2.0M      2.0M         0 100% /rom
tmpfs                    14.3M    148.0K     14.1M   1% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/mtdblock3            1.1M    652.0K    436.0K  60% /overlay
overlayfs:/overlay        1.1M    652.0K    436.0K  60% /
/dev/sda1               916.5G    477.8G    392.2G  55% /home
/dev/sda2                97.3M      4.1M     88.1M   4% /mnt/rootfs
Check swap
$free
             total         used         free       shared      buffers
Mem:         29220        24864         4356            0         1660
-/+ buffers:              23204         6016
Swap:        98936          456        98480
Exrootfs - Whole external root (pivot root) Do this on openwrt console
$ tar -C /overlay -cvf - . | tar -C /mnt/rootfs -xf -
$ mkdir -p /tmp/cproot
$ mount --bind / /tmp/cproot
$ tar -C /tmp/cproot -cvf - . | tar -C /mnt/rootfs -xf -
$ umount /tmp/cproot
Reboot After Reboot, check your system mount point and swap memory Before
$ df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    1.1M    652.0K    436.0K  60% /
/dev/root                 2.0M      2.0M         0 100% /rom
tmpfs                    14.3M    148.0K     14.1M   1% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/mtdblock3            1.1M    652.0K    436.0K  60% /overlay
overlayfs:/overlay        1.1M    652.0K    436.0K  60% /
/dev/sda1               916.5G    477.8G    392.2G  55% /home
/dev/sda2                97.3M      4.1M     88.1M   4% /mnt/rootfs
After
$ df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                  370.4M     15.4M    335.8M   4% /
/dev/root                 2.0M      2.0M         0 100% /rom
tmpfs                    14.3M     88.0K     14.2M   1% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda2               370.4M     15.4M    335.8M   4% /overlay
overlayfs:/overlay      370.4M     15.4M    335.8M   4% /
/dev/sda1               916.5G    477.8G    392.2G  55% /home
Now you have a lot of space to install any applications :D Enjoy it !!

OpenWRT on TP-Link MR3420 v1.2 (OpenWrt Attitude Adjustment 12.09-beta2)

Here's my experiences using OpenWRT on TP-Link MR-3420, i don't posting detail how to upgrade from TP-Link original firmware to OpenWRT firmware, because i think you should know how to upgrade firmware than continue to configuring your new firmware, don't worry, there is a lot information on the net about upgrading firmware from TP-Link firmware to OpenWRT firmware.

Here what i did with my Router Download Firmware OpenWRT untuk MR3420 versi Attitude Adjustment Versi 12.09-Beta2 For fresh upgrade (from TP-Link to OpenWRT)

openwrt-ar71xx-generic-tl-mr3420-v1-squashfs-factory.bin
openwrt-ar71xx-generic-tl-mr3420-v1-squashfs-factory.bin
For system upgrade (from OpenWRT to OpenWRT)
openwrt-ar71xx-generic-tl-mr3420-v1-squashfs-sysupgrade.bin
openwrt-ar71xx-generic-tl-mr3420-v1-squashfs-sysupgrade.bin
My goal is :
1. Create Rootfs on External Storage (Exroot / Jail Break)
2. Having Samba Server on it
3. Also Ftp server
4. And My DLNA server
5. Oh...My 3GS USB Dongle also must be worked on it, and yes, it worked too, even when i used usb hub

And here's my router and StoreJet


Wireless Router TP-Link MR-3420 v1.2.


Transcend StoreJet 1TB


Huawei E173



And Yes, I can have all of it !!