September 5, 2014

0 Kickstart and Hostnames

The basic purpose to use kickstarts is to install numerous systems at a time with given para.
Configuring each system post install is tedious.
I found a workaround (that worked for me on Oracle Linux 6 and RHEL 6 and should most probably work for similar distros) to automate this task post install as well. If you know better solution, drop a comment below.

In the %post% section,

Add this:

 exec < /dev/tty6 > /dev/tty6 2> /dev/tty6  
 chvt 6  

This will switch to the 6th TTY and will drop into interactive shell. This allows installer to ask for information.

Let's try to ask for information:

 echo -n "Enter Hostname: "  
 read HOSTNAME1  
 echo -n "Enter IP Address: "  
 read IPADDR  
 echo -n "Enter Netmask: "  
 read NETMASK  
 echo -n "Enter Gateway: "  
 read GATEWAY  

Now that we have information, we can use the inbuilt cmd to configure the interface. I assumed first interface as eth0 (which it is in most cases. If you are not sure, you might want to add this to automation to detect what interface you have).


  echo -n "Applying network settings..."  
 echo "DeviceList.Ethernet.eth0.BootProto=static  
 DeviceList.Ethernet.eth0.IP=$IPADDR  
 DeviceList.Ethernet.eth0.Netmask=$NETMASK  
 DeviceList.Ethernet.eth0.Gateway=$GATEWAY  
 ProfileList.default.DNS.Hostname=$HOSTNAME1.domain.com  
 ProfileList.default.DNS.Domainname=domain.com" > /tmp/network-config  
 system-config-network-cmd -i -f /tmp/network-config &> /dev/null  
 service network restart &> /dev/null 

The system-config-network-cmd helps us import /tmp/network-config file.

Restarting network service later loads the new configuration.

To drop out of the TTY 6 and resume back to anaconda use chvt trick again:


 chvt 1  
 exec < /dev/tty1 > /dev/tty1 2> /dev/tty1  

Credits for chvt trick: Hintshop blog.

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

2 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.
 

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