Saturday, December 21, 2013

Rsync + SSH - no password




Install rsync
For Ubuntu or Debian
# apt-get install rsync
For SUSE or Fedora# yum install rsync
rsync without prompting for password:
Assuming the file server is ServerF and backup server is ServerB

Genarate the public key in ServerF
$ ssh-keygen
$ Enter passphrase (empty for no passphrase):
$ Enter same passphrase again:

The public key will be generated and stored in
~/.ssh/id_rsa.pub

Copy public key to remote host
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.1.100
Or
ssh-copy-id -i ~/.ssh/id_rsa.pub "root@192.168.1.100" -p123
Or

Open id_rsa.pub, copy the content
Login to ServerB using the same user in the rsync command
In ServerB, append the contents to ~/.ssh/authorized_keys. Create the file if not exist. Make sure the file mode is 700.

Is it possible to run ssh-copy-id on port other than 22?
Rsync with SSH without prompting for password

Sunday, December 15, 2013

Microsoft Windows - Client Operating Systems - API unity


Why Microsoft needs three or more operating systems

   A common operating system core, with common APIs and capabilities, is inevitable, and it is logical. Microsoft might even start to use common branding, most likely with Windows Phone becoming just "Windows." But that doesn't mean that it won't actually have three operating systems. Windows on a phone will be different from Windows on a tablet—in much the same was as iOS on the iPhone is different from iOS on the iPad. The user interface will be tailored to the form factor, making the two close siblings but not identical.

This will result in Windows for ARM phones, Windows for ARM tablets, and Windows for x86/x64 PCs. One might even make a case for a fourth to be added into the mix: Windows for x86 phones.

More exotic is the Xbox One operating system. This has no branding of its own, as it's never decoupled from the Xbox One hardware


A completely different API? That’s a different OS !


The operating system that is meaningfully different is Windows Phone. Windows Phone 7 used Windows CE (Microsoft's lightweight, customizable, embedded operating system) as its kernel. At the time, Windows CE was Microsoft's only ARM-compatible operating system, and the company had considerable experience using it on smartphones (as it was also used in Windows Mobile). This seemed like a sensible decision. Third-party applications were built using a modified version of Silverlight with a .NET environment .


For Windows Phone 8, Microsoft wanted to use the NT kernel. The NT kernel is more capable and is where most of Microsoft's development effort is spent, so this made sense for the company (if not for end users). Since the development of Windows RT meant that the Windows software stack ran on ARM, there was no longer any reason to stick with Windows CE. Accordingly, Windows Phone 8 shares major parts with Windows 8, with low-level components such as the network stack and security infrastructure in common between the operating systems.

To support existing Windows Phone 7 apps, Windows Phone 8 included essentially the same Silverlight environment. New applications for Windows Phone 8, however, didn't use the Silverlight environment. They have a couple of options: a new .NET environment similar to the old Silverlight one (though this time built on the full .NET runtime and notably missing the XNA 3D graphics API that the Silverlight system supported) and native code C++ with Direct3D.

Significantly, Windows Phone apps can't use Windows' Win32 API. Nor can they use most of the new WinRT API.

Developers wanting to share code between their phone and tablet software aren't completely out of luck: it's possible to write .NET code that conforms to a common subset of functionality that's available on both Phone and regular Windows (producing what are called "Portable Class Libraries"). Windows Phone 8 also gives C++ developers access to a limited subset of the WinRT API (sometimes called WinPRT), and large parts of Direct3D. Sources speaking to Paul Thurrott claim that overall, there's about a 33 percent commonality between the phone and non-phone operating systems.

This makes Windows Phone 8 a strange orphan operating system. Windows Phone 8 has few APIs in common with either Windows or Windows RT, so while iOS and Android phone apps can also be used on iOS and Android tablets, Windows Phone apps are strictly for the phone alone !

Universal binariesMicrosoft is currently pushing the notion of universal binaries that would let developers create a single app that can run both on Windows RT and Windows Phone. Where Windows Phone 8 has 33 percent "API unity" with Windows RT, Windows Phone 8.1 will hit 77 percent.

Saturday, December 7, 2013

Fedora 19 : S.M.A.R.T. - SMARTd - SMARTctL - SMARTmonTools - gSMARTcontroL




Monitoring Hard Disks with SMART

When a failure is anticipated by S.M.A.R.T., 
the user may choose to replace the drive to avoid unexpected outage and data loss.

Fedora comes with a "smartd" service that will email root if serious problems are detected on disks.

[root@server ~]# yum provides smartd
Loaded plugins: langpacks, refresh-packagekit
smartmontools-6.1-1.fc19.x86_64 : Tools for monitoring SMART capable hard disks
Repo        : fedora
Matched from:
Filename    : /usr/sbin/smartd

smartmontools comes with two programs:
   - smartctl : meant for interactive use
   - smartd   : continuously monitors S.M.A.R.T.


Check smartctl daemon service
   # service smartd status



[root@abxrds ~]# 
[root@abxrds ~]# service smartd status
Redirecting to /bin/systemctl status  smartd.service
smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon
   Loaded: loaded (/usr/lib/systemd/system/smartd.service; enabled)
   Active: active (running) since Fri 2013-12-06 22:27:46 EET; 2h 30min ago
 Main PID: 9625 (smartd)
   CGroup: name=systemd:/system/smartd.service
           └─9625 /usr/sbin/smartd -n -q never

Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb, type changed from 'scsi' to 'sat'
Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb [SAT], opened
Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb [SAT], ST2000DM001-9YN164, S/N:Z1E2JV3Q, WWN:5-000c50-04f5f87f8, FW:CC4G, 2.00 TB
Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb [SAT], found in smartd database: Seagate Barracuda 7200.14 (AF)
Dec 06 22:27:46 abxrds smartd[9625]: Device: /dev/sdb [SAT], WARNING: A firmware update for this drive is available,
Dec 06 22:27:46 abxrds smartd[9625]: see the following Seagate web pages:
Dec 06 22:27:46 abxrds smartd[9625]: http://knowledge.seagate.com/articles/en_US/FAQ/207931en
Dec 06 22:27:46 abxrds smartd[9625]: http://knowledge.seagate.com/articles/en_US/FAQ/223651en
Dec 06 22:27:47 abxrds smartd[9625]: Device: /dev/sdb [SAT], is SMART capable. Adding to "monitor" list.
Dec 06 22:27:47 abxrds smartd[9625]: Monitoring 2 ATA and 0 SCSI devices
[root@abxrds ~]# 

To ensure that your drive supports SMART, type:
smartctl -i /dev/sda 

SMART will also give you a lot of detailed information about the drive : 
smartctl -a /dev/sda

[root@gate ~]# smartctl -a /dev/sda
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.11.6-200.fc19.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate SV35
Device Model:     ST2000VX000-1CU164
Serial Number:    S1E2D65T
LU WWN Device Id: 5 000c50 062131fc0
Firmware Version: CV22
User Capacity:    2,000,398,934,016 bytes [2.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    7200 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Sat Dec  7 00:38:33 2013 EET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
without error or no self-test has ever 
been run.
Total time to complete Offline 
data collection: (   97) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine 
recommended polling time: (   1) minutes.
Extended self-test routine
recommended polling time: ( 223) minutes.
Conveyance self-test routine
recommended polling time: (   2) minutes.
SCT capabilities:       (0x10b9) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   113   099   006    Pre-fail  Always       -       54914664
  3 Spin_Up_Time            0x0003   095   095   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       43
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   069   060   030    Pre-fail  Always       -       9313921
  9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       1483
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       43
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
188 Command_Timeout         0x0032   100   100   000    Old_age   Always       -       0
189 High_Fly_Writes         0x003a   072   072   000    Old_age   Always       -       28
190 Airflow_Temperature_Cel 0x0022   066   065   045    Old_age   Always       -       34 (Min/Max 22/35)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       15
193 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       -       43
194 Temperature_Celsius     0x0022   034   040   000    Old_age   Always       -       34 (0 17 0 0 0)
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%      1482         -
# 2  Short offline       Completed without error       00%      1478         -
# 3  Short offline       Completed without error       00%        42         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

[root@gate ~]# 


Check the overall health:
smartctl -H /dev/sda
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.11.6-200.fc19.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED



Testing a Drive


You may run any type of test while the drive is mounted although there may be some drop in performance. There are three types of test that can be conducted on a drive:
  1. Short
  2. Extended (Long)
  3. Conveyance
To find an estimate of the time it takes to conduct each test, type:
sudo smartctl -c /dev/sda 

The most useful test is the extended test (long). You can initiate the test by typing:
sudo smartctl -t long /dev/sda 

Results


You can view a drive's test statistics by typing:
sudo smartctl -l selftest /dev/sda 

Suggested application: GSmartControl

[root@gate ~]# yum install gsmartcontrol
Loaded plugins: langpacks, refresh-packagekit
Package gsmartcontrol-0.8.7-2.fc19.x86_64 already installed and latest version