April 15, 2013

0 My Raspberry Pi Setup Part 1

The whole purpose to use raspberry pi in my house was to use it as a Bittorrent Downloader and File Server.

To know what Raspberry Pi is, go here:

http://www.raspberrypi.org/faqs

Raspberry Pi runs linux operating system. To know more about it, go here:

http://www.linux.com/learn
http://www.ibm.com/developerworks/linux/newto

I have it currently set up a simple set up as follows on my Model B RasPi.


Attached is:
1 16 GB Class 10 Transcend SD Card.
1 8 GB USB drive.
1 16 GB USB drive.
Network cable connected to my Router.
Power supply (Of course)

More powerful power supply will allow you to connect USB HDDs without additional power supply. For ex. if you connect a Samsung Phone Charger with 700 mA, you won't be able to connect external HDD without additional power supply.
I connected LG Charger that came with my Nexus 4, which produces 1.2 A output, seems to make my 1 TB WD external HDD work with the Pi.

Software Setup:
Raspbian OS (Previously I tried Arch, but I found raspbian nicer.)
LVM (Logical Volume Management)
Transmission BT
youtube-dl


Initial Configuration:

Installed Rasbian OS on my Pi. To know how to do that go here: 

http://elinux.org/RPi_Easy_SD_Card_Setup

By default, Raspberry Pi allows SSH access with the default username pi and password raspberry. I accessed it directly from the network.

Configure root password

 sudo passwd root  

command will allow you to change your root user password so that you can login using root account.
I always use root account and have never logged in using pi account.

Be careful. Logging in using root and performing incorrect operations may cause unstable OS or crash.


Configure Static IP address

To configure static IP address I simply edited my /etc/network/interfaces file that now looks like this:


 auto lo  
 iface lo inet loopback  
 iface eth0 inet static  
  address 192.168.0.10  
  netmask 255.255.255.0  
  gateway 192.168.0.1  
  dns-nameservers 124.124.5.140 8.8.8.8  

Then issued command

 service network restart  

Re-connected to my raspberry pi using new static IP address.

Update the pi

 apt-get update && apt-get -y upgrade  

Its always good to have this run first time, before you do anything.


The LVM setup

OK. The idea behind configuring LVM on my pi was nothing but to combine all the space available on different partitions to form a single logical volume and mount it at a single point, so that I can keep huge stuff inside single mount point.
Here's how my fdisk -l looks like:

Note: Removed information that is not required as of now.

  root@raspberrypi:~# fdisk -l   
  Disk /dev/mmcblk0: 16.1 GB, 16130244608 bytes   
  4 heads, 16 sectors/track, 492256 cylinders, total 31504384 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: 0x00014d34   
    Device Boot  Start   End  Blocks Id System   
  /dev/mmcblk0p1   8192  122879  57344 c W95 FAT32 (LBA)   
  /dev/mmcblk0p2   122880  7454718  3665919+ 83 Linux   
  /dev/mmcblk0p3   7454719 31504383 12024832+ 8e Linux LVM   
  Disk /dev/sda: 8166 MB, 8166703104 bytes   
  224 heads, 63 sectors/track, 1130 cylinders, total 15950592 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: 0x000ae796   
   Device Boot  Start   End  Blocks Id System   
  /dev/sda1   2048 15950591  7974272 8e Linux LVM   
  Disk /dev/sdb: 16.0 GB, 16008609792 bytes   
  64 heads, 32 sectors/track, 15267 cylinders, total 31266816 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: 0x5ea0a18f   
   Device Boot  Start   End  Blocks Id System   
  /dev/sdb1   2048 31266815 15632384 8e Linux LVM   

OK. So there's three devices.
First memory card that RasPi boots from, Second the 8 GB USB and third 16 GB USB drives. /dev/mmcblk0, /dev/sda and /dev/sdb respectively.

There's two partitions on /dev/mmcblk0p1 and /dev/mmcblk0p2 used for RasPi itself. The third one was created by me. Note that the type of partition is Linux LVM. Similar partitions created on USB drive but only one on each that lie on full drive.

To know how to create a partition on a disk go here:

http://www.tldp.org/HOWTO/Partition/fdisk_partitioning.html

To know about LVM go here:


http://tldp.org/HOWTO/LVM-HOWTO/anatomy.html

Now, we need a volume group.


# vgcreate /dev/mmcblk0p3 /dev/sda1 /dev/sda2  
 volume group datavg created.  
# lvcreate -l 100%FREE datavg  
 logical volume lvol0 created.  
# mkfs.ext4 /dev/datavg/lvol0

vgcreate will combine space from /dev/mmcblk0p3 /dev/sda1 /dev/sda2 to create a single Volume group.

lvcreate will create a logical drive out of that volume group.

mkfs.ext4 will create an ext4 filesystem on the logical volume.

We need to mount this new logical volume.


#  mkdir /data  
# mount /dev/datavg/lvol0 /data  
# chmod 777 /data  

So our new filesystem which comprises space from three devices, will be accessible on /data partition.


Now, we need this logical volume to be mounted across each reboot. To make it happen, ran following command.



# cp /etc/fstab /etc/fstab.bak  
# echo /dev/datavg/lvol0 /data ext4 defaults 0 2 >> /etc/fstab  

We're done!

I will write another article to describe how I installed software and its configuration.

April 11, 2013

1 Making you SD card work with your Ubuntu / Linux Laptop or Desktop

You insert you SD card in your Ubuntu PC and it simply does not work. Most probably your kernel has not loaded module required for recognizing your SD card.

You must run all commands in this post as root.
[Optional] : To run commands as root run command "sudo su root" and to switch user as root.

First check if your PC detects the SD Card controller.
For that run command
lspci | grep -i sd


  root@ubuntu:~# lspci | grep -i sd   
  23:00.1 System peripheral: JMicron Technology Corp. SD/MMC Host Controller (rev 30)   
  23:00.2 SD Host controller: JMicron Technology Corp. Standard SD Host Controller (rev 30)   

As you can see above, my PC recognised JMicron SD Card controller.

To make your OS load module for SD Card controller, simply run these commands.



  root@ubuntu:~# echo tifm_sd >> /etc/modules   
 root@ubuntu:~# echo mmc_block >> /etc/modules   


And then reboot. Your OS should recognise your SD card.

September 14, 2012

0 Publish SSH Server through TMG

Yet another dumb but useful post.

Here's how I did it.

If you have a look at all the protocols available in Forefront Threat Management Gateway Toolbox, SSH is there, but it is outbound.

TMG forwards only inbound protocols. So, You will have to create a new protocol definition with nay name you like, port 22 and "inbound". And then create a non-web server protocol publishing rule.

It seems dumb but ate my 10 minutes.

That's it.
 

Kaustubh Ghanekar Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates