Archive

Archive for the ‘Blog’ Category

Linux RAID

November 18th, 2009
Comments Off

Recently one of the guys that works next to me got me hooked on ripping full DVDs instead of converting them to XviD (AVI) format. The pros include the video quality is better and you get all the special features. Cons are that each DVD is between 4 and 8GB for 4-6 shows.

I was already running out of space on my 2x 1TB drives so I decided to go all out and build a server with 4x 1TB drives and 2x 500GB drives. I made the 4x 1TB drives into a RAID-5 for a total of 3TB usable space but with redundancy so I don’t lose all my content if one of the drives fails. The 500GB drives were put into a RAID-1 (mirrored) which is where I keep my pictures and important documents.

Once the server was up and running I wanted to be able to share those drives with my Windows machines so I could watch the movies/TV shows in any room from Media Center. This was another issue since Windows doesn’t nativly support the ext file system which Linux uses. For this I ended up using Samba for simple network sharing, and mkfs.ntfs which allows Linux to read/write NTFS file systems.

Digging around the internet it took me about 2 days to get all the information about how to get the system working exactly how I wanted it. Here are the steps I followed.

Part 1: Creation of the RAID

Start by installing all of the required software

$ sudo apt-get install samba
$ sudo apt-get install mdadm
$ sudo apt-get install mkfs.ntfs

Samba is for user authenticated sharing made simple. Mdadm is used to create and manage the RAID systems and mkfs.ntfs allows Linux to read/write to an NTFS system.

Next we need to find out what disks are available and what their labels are. This is needed for when the RAID is actually created. For this tutorial I will be showing the steps for making a 4TB RAID-5 (4x 1TB HDDs).

Start by finding out which drives we will be using.

$ cat /proc/diskstats

This command will display the hard drives connected to the computer. For this tutorial I will be using /dev/sda, /dev/sdb, /dev/sdc, and /dev/sdd.

Next run fdisk for each of the drives to partition, set type to RAID, and format.

$ fdisk /dev/sda

Press nспални and enter to create a new logical partition. Remember the cylinders used because each disk needs to be the exact same size. Next press p for primary partition and 1 to create partition 1. Next it will ask you for the start and stop partitions. Just accept the default for both. Next press t for type and fd for RAID. This defines the drive as part of a RAID. Finally press w to write the changes to the drive.

Repeat these steps for the other drives (sdb, sdc, and sdd).

Once you have all of the drives partitioned and defined as a RAID you need to create the software RAID in Linux.

To do this run the following command:

$ sudo madadm --create --verbose /dev/md0 --level=5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

This will create the RAID in /dev/md0 as a level 5 using 4 drives which are sda1, sdb1, sdc1 and sdd1 (the 1 at the end specifies the partition on the drive).

Now the RAID is being built. This will take a long, LONG time. I like to let this run overnight and continue the next morning. Keep in mind that the bigger the drives, the longer this process will take. You can watch the process status by typing:

$ watch cat /proc/mdstat

Now we need to tell mdadm to manage the RAID. Most sites I read said I only needed to run the command with sudo, but I found that I had to run it as root (sudo -i).

$ sudo -i
$ mdadm --detail --scan >> /etc/mdadm/mdadm.conf

The RAID array is now created and located in /dev/md0. Now we need to format the drive. Normally you would format it using ext3 (mkfs -j) or something similar but since we want to easily access it from our Windows machines we will need to format it with the NTFS file system. Follow the prompts as they are pretty self explanitory. When asked how to format it, choose quick instead of full.

$ sudo mkfs.ntfs /dev/md0

Now the RAID is created, formatted and ready to use. To start accessing it we first need to mount it. I like to put mine in my media folder. Replace RAID5 with whatever you want it to be called.

$ sudo mkdir /media/RAID5

Now we want it to mount automatically when we boot, right? I use gedit but you can also use nano.

$ sudo gedit /etc/fstab

Add this line to the bottom of the file:

/dev/md0 /media/RAID5 auto defaults 0 3

Now when you reboot the drive will be mounted. To mount it immediately instead of restarting type:

$ mount -a

Copy any files you want to the drive. All files will be backed up across the drives so if one fails you don’t loose all of your information.

Part 2:  Folder Sharing

All finished right? Not quite. We still need to be able to access this from our windows machines over the network. Start by setting a network user/pass for the drives. This is usually set to the same user/pass as the current user that is logged in. I didn’t want this since I was running MyMovies which requires all network folders to have the same user/pass.

First turn off user share only so that we can share folders that we don’t own. This way you don’t have to log in as root every time you want to share a folder.

$ sudo gedit /etc/samba/smb.conf

Find [global] and below that enter usershare owner only = false. Now you can share any folder you want to.

Start by making a new username for the shared drive.

Next set the shared folder password for that user (replace $USER with the username if it is different than the current username which is logged in). Leave the password blank if you want to use the same password for that username. If you want a different password than what they log in with, replace <password> with it. Here is the guide which may answer any questions.

$ sudo smbpasswd -a $USER <password>

Now share the folder

Part 3: Copying Files

http://sonniesedge.co.uk/?p=80

http://mywheel.net/blog/index.php/software-raid-in-ubuntu/

azlon Blog, Ubuntu, Video , , , ,

Use your PC as an Alarm Clock

September 29th, 2009

I have an older HP Pavilion d9600 in my bedroom as a Media Center. The 17″ screen seems to be ideal when paired with the docking station to elevate it an give some larger speakers. One problem I had was that I was having to use my phone as an alarm clock. After about a month of this I got tired of it and decided to find an alternative way using the PC.

There are many alarm clock solutions out there but I wanted something full of features. After trying 5 or 6 different solutions I found Atomic Alarm Clock v5.87 which did everything I needed. This software allows you to set multiple alarm clocks at any interval on any day. This was perfect for me since I work one set of hours Monday – Wednesday and another set of hours on Saturday and Sunday.

Key Features:

  • I love being able to set any MP3 as the alarm (I use the beep.mp3 which comes with it)
  • I also love the ability to gradually increase the volume until you turn it off. This makes for a better wakeup for me.
  • Another feature I like is that it can launch any program when the alarm goes off.
  • It will also wake up your computer from sleep/hybernate! Perfect for my power settings.

The Problem: The only problem I had with the program is that it normally becomes the focus window when the alarm goes off, but doesn’t take focus when Media Center is open. As a result I would have to minimize Media Center, then turn off the alarm. I wanted to be able to just hit the OK button on my remote to turn off the alarm. Since I always fall asleep to a TV show or movie (I have my Vista power settings set so that the computer will go to sleep after 1 hour and hibernate after 2) and have the alarm wake the machine up, I was sick and tired of minimizing Media Center.

The Solution: After googling for about 30 seconds I found the command to end a program. I set Atomic Alarm Clock to run tskill with a parameter of ehshell. Now when the alarm goes off, it closed Media Center for me and makes the alarm dialog the primary window. A quick fumble for the remote and a tap of the OK button and everything is perfect!

Click here to download it: Atomic Alarm Clock (60)

azlon Blog, HTPC ,

AFN RSS to iCal Feed

September 22nd, 2009

A few weeks ago I built a new machine from spare parts here at work. I decided to bring in my own TV tuner so I could record shows from the AFN network on post then take them home and watch them that night. One problem I ran into was how difficult it was to find out when a show was on which channel because of the time differences and inaccuracies of the guide channel.

I found out that there is actually an RSS feed at MyAFN.net. I figured it could easily be converted into an iCal feed and I could just throw it into my Google Calendar. After several days of tinkering with Yahoo Pipes I was finally able to get it working.

Give it a try!

Here is what the main pipe looks like:

Click to see larger image

Click to view the pipe

azlon Blog, Video , , , ,

Updated the TV Shows RSS Feed

June 21st, 2009

vntv-pipe Mininova recently started filtering copyrighted material on their site. This is a shame because it was my main source for downloading TV shows. Since my selection of content is rather limited here in Kuwait the feed was my lifeline back to real world entertainment.

While some content is still available, the reliability was horrible. I tried a few other sources to get my content (TVRSS, FeedMyTorrents, ShowRSS) but everything seemed to have issues (either the site was blocked in Kuwait or the content was limited). Then I came across an article by David Segonds where he used Yahoo! Pipes to create a reliable feed straight from the source, EZTV. I copied his pipe and used it as the source for my pipes which clean up the names and make things a little more user friendly. Since I was already messing with the feed, I decided to take it a little further and add more content.

After a couple days of tinkering I was able to pull the episode name and air date from epguides.com. Since epguides also links to TV.com for each episode I went ahead and pulled the episode description from there. I am finally happy with the outcome even though not all shows have the details (since epguides.com is user maintained and not always 100% up to date).

As one finishing touch I stopped blocking 720p content and simply added (HD) to the end of the show name. This should make it easy to filter out if anybody doesn’t want the large files showing in their feeds. I also allow duplicate posts for shows, which are rare, because I want to be able to download the one with the most seeds. This can also be easily blocked.

Take a peek at it and let me know what you think in the comments. If there is anything I should add, remove or change just let me know. I am always looking for ways to improve it.

In the future I will be implementing some of theTVDb.com’s API features and hopefully some zap2it.com and IMDB features as well.

Here are links to each of the pipes used in the process:

Finished VNTV Feed: http://pipes.yahoo.com/spazlon/tvshows
Source feed (EZTV.it):
http://pipes.yahoo.com/spazlon/neweztv
Episode details (epguide.com):
http://pipes.yahoo.com/spazlon/epguide
Episode description (TV.com):
http://pipes.yahoo.com/spazlon/epsummary

Quick Tip: Looking for a way to make the most of the feed? Take the VNTV Shows feed and add it to your raman amplifierGoogle Reader. In your reader go to Settings, Folders and Tags, and select private next to Your Starred Items. This will create a RSS feed of your starred items. To get your starred items RSS feed click view public page and copy the atom feed. Paste that feed in your uTorrent RSS feeds and select Automatically Download. Now when you are at work  catching up on the hottest articles on Lifehacker and you see a show you want to download in your reader, simply star the show and it will automatically start downloading at home.

azlon Blog, HTPC, VNTV , , , ,

Subtitle Rips

March 14th, 2009

This is a quick video I threw together about how to RIP subtitles using SubRip (125).

Get the Flash Player to see the wordTube Media Player.

azlon Blog