Wednesday, September 16, 2015

Raspberry Pi 2 Model B–Adding Use 2.5″ Hard Drive - Hitachi Touro 1Tb USB 3.0


If you have a small portable 2.5″ hard drive that draws power from the USB port, you can make this work without the need for an external power supply with the Raspberry Pi. You will be modifying how the GPIO pins on the Pi work, specifically turning pin 38 on (represented by 1). 

This means you can double the current over the USB bus from 600mA to 1200mA so you can actually power external USB devices through the Raspberry Pi itself.
Update to latest firmware:
root@raspime:/# sudo rpi-update
Edit /boot/config.txt
root@raspime:/# nano /boot/config.txt
add this line to the /boot/config.txt
max_usb_current=1Reboot
VerifyCheck gpio38, value should be '1'
sudo bash
root@raspime:/# cd  /sys/class/gpio
root@raspime:/# echo 38 > /sys/class/gpio/export
root@raspime:/# cat /sys/class/gpio/gpio38/value
1
OR
Using the wiringPi gpio command, you can do the following:
To make sure everything in default conditions
gpio -g write 38 0
gpio -g mode 38 out
To increase the limit to 1.2A:
gpio -g write 38 1
Verify
root@raspime:/# gpio -v
gpio version: 2.26
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Raspberry Pi Details:
  Type: Model 2, Revision: 1.1, Memory: 1024MB, Maker: Sony
Check gpio38, value should be '1'
root@raspime:/# gpio -g read 38
1

Raspberry Pi 2 Model B First Setup


Here is my Raspberry Pi 2 Specification :
The Raspberry Pi 2 Model B is the second generation Raspberry Pi. It replaced the original Raspberry Pi 1 Model B+ in February 2015. Compared to the Raspberry Pi 1 it has: A 900MHz quad-core ARM Cortex-A7 CPU, 1GB RAM.
Like the (Pi 1) Model B+, it also has:
  • 4 USB ports
  • 40 GPIO pins
  • Full HDMI port
  • Ethernet port
  • Combined 3.5mm audio jack and composite video
  • Camera interface (CSI)
  • Display interface (DSI)
  • Micro SD card slot
  • VideoCore IV 3D graphics core
I’m using Minibian Wheezy-18022015 from here
The main features of last version (2015-02-18) included in MINIBIAN image are:
  • Kernel 3.18.7+ #755
  • 13 secs boot (on RPi 2)
  • 24 MB RAM used
  • 334 MB disk space used
  • Fit on 512MB SD Card
  • Optimized ext4 file system with swap disabled
  • Support for RPi B, RPi B+ and the new RPi 2
  • Targeted for embedded or server applications (NAS, Web server, electronic applications)
  • 100% full compatbile with officiale release
  • DHCP client enabled
  • SSHD enabled
  • root user enabled (default password: raspberry – please change it a.s.a.p.)
For storage, I’m using 4GB MicroSD Card (Visipro Class 6)
root@raspime:~# fdisk -l
Disk /dev/mmcblk0: 3997 MB, 3997171712 bytes
4 heads, 16 sectors/track, 121984 cylinders, total 7806976 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004a452
        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1              16       97727       48856    b  W95 FAT32
/dev/mmcblk0p2           97728     7806975     3854624   83  Linux
Oke, Next step we are going to “copying” Minibian image (Minibian.img) to Sdcard, please follow step bellow.
  • Download Minibian Wheezy-18022015 from here.
  • Get SD Formatter from here it’s available for Windows and Mac.
  • Get Win32DiskImager from here it’s only available for Windows user, foe Linux user you can use DD tools.
  • Install and then open SD Formatter to format your MicroSDCard, when you are done, go to the next step.
  • Install and then open Win32DiskImager then choose Minibian.img  for Image File and for Device choose your Micro SDCard Drive.
Win32DiskImager
  • When you ready, press Write button and wait it till finish.
  • Done, plug that MicroSDCard to Raspi and boot it.

Monday, June 08, 2015

Linux Advanced Copy ( Modified Original cp Command )

Advanced-Copy is a powerful command line program which is modified version of original cp command. This modified version of cp command adds a progress bar and etc. shortly, it's much better than original cp command. How to get advanced copy on Debian "Wheezy" 7.8 .And this step work and tested. Download all required file all in one from HERE
root@prc-04:/tmp# wget https://www.dropbox.com/s/o9rs7o0l0569iv3/coreutils-8.4-receipt.tar.gz?dl=0
root@prc-04:/tmp# mv -v coreutils-8.4-receipt.tar.gz?dl=0 coreutils-8.4-receipt.tar.gz
Extract it
#root@prc-04:/tmp# tar -zxvf coreutils-8.4-receipt.tar.gz
coreutils-8.4.tar.gz
coreutils-8.4.patch
Extract coreutils-8.4.tar.gz
root@prc-04:/tmp# tar -zxvf coreutils-8.4.tar.gz
Copy file pacth
root@prc-04:/tmp# cp -v coreutils-8.4.patch coreutils-8.4/
`coreutils-8.4.patch' ---> `coreutils-8.4/coreutils-8.4.patch'
Go to coreutils-8.4/
root@prc-04:/tmp# cd coreutils-8.4/
root@prc-04:/tmp/coreutils-8.4#
Patch it
root@prc-04:/tmp/coreutils-8.4# patch -p1 -i coreutils-8.4.patch
(Stripping trailing CRs from patch.)patching file src/copy.c
(Stripping trailing CRs from patch.)patching file src/copy.h
(Stripping trailing CRs from patch.)patching file src/cp.c
(Stripping trailing CRs from patch.)patching file src/mv.c
patch unexpectedly ends in middle of line
Hunk #5 succeeded at 500 with fuzz 1.
Configure
root@prc-04:/tmp/coreutils-8.4#./configure
Make it
root@prc-04:/tmp/coreutils-8.4#make
Once, compilation completes, two new commands are created under src/cp and src/mv. You need to replace your original cp and mv commands with these two new commands to get the progress bar while copying files. Replace original cp and mv file
root@prc-04:/tmp/coreutils-8.4#cp src/cp /usr/local/bin/cp
root@prc-04:/tmp/coreutils-8.4# cp src/mv /usr/local/bin/mv
BUT If you don’t want to copy these commands under standard system paths, you can still run them from source directory like “./cp” and “./mv“.
root@prc-04:/tmp/coreutils-8.4/src# ./cp --version
cp (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjörn Granlund, David MacKenzie, and Jim Meyering.


root@prc-04:/tmp/coreutils-8.4/src# ./mv --version
mv (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Parker, David MacKenzie, and Jim Meyering.
Option to show progress bar while copying, add -g
root@prc-04:/tmp/coreutils-8.4/src# ./cp --help | grep progress

-g, --progress-bar add progress-bar

root@prc-04:/tmp/coreutils-8.4/src# ./mv --help | grep progress

-g, --progress-bar add progress-bar
Copying example.
root@prc-04:/tmp/coreutils-8.4/src# ./cp -g /tmp/test.img /tmp/tes

root@prc-04:/tmp/coreutils-8.4/src# 861.7 MiB / 1.0 GiB[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||--------------------------] 84.1 % Copying at 52.6 MiB/s (about 0h 0m 0s remaining) /tmp/test.img 861.7 MiB / 1.0 GiB[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||--------------------------] 84.1 % Done

Monday, January 19, 2015

Password Protection with htaccess




You can protecting directory on apache web server so no unauthorized people may access it, in here we would like use .htaccess file (there is DOT at front htaccess file name) on apache root directory.

root:# cat .htaccess
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /home/apasswords
Require user anjani
root:# ls -al .htaccess
-rw-r--r-- 1 root root 103 Oct  9 08:38 .htaccess


Make password for user anjani and save it on file /home/apasswords


root:# htpasswd -c /home/apasswords anjani
New password: ******
Re-type new password: ******
Adding password for user anjani
root:# cat /home/apasswords
anjani:jBdra06B5M54.


The password on the appasswords is encrypted


root:# ls -al /home/apasswords
-rw-r--r-- 1 root root 21 Oct  9 14:18 /home/apasswords
Done.