Sunday, October 14, 2012

My DIY NAS (1)

I'm building my own NAS. A off-the-shelf NAS that has more than 4bays is pretty expensive, so I would rather build my own. To keep things cheap and flexible, I'll be installing Linux, and using software RAID.


The loot.
Parts:
Case: Lian Li PC-Q25
PSU: Silverstone 400W
Processor: Intel Core i3 3220
Motherboard: Asus P8H77-I (it's mini-ITX)
RAM: 2x 4GB DDR3
HDD: 7x3TB 2.5" Toshiba (7200rpm)
HDD: 750GB 2.5" WD Black (7200rpm)
PCIe card: MSI Star SATA6 Expansion card (Marvell SE9128)


I didn't want to build one that is too big, so I opted for the PC-Q25 which is a ITX case. It can take in 7 3.5" drives and 1 2.5" drive, and has 2 case fans. The power draw required would probably be low. I'm wary of cheap PSU, while the Silverstone 400W might be a wee bit overkill. It has 3 4-pin molex and 4 SATA power pinout. I had to use the 4-pin molex splitter for the case fan -- the motherboard only has a single connection for  the case fan, while the casing takes in 3 4-pin molex for the 4 drives. 
   
The PSU has 3 4-pin molex. Needed to use a splitter.

The processor doesn't need to be that powerful, core i3 ought to be enough. The motherboard I chose has 6 SATA ports. Most ITX boards have only 4 or 5 ports. I wanted to max out the case, so I have added a PCIe SATA expansion card. I didn't need an expensive card that supported other features since I'll be running software RAID. After I installed Ubuntu 12.04, I did receive DRDY messages. Probably due to the NCQ errors for drives that were connected through the card. Didn't get the messages after I added GRUB_CMDLINE_LINUX_DEFAULT="libata.force=1:noncq libata.force=2:noncq"  to /etc/defaults/grub. I will elaborate more on this in my next post.

As for RAM, 8GB is probably overkill. But well, RAM is cheap...
Tight tight tight...
Initially I wanted to use a USB thumbdrive as the boot/root drive (for the OS), but it turned out to be unstable (sometimes I couldn't boot into it, sometimes it just loads and stops there). In the end I've gotten a 2.5" WD Black instead.

Ok, the hardware is set up, my next post(s) will be on setting up the software (Ubuntu 12.04LTS and other stuff).

Thursday, March 1, 2012

Some notes about getting started with Amazon AWS

I'm a noob in regards to AWS. Some of my notes here for a friend who will be using the AWS for his website. Please correct me if I'm wrong...


For a start, creating an instance is getting a machine for use. Going through the creation of a new instance (with the classic instance):
  • you need to choose a AMI (Amazon Machine Image). Basically it's a choice of operating system you need. In my case, I choose Amazon's Linux AMI (it's based off CentOS anyways).
  • choose the instance type. I'm a cheapo trying out the free tier - so it's a Micro instance for me. I have no preference for the availability zone.
  • I'll just have the default Kernel ID and RAM Disk ID. Tags (Key and Value) for the instance I'll just leave it blank for now.
  • Creating key pair if you don't have any that you want to use. It's important to (download and) keep the private key, as you will need it later on.
  • Configure security group. It's about the firewall policy for the machine. As I want just the Apache server service to be facing the internet, I'll just create a new security group and then add the Rule for SSH and HTTP. I'll just leave the source as it is for now (0.0.0.0/0)
  • Launch!

Other notes:

By default the public DNS for your instance is something like: ec2-somenumbers.ap-southeast-1.compute.amazonaws.com. If you prefer a nice public IP, you can get the Elastic IP:  
  • Allocate a new address
  • then associate the address with your instance
Note that you will need to pay if the address you obtained is not associated with any instance.
The Route 53 service is for more complicated use case. :)


Connecting to the instance when you got a Windows computer:
  • Grab the PuTTY and PuTTYgen software
  • PuTTYgen is needed cos you need to convert your private key (myprivatekey.pem) to a format which PuTTY can use
  • PuTTY to connect to your instance thru SSH
  • You can use Filezilla to connect (and upload files) to your instance. Need to add keyfile thru Edit > Settings > Connection > FTP > SFTP

To update the system and install the Apache and php:
sudo yum update
sudo yum install httpd php
The root folder for the website is in /var/www/html . You should be able to see a sample landing page at your instance's public DNS address.
Check out CentOS documentation/guides if you wanna do anything else which you are unsure of.


Persistent Storage:
Creating the instance (with Amazon's Linux AMI) would also create a 8GiB volume in the Elastic Block Store (EBS). This volume would be GONE if you terminate the instance. If you want something a more permanent store (other than S3), you can:
  • Create new volume
  • Attach the new volume to your running instance, which it will appear as /dev/sdX in the instance
  • which then i would use fdisk to create partition, mkfs for the filesystem, then mount it.
  • Edit /etc/fstab if you want the partition to be auto-mounted on start.
For the free tier, you have 30GiB of EBS to play around.


ElasticFox is pretty cool extension for Firefox. You need the credentials in order to access your aws panel. Citation: http://manavg.wordpress.com/2010/12/27/amazon-ec2-and-elasticfox/

That's it for now I guess.

Wednesday, May 4, 2011

Language input (and disable IPv6) for my Kubuntu 11.04 desktop

Setting up a Kubuntu (or any other distro/flavour) is a one time pain - and things have gotten easier. But still work has to be done... It's not difficult, but it's troublesome for me to find the information time and again - so might as well blog it. I'm covering language input, disable IPv6 here. I'm on Kubuntu 11.04 btw.


Added Japanese/Chinese input

In the KDE menu, run System Languages. Select the languages (in my case, Chinese and Japanese) you want, and check the input methods and extra fonts. It doesn't end there - this GUI method is still not perfect yet. I needed to append this to my ~/.bashrc
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
You might wanna restart your X session (log out, log in) and then see if there's a language input icon. If there's isn't, just run ibus-daemon. There's a need to add the languages to the input as there isn't any set by default: go to Preferences -> Input Method -> Select an input method (say, Japanese -> Anthy) -> Add. This will provide the language option when pressing Ctrl-space. やったー!


Disabling IPv6

The reason for me to disable IPv6 is that the kernel does sometimes take time to look up IPv6. Maybe I'm wrong on this, but well, no harm done if it isn't. I'm running on SSD and I want things to be fast. Just append to /etc/sysctl.conf
#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Ok, done.


I've also noticed the my DVD drive delayed my boot up time by a lot (though it seems to be still working as per normal). Saw the Emask error when i run dmesg (happened to my other hard drives before, which eventually they died. zzz). I replaced the DVD drive with a new one and lengthy bootup problem was solved. Here's the error message for your reference.
[ 34.000061] ata7.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
[ 34.000065] ata7.00: failed command: IDENTIFY PACKET DEVICE
[ 34.000070] ata7.00: cmd a1/00:01:00:00:00/00:00:00:00:00/00 tag 0 pio 512 in
[ 34.000071] res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
[ 34.000073] ata7.00: status: { DRDY }
[ 34.000076] ata7: hard resetting link
[ 34.550049] ata7: softreset failed (device not ready)
[ 34.550053] ata7: applying SB600 PMP SRST workaround and retrying
[ 34.750059] ata7: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[ 34.752058] ata7.00: configured for UDMA/100
[ 34.752784] ata7: EH complete

Wednesday, April 27, 2011

New SSD for desktop and "Clocksource tsc unstable" issue

Gotten a new SSD for my system - the Intel 320 120GB. Decided to reinstall my desktops, so I also spent time on looking for optimizations for my kubuntu (11.04) desktop. There's quite a number of posts out there on this topic, I found a SSD checklist pretty neat - but I lost the link (gah, combination of Blogger and my stupidity - I saved the draft with the link -> Blogger gave me a META error when I tried to publish the post -> I cut and pasted the content into a text editor, forgetting that it's plain text -> Saved the draft and lost the link. If only Blogger has a certain version control). Here's an alternative one. It even explains what you are actually doing too. I admit I cheated by using windows 7 to create the partitions - 1) going thru fdisk is a bit troublesome and requires calculation. 2) (kde) partition manager does not align the default starting cylinder at 64k. 3) gparted probably does the alignment correctly - but somehow not all the time for me. Time to be pragmatic.

As I'm dual booting, I installed Windows 7 first. After all the updates and stuff, it takes around 15 seconds to boot. There's also tweaks for Windows, such as turning off hibernation to save disk space on the tiny SSD. Great.

===

Next, I installed the Kubuntu 11.04. However it seems to boot up slower than Windows by a lot, varying from 15s to a few minutes! It sucks to be not able to see the verbose booting (why did the developers take that option away? Let me know if you know the answer to do it - It used to be ALt-F2 I think?), booting with/without the splash and verbose option doesn't help too. Anyway, I ran dmesg and noticed this
[ 3.970543] generic-usb 0003:08BB:2706.0004: input,hidraw3: USB HID v1.00 Device [Burr-Brown from TI USB Audio DAC ] on usb-0000:00:12.0-3/input2
[ 207.671545] Clocksource tsc unstable (delta = -188978571100 ns)
Seems that the default clock source for the kernel is off. 200 seconds wait is really...wtf? I solved it by adding clocksource=hpet to the booting entry. It's a temporary fix. To make the fix permanent, change the entry in /etc/grub/default
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash clocksource=hpet"
and then run grub-update to update the kernel listing.

Now it's much faster than before. It's probably a problem that existed earlier, yet I had never noticed.

Thursday, March 24, 2011

Preventing my Debian desktop to mount my MTP/MSC device as MTP

Done this before some time ago, and I've forgotten about it. Then the issue bites back at me. So might as well blog it in case I forget again. I looked around on the net, and most of the solutions were pointing me to disabling MSC instead of MTP.

I don't like MTP. The Sony NWZ-E438 I've gotten recently is both MTP/MSC. If you were on Windows, you could see this device mounted as an external drive (MSC) and also as MTP in Windows Media Player.

In Debian (or probably other Linux desktop as well), the computer will identify this device as MTP, and preventing it to be mounted as MSC.

So what I'm doing here is to not let HAL identify the device as MTP. The file at/usr/share/hal/fdi/information/20thirdparty/20-libmtp8.fdi has the entries for the different mp3 players. Just comment out the entry for your device.

>If the libmtp8.fdi file doesn't exist in that location, you could try finding it
find /usr -name *libmtp*
Can't find your device in the list? lsusb would give you the ID, my device gives:
Bus 002 Device 002: ID 054c:0385 Sony Corp.
Then find the corresponding entry in 20-libmtp8.fdi and comment out the entire entry by adding at the end.

Maybe there's a better way of doing this (blacklisting the mtp module? or just delete the fdi file?), as that fdi file could get updated from system updates. If you know a better solution, let me know. :)

Monday, January 11, 2010

New year, changes that I can believe in.


I still have approximately 1/2 year more before I graduate with a degree in comp sci. Quite a few changes to my life at the turn of the year, mainly:
  • Quit my part time job selling apples (the job's fine, but I lacked the time to code!) Gonna write a fun game from now. ;D
  • Cleaned up quite a bit of my room, less clutter (but still a wee bit too cluttered, gonna work on it. And keeping my desk neat at the end of every day.
  • Changed the location of my mouse to left handed, my right wrist still hurts since I fell and landed on it around a year ago.
  • etc.
I'm gonna spend more time on coding and have convinced myself to purchase a new monitor (despite the tight budget I'm working with). My current one (17") isn't really big enough, especially when I'm using virtual machine + looking at the documentations, google, etc. And hey, having 2 monitors is the 1st item on The Programmer's Bill of Rights.

This year, my personal motto would be "Making things happen". Or maybe it should be every year? Cheers.

***
GPGT. Above's the picture of my room. The 2 monitors hooked up to my Kubuntu desktop - running off the onboard HD3200 (AMD 780G chipset), with fglrx. Works kinda smooth, but I turned off the desktop effects for better performance (Video frame-rate wasn't that high with the desktop effects turned on).

Friday, November 20, 2009

Installing Dropbox on 64 bit Kubuntu 9.10 (KDE4.3)

Just did a clean reinstall on my desktop and laptop. Syncing documents between different computers can be a pain (and sometimes I need to grab the files without my computer), so I decided to use the Dropbox service to hold my documents. Like any other service... PLEASE DO BACKUPS other than relying solely on the service, though Dropbox hasn't failed me yet.

If you haven't got an account with Dropbox yet, feel free to use this referral link. I'll get more space. :3 Now for the guide proper:



The default Dropbox package for Ubuntu pulls in stuff from Gnome (nautilus), which I don't really need for my Kubuntu desktop. So here's what a did, based on this guide.

Open the command line (konsole, terminal) to download the dropbox for your platform. I'm using the 64 bit version. If you are using 32bit, just leave the _86 out.
$ wget -O dropbox.tar.gz http://www.getdropbox.com/download?plat=lnx.x86_64
Extract the file
$ tar zxof dropbox.tar.gz
If necessary, say the files were not extracted to your home directory,
$ mv .dropbox-dist ~/.dropbox-dist
Basic installation is done, so I will 1) run it, and 2) make Dropbox start when my desktop starts.

1) Run Dropbox
$ ~/.dropbox-dist/dropboxd &
You should see the Dropbox icon in the system tray... and so configure it accordingly. ;)

2) Under (KDE) System Settings > Advance (tab) > Autostart.
Click on "Add Program", and type in the full path. In my case it's
/home/ensheng/.dropbox-dist/dropboxd
Also check the box for "Run in terminal". Ok, done. Try rebooting and see if the Dropbox starts automatically.. it should. Enjoy. ;)