Archive for the ‘linux’ Category
I know you must be banging your head against the wall over this. I did.
Make sure use are logged in as the user you want to give ssh permission to:
su sshuser cd ~/
All you need to do is fix the permissions and owner on .ssh and authorized_keys:
chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys chown sshuser:sshuser ~/.ssh chown sshuser:sshuser ~/.ssh/authorized_keys
This should do the work.
For over a year I used Buffalo Linkstation Duo Pro with 2x1TB mirrored drives. It served me well, but it was starting to gradually fill up – pictures, videos, taxes/documents, more pictures. And there were other things I wanted to move from my local drives, but still needed them to be accessible on-demand – ISOs – Linux, Windows, IDE installers, Old code etc. And then was wife’s music collection, docs etc.
Judging from above I came up with following requirements:
1. At least 4-6TB space. Future proof for 3-4 years
2. Gigabit Network Capable. I’m done with slooow speed NAS
3. Expandable. Add more space as needed.
There were three options available:
Plan A – Buy new NAS drive(s) – solves the problem for now. Average cost $300
Plan B – Build a new low power PC, install FreeNAS or something similar. Move the old NAS drives to this and add more drives. Around $300-$500
Plan C – Purchase Cloud Storage subscription – varies, from monthly to year plans.
Considering the requirements, clearly my options were limited to Plan B. Plan A and Plan C were pre-baked solutions that did not offer me what I really needed. Plan B meant I needed to spend some time for this project.
I’m a big fan of Micro Center because I can pickup components as and when I need them. Also, they offer pretty good deals and match NewEgg’s prices – minus the shipping costs. Returning stuff is hastle free as well.
So I started looking for best motherboard to get the job done. Essentially, I was looking for a mordern (but not latest and greatest) mobo that had 6 SATA ports, on board graphics chip and a gigabit ethernet. So, I picked up the cheapest one – Gigabyte GA-78LMT-S2P for $43 after MIR, Sempron 145 – 45W, Diablotek EVO Mid Tower ATX case, a 500W power supply and 2x1TB drives.
After spending sometime with the board, I realized that there is a known issue with the GA-78LMT-S2P – it fails to recognize the drives when switched to AHCI mode!! So back I returned it and got the next in line Asrock 880GM-LE FX. This one cost me $10 more, but has a better graphics chip (HD 4250). Not that I would need it. I installed the CPU and spare 4GB ram that I had. Sempron’s can be unlocked to a dual core CPUs, this one didn’t. But that was OK since I needed less power hungry machine. Then I plugged in four drives (500GB, 750GB, 2x1TB new drives)
I Initially installed FreeNAS on a 8GB flash drive. Now, all my drives were ntfs and soon enough I ran into issues. Drives were failing to mount since they had errors – threre is no way to fix them on linux. These needed to be fixed by connecting them to a windows machine and running
CHDISK /force. I took a step back(read below), and thought that if all my drives are ntfs why not run windows instead? More over Windows 8 has this new feature so that you can run it off a usb drive!
At least 32GB is needed for Windows-To-Go. Which meant I need to buy a 32GB flash drive. So I did – Sandisk Glide 32 GB. Installing windows 8 on the flash drive is real pain. With help of GImageX you can copy the install.wim image on to the flash drive. The copy took around 90 minutes!! Argh! Booting from the flash drive and initial setup took around 30 minutes more! Also, using windows-to-go is really really really slow. I cannot stress it enough. Partly the issue was the Sandisk Glide drive but I think more due to how windows worked. It kept hammering the flash drive. I read that USB 3.0 will improve the speed a little and in any case my 880GM-LE FX board didn’t have it. Finally I gave in.
So where was I? I have to convert all my drives to etx3/4 and move around few TB of data. Before I returned the 32GB flash drive, I CHDISK’d all my drives so at least they would mount on
FreeNAS PartedMagic. Then I connected the new drives, formatted them to ext4 and copied over the data to new drives, formatted the nas drives to ext4 and copy back the data from new drives. Same for the old 500GB and 750GB – rinse repeat.
FreeNAS vs OpenMediaVault:
In short, OpenMediaVault is what you want. Stable, functional and actively developed.
Returned the dreadfully slow Sandisk Glide and installed OpenMediaValut on 8GB Kingston G3 drive.
Configured the shares and ftp. For detailed setup please read this blog
The last but not the least goal was to have gigabit copy speeds. I set the 9K MTU on the interface using the web interface and I was all set. I get around 80Mb/s copy speeds which I’m pretty satisfied.
I ended up removing the 500GB drive and moving all the important documents to it. I will pair that with another 500GB in a Raid 0 configuration. With 5 drives, I now have almost 4.75 TB of space. With 5 more drive slots to go - it can continue to expand as needed.
As an engineers we are always on a quest to solve problems and in the process we sometimes over-engineer things. I think this to be true in this case. However, the new NAS would be good for another 3-4 years.
I use gentoo linux on my laptop (G1S-A1). Everything is working including wireless, bluetooth, media keys etc.
The only thing that annoys me is when I use skype beta (with video) or any other webcam utility. The webcam image is 180° inverted!! I know it sounds funny..but its annoying after a while… Anyway, as usual I set out on the quest to find out the cause and possible remedy. A quick lsusb gives tells me that the device id and vendor id information.
localhost ~# lsusb
Bus 002 Device 001: ID 0000:0000
Bus 007 Device 002: ID 0b05:1712 ASUSTek Computer, Inc.
Bus 007 Device 001: ID 0000:0000
Bus 006 Device 001: ID 0000:0000
Bus 005 Device 002: ID 046d:c521 Logitech, Inc.
Bus 005 Device 001: ID 0000:0000
Bus 001 Device 003: ID 0b05:1726 ASUSTek Computer, Inc.
Bus 001 Device 002: ID 174f:5a35
Bus 001 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
To get more information about the webcam from vendor/device id
localhost ~ # lsusb -v -d 174f:5a35
iManufacturer 2 Sonix Technology Co., Ltd.
iProduct 1 USB 2.0 Camera
I tried to google the combination of device id and sonix to find any information about the camera. But it turned out that there is no such device manufactured/assembled by Sonix. I was curious and I thought lets see what the windows driver for this webcam has to say. I rebooted into Vista and bingo! the device information clearly mentions D-Max/Sonix 1.3M pixel camera. All the description regarding their camera modules can be found their website. Two weeks ago I was able to find the module along with device id mentioned. Unfortunately today I’m unable to locate the 5A35 module on that page because all the camera modules have generic names now(e.g 1.3M_UVC 5). I couldn’t find any cached page on google either. Looks like they D-Max doesn’t want to disclose that information.
On further digging through windows driver files, snp2uvc.inf (version 04/18/2007, 6.21.70.001) reveals some cool information.
%SN.USBVideo.DeviceDesc% = SN.USBVideo.XP,USB\VID_174f&PID_5a35 ;GD-5A35A(Ov9655)
%SN.USBVideo.DeviceDesc% = SN.USBVideo.XP,USB\VID_174f&PID_5a31 ;GD-5A31A(MI1320)
%SN.USBVideo2M.DeviceDesc% = SN.USBVideo2M.XP,USB\VID_174f&PID_5a51 ;GD-5A51A
%SN.USBVideoVGA.DeviceDesc% = SN.USBVideoVGA.XP,USB\VID_174f&PID_5a11 ;GD-5A11A(Ov7670)
Hmm…After searching for GD-5A35A I found this cached link that links 5A35 to the generic model number that is 1.3M_UVC 1. So, here are the specifications:
1.3M_UVC 1 USB 2.0 1.3MP Camera Module Support UVC
• SXGA Resolution Image Sensor
1280 x 1024, 1280 x 800
1204 x 768, 800 x 600
640 x 480, 352 x 288
320 x 240.
640 x 480 at 30fps maximum
1280 x 1024 at 8fps maximum
•Video Format: YUY2
•DOF on 30~80cm
•Auto White Balance Control
•High Speed USB 2.0 Interface
•Low Power Consumption
•Dimension(LxWxH) 60 x 8.5 x 7.05mm
On careful inspection of snp2uvc.inf you can see that my webcam uses OV9655 sensor – cool! And the datasheet for that can be found here: http://rapidshare.com/files/94672360/OV9655-datasheet.pdf.html
Interestingly the newer version of the webcam driver doesn’t specify the sensor (OV9655) or the model number (GD-5A35A) information.
Most of the datasheet information went over my head except some interesting bits.
If you skip to “Register Set” and checkout register 1E :
1E MVFP 00 RW Mirror / Vertical Flip Enable Bit[7:6] Reserved Bit Mirror 0: Normal Image 1: Mirror Image Bit Vertical Flip 0: Vertical Flip Disable 1: Vertical Flip Enable Bit[3:0] Reserved
Default value for bit is 0, i.e VFlip is disabled. We get upside down image which means that the webcam module is installed upside down on G1S-A1, so the linux uvc driver must find a way to set the bit of this register.
I’m reading through uvc-linux source to understand the driver and make appropriate changes. But it can take sometime… Sole purpose of this blog entry is to inform you guys about my findings, so someone with the right knowledge can add the vflip support for this webcam.
So you want to have your linux GUI to look uber cool huh?
Remember last time when you installed linux on your home PC? If you are like me, probably you spent atleast a week before you feel comfortable with the settings and customizations. You make sure that all the required tools and applications installed. Like Firefox, OpenOffice, Mplayer and so on. But, no matter what you do linux GUI dosen’t look consistent! All the apps don’t use same fonts, font-sizes. The UI components look different for different apps etc. Probably you know the reason: All the applications in linux use different GUI toolkits. The two most commonly used toolkits are GTK and QT. So, what? Well they rely on different redering techniques unique to the toolkit. This gap between the two can be bridged by installing GTK-Qt Theme Engine.”The GTK-Qt Theme Engine is a plug-in for GTK that allows GTK applications to use Qt widget styles.”
Most of the Linux distros have GTK-Qt Theme Engine available as a package.
Install it :
Gentoo: emerge x11-themes/gtk-engines-qt
Ubuntu: apt-get install gtk-qt-engine
Fedora: yum install gtk-qt-engine
Once you done with that. Use it from KDE control center.
Find a screenshot from my Gentoo machine here.
Now it’s time to fix the fonts. The rendering of the fonts depends on following things:
- Screen Size (17″, 19″, 20″ etc.)
- Screen Resolution (1024×768, 1280×1024, 1680×1050 etc.)
- Dots per Inch or DPI in short (http://en.wikipedia.org/wiki/Dots_per_inch)
- Freetype’s Byte Code Interpreter switch
- Sub Pixel Rendering (http://en.wikipedia.org/wiki/Subpixel_rendering)
- Font Hinting
Dots per pixel:
“Dots per inch (DPI) is a measure of printing resolution, in particular the number of individual dots of ink a printer or toner can produce within a linear one-inch (2.54 cm) space.”. Modern monitors support DPI = 96×96 or sometimes more. Though 96×96 is enough to get good quality fonts.
The screen size, screen resolution and the DPI all are related by the following equation:
For monitor width in millimeters to achieve DPI of 96:
x = (25.4 x resolution width in pixels)/96
Same for monitor height in millimeters:
y = (25.4 x resolution height in pixels)/96
Do I need the above x and y values?
If you have NVidia graphics card, you don’t have to do the above calculation. You can tell the nvidia driver to calculate it for you.For this specify the following in /etc/X11/xorg.conf under device section:
Option “UseEdidDpi” “FALSE” #
Option “DPI” “96 x 96″ # specify these two lines
If you have an ATI graphics card, the graphics drivers sucks. So we have to tell it what to use. For example you have monitor with native max resolution 1280 x 1024:
(25.4 x 1280)/96 = 338.6
(25.4 x 1024)/96 = 270.9
For this specify the following in /etc/X11/xorg.conf under monitor section:
DisplaySize 338.6 270.9
After this restart your X. press Ctrl + Alt + F1, then if promted enter login info and enter following command:
In the next part, I’ll will continue with beautifying fonts in linux.
Recently I was involved in a project that involved java code accessing native c++ libraries. All went fine from creation of the JNI functions to its implementation. In one of the functions has java.nio.ByteBuffer as parameter. On the java side this buffer was initialized using allocateDirect. On the c++ side, the buffer content is altered and size gets reduced. The limit is changed using limit(int). I managed this all using cout/printfs/err to print the debug information.
I put up a screen cast (without voice) for anyone who needs to watch this method inaction. Download this video from here: http://www.hotlinkfiles.com/files/1266155_p61kq/jni-debug.divx
Short description of the same:
So, I really needed to look at the live data. Hence needed a way to debug JNI c++ code. So, as everyone else I turned to Google. Finally this article described the need for dual debuggers. I understood that we need to start the java application that uses jvm in debug mode (-Xdebug). We also need to make sure that Eclipse and Visual Studio co-operate. So we need the -Xrunjdwp jvm argument. This will specify the protocol and port address where Eclipse (remote java application) will listen to.
So, open the JNI C++ VS 2005 project and navigate to project->settings->debugging. in command specify the path to java.exe, in command arguments add this:
-Xmx400m -Xms400m -Xdebug -Xnoagent \
-Djava.library.path=”[path to debug folder containing JNI DLL]” \
-cp “.;[path to folder containing .class files for he java app]” \
[main java class]
And then set break points in the c++ code.
Then we need to create a remote java application configuration in Eclipse. Specify the port number (in this case 8000). Also in my case I had to add java source directory where Eclipse will search for the java code of the remote application. This is done from the source tab. Once done add break points where the java application loads the native library and where you call the native function.
Then start debugging the VS project (f5). The java application will be in suspended mode (because suspend=y argument) and wait for external debugger to attach. So, start the Eclipse’s remote java application configuration that we created in debug mode. And start debugging!