About My Blog



Whenever I get stuck doing something - the time comes to venture in the world of internet to find solution. In most cases I do find the solution, solve my problem and go on with my life. Then one day I am faced with the same problem. But now - I can't remember how the hell I solved it the first time. So the cycle begins again. Then I thought, what if I can remember all the those things? So here it is, my Auxiliary Memory. I decided to save all the problems and their solution in this blog so that I can get back to them when I need them. And the plus point is - so can everybody else.

Monday, December 1, 2014

Installing Arch Linux

For a newbie (such as myself) installing Arch Linux can be very painful experience. The arch linux wiki is very good and covers all the aspects. Though I would suggest anyone wanting to install arch for the first time to read the Beginner's Guide rather than reading the Installation Guide. The Installation Guide is basically a cheat sheet for more adept users who just need some reminder on the how-to's. When I first read the installation guide I was just clicking all the links to figure out what I need to do. On the other hand, the beginners guide covers everything with the basics.

However, this can also be a drawback. The beginners guide have so much information that you might get side tracked. Or, you might miss a step which needs to be followed to install arch. So, I thought it's better to make my own cheat sheet.

A simple understanding of how linux work, or the component which makes up a fully interactive linux environment is a plus for this type of installation. As I mostly used Ubuntu, I didn't have a good understanding of the components at work. But after I was able to install arch, I got a good idea about them.

The image on the right shows the components we need to be aware of. To install arch, we need to start from below. First we need to partition the hard disk. Then we will install the arch linux kernel. After that, we will install a Display Server. Then, if we don't want to use the default display drivers, we need to install the display drivers. After that, we will install the Desktop Environment. This will automatically install a Desktop Manger and Window Manager.

So, we need to follow these steps to install arch. Now, let's talk about them in more details.

1. Creating a Installation Media

So, we need to first download the iso of Arch from their site. Than we can just burn the image to a disk. I myself, however, prefer creating a bootable USB from the iso. So, I created a bootable USB from the iso using UUI. But turns out, this have some issues and so the system doesn't boot from the USB.

So, I followed the other instruction given in the link above to create the disk. Since, I was using Ubuntu, I just opened up a terminal and created the live USB with the following command -
dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx && sync
Don't forget the sync command at the end. If you miss it, arch might not boot from the USB correctly. The first time I tried making the USB, it didn't work correctly.

Note: This command will erase everything on the USB disk. So make a backup of the drive before running the command. Also, it is better to format the drive to FAT32 if it's in any other format.

Now we can use the media to boot to arch linux.

2. Partitioning The Hard Disk

We can partition the hard disk using MBR or GPT partitioning style. I prefer GPT as it is newer and has some advantages over MBR. More information on them can be found here.

For the most basic setup, the hard disk need only two partition - one is root /, and the other is boot partition. For MBR partitioning style, only one partition (root) is enough.

Partitioning can be done using any of the available tools, here we will use cgdisk. cgdisk is a GPT partitioning tool. We can startup cgdisk using the following command.
cgdisk /dev/sda
If the disk is already partitioned using MBR or not partitioned at all, it will ask to convert the disk to GPT partition. Pressing enter will convert the disk to GPT partition and show a list containing the partitions available in the hard disk. You can select partitions using up/down keys and select actions using left/right keys from the keyboard.

If the drive is not partitioned, there will be only one entry in the partition list with partition type unallocated. By selecting the entry and selecting [New] command from below we can start creating partitions. We will create three partitions - first one is for boot (for BIOS boot, code is ef02 and for EFI boot, code is ef00), second one for swap (code is 8200) and the last one for root (code is 8300). After we finish creating the partition, the screen will look something like below -


Note: Though in the Beginners' Guide, it is said that for BIOS boot we don't need any boot partition, but I couldn't boot to arch without creating a BIOS boot partition (code ef00).

We have to make sure to "write" the partition information before quitting cgdisk or we have to do it again.

3. Mounting the partitions

After creating the file system we have to format and mount them. Assuming our hard drive is /dev/sda, we have invoke the following commands to format and mount the file systems -
mkfs.ext4 /dev/sda3
mount /dev/sda3 /mnt
mkfx.fat -F32 /dev/sda1
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
We also have to make the swap partition -
mkswap /dev/sda2
swapon /dev/sda2

4. Connecting to Network

For wired connection the system should automatically connect to a dhcp network. Nothing further needs to be done. For connecting to a static IP network it's best to refer to the Beginners' Guide.

For wireless/wifi connection we have to first know the name of the wireless card. We can check it using -
ip link
Now we can connect to the wifi network using -
wifi-menu <card name>
Now, we need to follow the instruction and provide the asked information to connect to a wifi network.

Note: If there's only on wifi network card in the machine then invoking wifi-menu without parameter will default to that one card.

5. Installing Arch Kernel

Now we will install the base kernel using the following command -
pacstrap /mnt base base-devel
This will install all packages from base and base-devel group. To customize what packages will be installed we can use -i flag with pacstrap. This will prompt to select the packages we want to install.

6. Creating file system table

The file system table defines how the partitions will be mounted in the system. To generate it run the following command -
genfstab -U -p /mnt >> /mnt/etc/fstab
vi /mnt/etc/fstab
Note: It is recommended to open and check the generated fstab file

7. Configure Base System

After this, we need to configure the base system. For that we need to chroot to the system -
arch-chroot /mnt /bin/bash

Configure Locale

Now we will configure system locale. We have to open /etc/locale.gen file and uncomment the line en_US.UTF-8 UTF-8. Then we will run the following command to generate locale.
locale-gen
Then we will create /etc/locale.conf -
echo LANG=en_US.UTF-8 > /etc/locale.conf
And we will set the LANG variable -
export LANG=en_US.UTF-8

Configure Time

We will create a symbolic link to our subzone using the following command -
ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime
We have to change Zone and SubZone with our zone information.

Then we will set the hardware clock mode -
hwclock --systohc --utc

Set Hostname

We can change the machine hostname by -
echo host_name_here >> /etc/hostname

8. Install CPU Microcode

For intel based cpu's we have to install the microcode update (this is optional, we can run the system without microcode update). It is better to install it before installing boot loader because some boot loaders (such as grub) can load microcode at boot.
pacman -S intel-ucode

9. Install Network Components

For wired connection we don't need to do anything. We just have to configure the network again as above after restarting the system. For wireless connection, we need to install some packages to be able to connect as we did before -
pacman -S iw wpa_supplicant dialog
After this we can connect to wifi network using wifi-menu.

10. Install Boot Manager

We will install grub as it automatically loads intel-ucode. We have to run the following commands to install and configure grub -
pacman -S grub
To configure for EFI (64 bit)-
grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=arch_grub --recheck
To configure for BIOS -
grub-install --target=i386-pc --recheck /dev/sda
Then we need to create grub.cfg for both case -
grub-mkconfig -o /boot/grub/grub.cfg
After this we need to reboot the computer and log into our newly installed OS for further installation process. To unmount the partitions and reboot -
umount -R /mnt
reboot

11. Install Display Manager

After rebooting we will find ourselves in a arch linux kernel. Now we have to install the Graphical user interface. For that we have to first install a Display Manger. The most common display manager is Xorg which we can install using -
pacman -S xorg-server xorg-server-utils
Note: Before we can install anything we need to connect to network using the methods discussed previously.

12. Install Display Driver

We can use the default driver if we want. But we can also install vendor provided drivers.

For intel -
pacman -S xf86-video-intel  libva-intel-driver libva lib32-mesa-libgl
For ATI -
pacman -S  xf86-video-ati  mesa-libgl lib32-mesa-dri lib32-mesa-libgl
For NVidia the process varies for models. So it's better to visit Arch Wiki for installation instructions.

Note: To be able to install lib32-mesa-libgl in x64 system we need to enable multilib. We need to uncomment the [multilib] section in /etc/pacman.conf and then update the package list pacman -Syu

13. Install Desktop Environment

Now, we are ready to install the actual Desktop Environment. To install GDM -
pacman -S gnome gnome-extra
Then we need to set up GDM to start at system boot -
systemctl enable gdm
To install other Desktop Environments we can refer to Arch Wiki.

After this we can reboot to log into our installed Desktop Environment.

14. For Laptops

If we are installing arch in laptop, we have to install touchpad driver to make it work.
pacman -S xf86-input-synaptics
After installing driver we need to restart the laptop.

For better power management we can install TLP which works out of the box.
pacman -S tlp

15. Misc

The sound driver should work out of the box. However, to be able to play music we might need to install Codecs. GStreamer is a good codec which can be installed using -
pacman -S gstreamer
However, the old version of GStreamer is still widely used. So we can also install the old version using -
pacman -S gstreamer0.10

Monday, November 17, 2014

Compiling Monodevelop in Ubuntu using git repo from behind proxy

I did the compiling twice to get a better idea of whats going on. If you install all the prerequisite packages correctly, the compilation is pretty straightforward - you clone the git, build it, and install. Here are the steps I followed -

Prerequisites

First thing first, the prerequisites. Open up a terminal and install this packages -
sudo apt-get install mono-complete mono-devel mono-xsp4 gtk-sharp2 gnome-sharp2 gnome-desktop-sharp2 mono.addins mono-tools-devel git-core build-essential checkinstall

For the compilation to succeed you will also need to import mozilla certificates. Run the following command to import the mozilla roots -
sudo mozroots --import --sync --machine

The --machine flag is only needed if you use sudo make to compile.

Cloning the Git

Now go to the folder where you want to clone the git. Here I have used /opt. Make sure your user has right permission to that folder. You can give permission using the following command -
chmod 777 -R /opt

If permission is right, then run the git clone command-
cd /opt
git clone git://github.com/mono/monodevelop.git

if you are behind proxy use https-
git clone https://github.com/mono/monodevelop.git

This will only clone monodevelop. We need to clone the submodules using another command. But if you are behind proxy, first you need to change the git urls to use https. For that open up the file .gitmodules and replace all git with https. Make sure the url ends with .git. You can easily do it by opening the file in vi and running the following ex command -
:%s/git:/https:/g

Now clone the submodules
cd monodevelop
git submodule init
git submodule update

If you are behind proxy you need to change git url in another .gitmodule file which will be cloned in /opt/monodevelop/main/external/monomac/.gitmodules after the update.

Compile & Install

Now we will compile and install monodevelop. First we run the configure script. Here I have used the default location to install monodevelop. You can pass --prefix=<location> to install monodevelop in other location.
./configure --select --profile=stable

After this we are ready to build.
make

If you have given the --select flag, you will be asked to select the modules to make. I have skipped all them since some of the addons are broken now. For example, valabinding addon needs libvala-0.12 and mine had later version installed which is not supported. After compilation is successful, run the following command to install monodevelop.
checkinstall

This command puts the program in the package manager for easy removal later.

Misc.

Some other packages that might need to be installed are.
sudo apt-get install libglade2.0-cil-dev
sudo apt-get install libtool
sudo apt-get install autoconf

Thursday, November 13, 2014

How to list DB Provider Factories registered in machine with C#

Recently I was trying to use Entity Framework with Oracle Database. In one point I needed to see the DB Provider Factories registered in my machine. In one of the blog I found how to do that using C#(Sorry I forgot to save the link). What they did was create a desktop application and used a datagrid to show the result. It looked like a lot of work to just get the names. So, instead, I used LINQPad. Basically, it's like a Sql IDE which can execute C# codes on the fly. So you can just open up LINQPad, write some code, and see the result on the fly. I even use it to get some scripting jobs done instead of using powershell or cmd.
To get the list just fire up LINQPad. Select "C# Statement(s)" from "Language" dropdownlist. Paste the following line in textarea and run.
System.Data.Common.DbProviderFactories.GetFactoryClasses().Dump();

You will be presented with the details of all DB Provider Factories in your machine.

Tuesday, November 11, 2014

Installing VoraX (A vim based Oracle IDE) on Windows

I am quite a fan of Vim and use it everyday. So it's natural that I was drawn to VoraX. I installed using the following procedure, but got stuck when connecting to the database. The error is related to Broken Pipe during connection. So if anyone has a solution for that please let me know. I will update this blog post if I find the solution.
The things we need for vorax to be installed are -
  1. Oracle Sql Client
  2. Gvim 7.4
  3. Ruby
  4. Ruby Dev Tools
  5. And last, vorax itself

Lets start with Oracle Client. Vorax uses sqlplus to connect to Oracle database. So it needs to be installed and it's path added in Environment Path. I already had it installed in my machine and no further configuration was needed for it.
Next up, Gvim. Just download gvim from it's official website and install it. But the problem with that is gvim requires msvcrt-ruby192.dll. But I was unable to find a windows ruby installer that contained this specific version of the dll. So I downloaded custom gvim build from wyw.dcweb.cn which uses msvcrt-ruby200.dll. I found this link in this stackoverflow discussion. After downloading the custom build I replaced the original gvim74.exe and vim74.exe with the custom ones.
Now, it's time to install ruby. Downloaded Ruby 2.0.0-p594 and extract it in a local directory. Lets call it RUBY_DIR. Now put RUBY_DIR\bin in Environment Path.
After this we need to set up Ruby Dev Tools. Download it and extract to some local path. Let's call it's location DEV_DIR. Now open cmd and goto DEV_DIR. Execute the following command -
DEV_DIR>ruby dk.rb init

This will create a file named config.yml in DEV_DIR. Open the file with notepad and insert the RUBY_DIR location at the end of it if the line already doesn't exist and save it. Now run the following command -
ruby dk.rb install

This will install devkit.rb file in RUBY_DIR\lib\ruby\site_ruby.
Now lets start installing VoraX. First we install some ruby gems required by VoraX. For that Open a cmd and goto RUBY_DIR\bin. Now it's time to install some gems required by VoraX. Execute the following command in cmd -
RUBY_DIR\bin>gem install vorax --no-rdoc --no-ri

If you are behind a proxy set up HTTP_PROXY variable first -
set HTTP_PROXY=http://<proxy address or IP>:port

Now download vorax plugin and extract it's contents in %userprofile%\vimfiles. Make sure %userprofile%\_vimrc file contains the line "filetype plugin on".
Now when you run gvim with vorax installed. Further information can be found
  1. vorax.txt file in downloaded plugins doc folder
  2. https://github.com/oneclick/rubyinstaller/wiki

Monday, November 10, 2014

Why Html.BeginForm Have to be used with using?

This is the exact question I typed in google to find the answer. I guess I was too lazy to find it myself. But alas, I didn't find any good links. So I started going through the MVC library myself.
My exact question is that why we need to declare Html.BeginForm with using like below but for other Html extensions we don't.
@using(Html.BeginForm())
{
...
}

Well, the answer is actually pretty simple. The BeginForm method render a html form tag. When the method is called it render only the first part of the form.
<form action=""...>

After that any number of extension methods can be called. So how would the system know when to close the form. And that's why using is used. When system goes out of the using scope, it tries to dispose the enclosing object. This is when the object renders the closing form tag.
This can be verified by going to the declaration of BeginForm. All the BeginForm methods return an object of Type System.Web.Mvc.Html.MvcForm. And MvcForm implements IDisposable interface.

Friday, November 7, 2014

How to add software source in ubuntu from behind proxy

The easiest way to add new software source to ubuntu is using the apt-add-repository command from terminal.
apt-add-repository ppa:user/repository
However, recently when I tried to add a ppa using the above mentioned command from behind proxy, it didn't work. So I had follow a longer way to add the software source.
First goto launchpad.net and search for the software whose source you want to add. Then click on the Technical details about this PPA link, which will show you source.list entries. Select you ubuntu version from the dropdownlist/combobox. Then copy the first line. Picture shown below -
Now you can add this copied source to your ubuntu software sources in two ways. One way is to run the following command from you terminal -
apt-add-repository 'deb http://myserver/path/to/repo stable myrepo'
Or you can just use the gui. For that open up and goto Edit>Software Sources...>Other Sources and clicking the add button. Paste the link on the textbox and click Add Source.
This will only add the source to your ubuntu. But for ubuntu to trust the source you need to add the gpg key of that source. For that you need to first save the key to you machine. Click on the Signing Key link shown in first picture. Then click on the first link on the next page. This will show you some text. Now from that page copy only the part shown below -
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.4
Comment: Hostname: keyserver.ubuntu.com

mI0ETnBj5QEEAOOa9QvcobiU9ulHUlwX/MOzhA2aH52zQ4kIk58PBk+5wM1gjLMUEhXAjJu7
0pQLsm2Te7q25ljYyV6LAN0f0FaFA1fx9P9oQF5dS208Gb5S4b434GieMmgAOC8Tidq
s8c8zTsaufaRaqPrZEGgj9q/dQb88mua5cM9DswHABEBAAG0I0xhdW5jaHBhZCBQUEEgZm9y
IEViZXJoYXJkIEJlaWxoYXJ6wECACIFAk5wY+UCGwMGCwkIBwMCBhUIAgkKCwQWAgMB
Ah4BAheAAAoJEEi2gD6Dnsu+AlIEAIbeU2/crDbYp/wRrpBsvBw44UtIKHYsRXLESWF2+kYk
8jQBfjnRUxoC3PFaoMlWaWJh7Jv5MWkSb0aws9DaRzFVcNu6/SDoj7t2/mXLgnDMQryw9CkL
gYcUcNlWvrgKicgqo9/v2L2FH2393i9blMJz7216j28NGjgoKeOLTWdv
=viCD
-----END PGP PUBLIC KEY BLOCK-----
Now create a text file and save this text with any name in you machine. Again you can do it two ways. First on goto the saved file location from terminal and run the below command -
sudo apt-key add <file>
Or second way, goto the Software Sources window as mentioned above. Then goto the Authentication tab, click on Import Key File.. button and browse and select the save file. This will add the signing key of the source to your ubuntu.
Now all that's left is to update you package repository with sudo apt-get update and you are ready to install any software from the new source you added.

My Most Used Vim Commands

I have become fond of Vi/Vim in recent years. For most of my typing works I prefer to use Vim. Well editors which provide vim emulation. So I thought why not share the vim commands that I use most.
Lets start with the basics :).

Moving arround:

Command Description
h move the cursor left
j move the cursor down
k move the cursor up
l move the cursor right


Moving arround (advance):

And some advance command for moving arround..

Command Description Remarks
w move cursor to the next word W does the same but considers special characters part of word
b Same as w, but works backwords B is same as W, but works backwords
e Same as w, but cursor moves to the end of word Same as W, but cursor moves to the end of word
% Go to the matching bracket
( Goto start of sentence
) Goto end of sentence
^ Goto first printable character of the line
0 Goto start of the line
$ Goto end of the line
H Move cursor to the first viewable line
L Move cursor to the last viewable line
zz Move window such that the cursor comes to the middle of the screen


Manipulating Text:


Command Description Remarks
u Undo last action
x delete character under cursor
dw delete one word can be used with other movement commands
dd delete whole line
I Goto start of the first printable character on the line and switch to insert mode
a Switch to insert mode after the character under cursor
A Goto end of line and switch to insert mode
o insert line below current line and goto insert mode
O insert line above current line and goto insert mode
y Copy/yank character under cursor yy copies current line
p paste copied text
~ change letter case
v turn on selection mode you can use movement commands to selecte texts in visual mode


Searching


Command Description Remarks
/ searches the following text starting from the cursor and forward type the text to be searched after the / and press enter
n goto the next occurence of the searched text
N goto the previsou occurence of the searched text


Miscelleneous:


Command Description
zo Open folded lines
zc fold the foldable region the cursor is currently in


Ex Commands

Now some ex commands. (These commands are given using :) -
Command Description
:w save file
:q quit vim
:%sort sort all lines in the files lexicographically
:nohl turn off highlighing of searched items
:syntax on turn on syntax highlighting
:set ft=<filetype> sets filetype of the file for syntax highlighting
:set wrap turns on wrapping of lines
:set nowrap turns off wrapping of lines

Phew... the list got bigger than I expected. And these are only the ones I use in my regular vim activity. Furthermore, I consider myselft just a novice of vim :p.

Tuesday, November 4, 2014

How to upgrade kernel on Ubuntu

You can find out which kernel version you are running by opening up a terminal and running the following command:
uname -r

To find out which version is the latest go to www.kernel.org.
To install the latest version you need to download the images. For that go to kernel.ubuntu.com/~kernel-ppa/mainline and open up the folder that matches the version number you found in www.kernel.org.
You need to download three files from the list. For 32 bit they are -
linux-headers-***-generic_***_i386.deb
linux-headers-***_***_all.deb
linux-image-***-generic_***_i386.deb

For 64 bit they are -
linux-headers-***-generic_***_amd64.deb
linux-headers-***_***_all.deb
linux-image-***-generic_***_amd64.deb

After downloading the files copy them to a temporary folder with no other deb files and run the following command from terminal -
sudo dpkg -i *.deb

This will install the new kernel. Restart you machine and uname -r to confirm you are running the latest kernel.
To uninstall the old kernel you could just use ubuntu-tweak. Install it with -
sudo apt-get install ubuntu-tweak

After installing ubuntu tweak, run it and open janitor. Do a clean and it will uninstall the old kernel for you.

Monday, November 3, 2014

Cannot launch/debug ASP.NET/ASP.NET MVC on MonoDevelop on Ubuntu 14.x

If you have installed Monodevelop 5.1 from ermshiperete's PPA then you might be facing this problem. When you try to run the project MonoDevelop will say it can't find xsp4.
The problem is that the PPA provides local mono but does not provide mono-xsp4 because of compatibility issues. So first we need to install mono-xsp4
sudo apt-get install mono-xsp4
Then we need to tell MonoDevelop to use User's mono runtime instead of the local one to run the project. For that we need to goto Edit>Preferences.. from MonoDevelop menu and select Mono*** (/usr) and set it as default.
Now if you try to run the project, it will run but you will get an error page saying System.MissingMethodException: Method not found: 'System.Configuration.IConfigurationSectionHandler.Create'. The problem is that mono-xsp4 cannot locate some dll files when run from MonoDevelop probably because the launcher script /opt/monodevelop/bin/monodevelop-launcher.sh set some environment variables before starting MonoDevelop.
To get around it we need to run MonoDevelop itself with the users mono runtime. You can see in the above picture that even though we have set users runtime as default, monodevelop was using the local mono to run itself. So, lets run monodevelop with users mono runtime. First copy the monodevelop script that monodevelop-launcher.sh calls to run monodevelop to someplace with easier access.
cp /opt/monodevelop/bin/monodevelop ~/Desktop/monodevelop
Now modify the value of EXE_PATH to directly point to MonoDevelop.exe
EXE_PATH=/opt/monodevelop/lib/monodevelop/bin/MonoDevelop.exe
Save the file.
Now run monodevelop script from desktop and monodevelop will start using users mono.
./monodevelop
If you try to run web application now xsp4 will successfully run them and you can also debug them. I have tested it with ASP.NET MVC 2 Project. You can also verify that monodevelop is using users mono runtime by going to the above mentioned screen.
P.S. If any registry access error is shown then we need to create the following directories and set their permissions.
sudo mkdir /etc/mono/registry
sudo mkdir /etc/mono/registry/LocalMachine
sudo chmod g+rwx /etc/mono/registry
sudo chmod g+rwx /etc/mono/registry/LocalMachine

Friday, October 31, 2014

Batch File Renaming with Windows PowerShell

I have been in situations where I needed to batch rename a lot of file. There are a lot of tool you can find on internet that can do this. But why go through all those software when you have one option available in windows ready for you to use.

Say Hello to PowerShell. To open it just type "powershell" in command prompt or in start menu.

Here are a few things you can easily do with powershell

Change File Extension

Have some .log whom you want to change to .txt? Just run the following command -

dir *.jpeg | rename-item -newname {  $_.name  -replace ".log",".txt"  }

dir command gets the list of files in the current directory. The | (pipe) character passes this list to rename-item command which takes each of the file and replaces it's extension

Appending File Extension

You can append file extension to multiple files which don't have file extension in their name

dir | rename-item -newname  { $_.Name +".jpg" }

Rename File With Increasing Number

This one's a bit complicated than the other two. It uses a variable to rename the files.
dir *.jpg | ForEach-Object  -begin { $count=1 }  -process { rename-item $_ -NewName "image$count.jpg"; $count++ }

Accessing Physical Hard Disk Partition From Virtualbox Guest

  1. Run virtualbox with admin privilege.
  2. First we need to find the partition number. For that we need to run the following command.
    "c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internal commands listpartitions -rawdisk "\\.\PhysicalDrive0"
  3. This will show the list of partitions (We need to run command prompt as administrator also for this to work). For my case
    Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)
    1       0x07  0   /32 /33  44  /190/18           350         2048
    2       0x07  44  /190/19  1023/254/63        204450       718848
    3       0x07  1023/254/63  1023/254/63         66560    419432448
    4       0x07  1023/254/63  1023/254/63        205578    555747328
  4. Now we need to create a .vmdk file that will point to the partition we need. I am going to attach mine with partition 4.
    "c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internal commands createrawvmdk -filename "E:\VirtualboxVDIs\rawedrive.vmdk" -rawdisk "\\.\PhysicalDrive0"  partitions 4
    RAW host disk access VMDK file E:\VirtualboxVDIs\rawedrive.vmdk created successfully.
  5. Bingo :). Now we need to attach the .vmdk file to a guest OS. Need to run VirtualBox Manager with admin privilege also.
  6. Select the guest OS from virtualbox manager and goto its settings
  7. Select storage tab and add the vmdk file to the SATA controller.
  8. Now startup your guest OS and you will find your hard drive their

One problem with this is that you cannot mount the hard drive in both guest and host at the same time. If your host is windows just remove the drive letter associated with the partition from device manager to unmount it.

Details can be found in this link

Thursday, October 30, 2014

You don't have permission error in Apache in CentOS

The Problem

I have installed apache 2.2 in centos 6. Everything worked fine when the apache folder was at its default location /var/www/html. Then I configured a Virtual host inside my users home folder. After that apache started showing Forbidden You don't have permission error when I tried to go to localhost or 127.0.0.1 from browser. this is the code i used in httpd.conf
<VirtualHost *:80>
        DocumentRoot "/home/anjan/workspace/mfs"
        ServerName anjan-centOS
        <Directory "/home/anjan/workspace/mfs">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order Deny,Allow
                Allow from all
        </Directory>
</VirtualHost>

I also disabled SElinux as was mentioned in some articles but in vain. If anyone could help me out it would be much appreciated.

The Solution

I solved the problem. After meddling with the permission of the system I found out that the user "anjan" who is owner of /home/anjan had read/write/execute permission on /home/anjan but the group "anjan", created when user "anjan" was created didn't have any permission at all.
ls -l /home/
showed
drwx------. 28 anjan anjan 4096 Jan 21 13:19 anjan
so I changed the permission with this command
chmod -R 770 /home/anjan
ls -l /home/
drwxrwx---. 28 anjan anjan 4096 Jan 21 13:19 anjan
i found out under which user my apache is running from this thread. It was running under user "apache" so I added user "apache" to group "anjan" with this command.
usermod -G anjan,apache apache
after that voila. No more Forbidden error.