Roshan Book

My Tech Notebook

Monthly Archives: February 2012

Introduction to creating desktop applications with PHP and Titanium

Source: http://www.sanisoft.com/blog/2011/01/03/introduction-to-creating-desktop-applications-with-php-and-titanium/

Excerpts : 

What tools do you need ?

  • Download and install the Titanium DeveloperThe download and installation procedure has been discussed at length in the Titanium documentation in a simple and understandable way and even the steps on creating a new project and hence I am not putting the same here. I am assuming that you will download and comeback right here to know what next.
  • Text Editor with HTML / PHP syntax highlighting – If you are a web developer then you can’t be alive without one. Use your favorite.

On my Ubuntu 10.04 I got an error like : symbol lookup error: /usr/lib/lib-something: undefined symbol: something:

I did this to get rid of it :

– cd ~/.titanium/runtime/linux/1.0.0 if you install in your home dir.

or if you install in /opt/titanium/runtime/linux/1.0.0

– rm libgobject* libgthread* libglib* libgio*

Ready ?  What next ?

Follow http://www.sanisoft.com/blog/2011/01/03/introduction-to-creating-desktop-applications-with-php-and-titanium/ to read more

Advertisements

Installing Oracle JDK 7 On ubuntu

  • Download he 32bit or 64bit Linux “compressed binary file” – it has a “.tar.gz” file extension i.e. “[java-version]-i586.tar.gz” for 32bit and “[java-version]-x64.tar.gz” for 64bit
  • Uncompress it

    tar -xvf jdk-7u2-linux-i586.tar.gz (32bit)

    tar -xvf jdk-7u2-linux-x64.tar.gz (64bit)

JDK 7 package is extracted into ./jdk1.7.0_02 directory. – Now move the JDK 7 directory to /usr/lib

sudo mv ./jdk1.7.0_02 /usr/lib/jvm/jdk1.7.0

  • Now run
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
  • Run
sudo update-alternatives --config java

You will see output similar one below – choose the number of jdk1.7.0 – for example 3 in this list:

$sudo update-alternatives –config java There are 3 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ———————————————————— * 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode 3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode Press enter to keep the current choice[*], or type selection number: 3 update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode. 

Check the version of you new JDK 7 installation:

java -version

java version “1.7.0” Java(TM) SE Runtime Environment (build 1.7.0-b147) Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode) 

Repeat the above for:

sudo update-alternatives --config javac sudo update-alternatives --config javaws

Howto Install Mysql Database Server with Phpmyadmin Frontend

Source:http://www.ubuntugeek.com/howto-install-mysql-database-server-with-phpmyadmin-frontend.html

MySQL is a widely used and fast SQL database server. It is a client/server implementation that consists of a server daemon (mysqld) and many different client programs/libraries.

Installing Mysql database in Ubuntu

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev

This will complete the installation of mysql server 5.0.45 in ubuntu gutsy.

Configuring Mysql in ubuntu

MySQL initially only allows connections from the localhost (127.0.0.1). We’ll need to remove that restriction if you wish to make it accessible to everyone on the internet. Open the file /etc/mysql/my.cnf

sudo gedit /etc/mysql/my.cnf

Find the line bind-address = 127.0.0.1 and comment it out

#bind-address = 127.0.0.1

You can check your configuration using the following command

#netstat -tap

Output Looks like below

tcp 0 0 *:mysql *:* LISTEN 4997/mysqld

MySQL comes with no root password as default. This is a huge security risk. You’ll need to set one. So that the local computer gets root access as well, you’ll need to set a password for that too. The local-machine-name is the name of the computer you’re working on. For more information see here

sudo mysqladmin -u root password your-new-password

sudo mysqladmin -h root@local-machine-name -u root -p password your-new-password

sudo /etc/init.d/mysql restart

Manage Mysql using Phpmyadmin

phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the Web. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, execute any SQL statement, manage keys on fields, manage privileges,export data into various formats and is available in 54 languages. GPL License information.

Install phpmyadmin in ubuntu

sudo aptitude install phpmyadmin

This will complete the installation.

Now you need to goto http://serverip/phpmyadmin/

Login using your mysql root as username and password


 

How To Install Gnome Themes In Ubuntu 11.10

Source:http://www.addictivetips.com/ubuntu-linux-tips/how-to-install-gnome-themes-in-ubuntu-11-10-tip/

The complexity of GTK3 themes in Gnome 3 makes it a bit confusing to add desktop themes in Ubuntu 11.10.  This is because, there is no default tool to change Ubuntu 11.10 themes. However, you can change and manage Gnome themes in Ubuntu 11.10 with the help of a third-party application, known as the Gnome Tweak Tool. In this post, we will tell you how to install and manage Gnome 3 themes in Oneiric Ocelot.

To get started, install Gnome Tweak Tool. Once done, go to the Home directory, hit CTRL+H hotkey to show hidden files and folders, and create a new folder named .Themes via right-click context menu. Now, download your favorite Gnome 3 theme and extract it within the .Themes folder. You can download some Gnome 3 themes from the link given at the end of this post.

Change theme

Now, open the Gnome Tweak Tool from Applications –> Other –> Advanced Settings. Go to Themes section within the tool, and select the extracted theme from the drop down list. For example, you can select the GTK+, icon and Window themes to transform the look and feel of your Ubuntu desktop.

Gnome Tweak Tool

This will apply the selected Gnome theme. You can download and add a wallpaper to match your theme.

Theme

Download Gnome 3 Themes

Backing Up in Ubuntu

Source: http://www.psychocats.net/ubuntu/backup

One of the most frequent questions on the forums is “How do I back up in Ubuntu?”

Before I started using Ubuntu, I thought the best method was just to copy and paste files using the file manager (that’s one way, of course, but it has its limitations). I’m going to recommend a few popular methods. This list isn’t comprehensive—it just gives you some places to start. You can always investigate further once you’re more comfortable with Ubuntu.

Backing Up Personal Files
rsync is what I use for backing up personal files. I used to copy and paste files using the file manager, but that would involve taking about an hour to back up all my music and erase all the old copies. rsync gives me the ability to copy over only the files that have been modified or added since the last time I backed up. Now, backups take me only about fifteen seconds a week.

The most basic way to use rsync is like this (command goes into the terminal):

rsync -av /path/to/source/directory /path/to/target/directory

For example, let’s say your username is aliceand you wanted to back up your home directory to your external hard drive that mounts at /media/usbdrive, you would use the command

rsync -av /home/alice /media/usbdrive

If rsync doesn’t seem sophisticated enough for you, you can type

man rsync

to find more options than just -av. You can also explore rdiff-backup, which allows you to store (and restore) different date-stamped versions of the same file without taking up too much extra space. And, if you hate the command-line, try installing grsync, which is the graphical frontend to rsync. Here are some screenshots of grsync in action.

Backing Up Whole Installations
Not that System Restore is foolproof in Windows, but it’s still a nice feature… at least in theory. Right now, Ubuntu doesn’t have anything like System Restore. So if you’re worried an update (especially if you have unsupported or pre-release updates set to install) might break your perfect setup, it’s best to back up your system first.

tar is an archiving command, but it can also be used to archive your entire system into one little zipped up bundle. Someone on the Ubuntu Forums wrote a nice little HowTo on backing up and restoring your entire installation using tar.

ddrescue allows you to copy a partition byte for byte to another partition or to a .img file. It’s mainly designed for recovery of a crashed drive, but you can also use it as a way to back up (a non-graphical PartImage of sorts). The trick is that the name of the package is ddrescue in the repositories, but the command to use it is dd_rescue. So if you wanted to copy /dev/hda1 to /dev/sda1, you would type in the terminal:

dd_rescue /dev/hda1 /dev/sda1

Keep in mind that /dev/hda1 cannot be in use or mounted. If that requires you using a live CD, then so be it. You can also, if you don’t want to erase /dev/sda1 completely, ddrescueto an image file and then mount the image to get the files off it:

dd_rescue /dev/hda1 /dev/sda1/hda1backup.img
sudo mkdir /recovery sudo mount /dev/sda1/hda1backup.img /recovery

I don’t have a good tutorial on it, but Clonezilla also works well for backing up single partitions or entire drives.

My favorite web server setup, Ubuntu Server, LAMP, Webmin, and Virtualmin.

Source:http://www.patrickjwaters.com/blog/2011-07-13/my-favorite-web-server-setup-ubuntu-server-lamp-webmin-and-virtualmin/3524

Over the past few years I have experimented with different web server setups. I have found that the combination Ubuntu,  LAMP (Linux, Apache, Mysql, and PHP), Webmin, and finally Virtualmin provide many advantages in my day to day workflow as a web developer. This setup provides me with an easy to use and easy to maintain web server that lessens the time spent configuring the server and increases my time programming. Here are my step by step instructions for setting up my favorite server configuration.

Step 1: Install Ubuntu Server

Download and install Ubuntu Server edition. At the time of writing this 11.04 was the most current version. I prefer to use the most Current LTS release, so I will choose 10.04 for my install. When installing Ubuntu you can choose to install the LAMP stack if you wish and skip step 2. Just as a side note, the first time I set this up was on Ubuntu 8.04 and the steps have not really changed sense.

Step 2: Install LAMP

First change to the root user by typing the following and entering your password.

patrick@ubuntu:~$ sudo su

Then to install the LAMP package type the following

root@ubuntu:/# tasksel

This will prompt you with a screen like the this

Use the the arrow keys to highlight the LAMP Package and press space bar. Next hit tab to jump to the ok button and press enter.

During this process you will be prompted to enter a root mysql password. I recommend choosing a mysql root password different than your current root/user password. That is pretty much it for installing LAMP.

 

Step 4: Installing Webmin

Next we are going to install webmin. Webmin is a free peace of software that give you a web based interface for controlling different parts of your server. For example, if you wanted to change some php settings, you don’t have to ssh into the server and edit you php.ini. You can do it all through webmin. I am not going to give a thorough tutorial on webmin, but I do recommend poking around in it, once it’s installed.

So first step to installing webmin is adding it’s repo’s to the ubuntu. It doesn’t come in the prepackaged repos. So you are going to want to edit the file /etc/apt/source.list like so.

root@ubuntu:/# nano /etc/apt/sources.list

This will open a simple text editor. Use the arrow keys to get to the bottom of the file and add the following lines

deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

Then hit cntrl-x and they y and then enter, to save the file.

Next run the following

root@ubuntu:/# cd /root/
root@ubuntu:~# wget http://www.webmin.com/jcameron-key.asc
root@ubuntu:~# apt-key add jcameron-key.asc
root@ubuntu:~# apt-get update
root@ubuntu:~# apt-get install webmin

This will now install webmin to your server. Once webmin is installed you can access it at https://YOUR.IP.ADDRESS:10000 (ex. https://192.168.1.100:10000) take note of the https. You will probably get a warning about the certificate note being trusted, this is ok. This happen because your https certificate is not signed by a company like veri-sign. Now go the that url and you should get a screen like so

You are going to now login with your root user and password. Note that Ubuntu does not set a password for the root user by default. You can do that by changging to the root user and typing ‘passed’ and setting your password.

Once you log in you will get a screen like so

 

You have no successfully installed webmin! Click around there a lot of awesome features!

 

Step 5: Install Virtualmin

Next we are going to install a webmin module called Virtualmin. Virtualmin is a module that turns your server into a multi domain hosting platform. It organizes your websites files and folders automatically. It does a whole bunch of configuration automatically for you, like creates the necessary apache host files, creates a mysql database, and creates a linux user with ssh access. This is the module that I use the most. I rarely need to ssh into the server to mess with configuration. I can setup websites in seconds, it’s a big time saver. So here is how you install Virtualmin. I have to admit the first time I installed it, it was a bit tricky, but I have done it so many times now, that I know all of the gotcha’s and I hope this will make the process smooth for others as well.

Alright so you need to be logged into webmin and at the home screen. You will need to go and click on and expand ‘wbemin’ in top left hand corner and then click on ‘Webmin Configuration’ like so.

Next click on the ‘Webmin Module’

Now go to this link http://www.webmin.com/vdownload.html and look for the ‘Webmin Module Format’ link. It will be a link that looks like this, but the version may have changed http://download.webmin.com/download/virtualmin/virtual-server-3.87.gpl.wbm.gz.

Once you have that link you are going to want to go back to the webmin configuration page you were at before and check the radio button labeled ‘From ftp or http URL’ and paste the link in the corresponding text field and click ‘Install Module’.

 

Step 6: Configure Virtualmin

Virtualmin is now installed but needs to be configured. First we need to install apache2-suexec-custom. You need this so virtualmin can change apache’s default directory to /home

root@ubuntu:~# apt-get install apache2-suexec-custom
root@ubuntu:~# cd /etc/apache2/suexec
root@ubuntu:/etc/apache2/suexec# nano www-data

replace the line “/var/www” with “/home” (without “” ). hit control-x then y then enter

root@ubuntu:/etc/apache2/suexec# apache2ctl restart

 

Next we need to set the MySQL root password in webmin. if you click on Servers > MySQL Database Server on the left hand side and enter ‘root’ for the login and your mysql password. Remember this is not your linux password, it’s your mysql password that you set when installing LAMP.

 

Next we need to turn on some apache modules. Goto to Servers > Apache Webserver. You will see a 3 tabs click on ‘Global configuration’ and then lastly click on ‘Configure Apache Module’. Now you are going to want to make sure you check ‘actions’, ‘suexec’, and ‘rewrite’ and click ‘Enabled Selected Modules’.

 

Next you are going to want to click on Servers > Virtualmin Virtual Servers (GPL). This will take you to a Post Installation Wizard. You do not want to run through the wizard.  You are going to want to push cancel. This will take you to a screen like so and you are going to want to push ‘Manage Enabled Features and Plugins’

Next we are going to turn OFF some features of Virtualmin. I have found that I only use a few key features and other features require further configuration. Uncheck  ‘BIND DNS domain’, ‘Mail for domain’,  and ‘Webalizer reporting’.

Finally click save and you will be taken to the new Vitualmin Configuration screen. You have now successfully installed Virtualmin!

Step 7: Setting up a website with Virtualmin

The next thing to do is add a new website/virtual server with virtualmin. Navigate to Server > Virtualmin Virtual Server (GPL). Next look for a button that says ‘Add New Virtual Server Owned By:’ and click that.

 

This will bring you to a new screen with a form. Enter in the domain you want to host on your server, without the www, and enter an administrator password. This is all that is required, you can thumb through the other options, but you do not need to change anything else. Once you have the form filled out click ‘Create Server;.

When you clicked create server Virtualmin did the following

-Created a new linux user on your server that you use to ssh and sftp into.

-Created a mysql database named the same as your domain without the ‘.com’ or ‘.org’ etc.  For example if the domain you created was test.com, then Virtualmin would create a database called ‘test’.

-Created a new folder structure on the server. For example if you created test.com, you can navigate to /home/test/. Here you will find a folder called ‘public_html’. This is your web root folder.

How to install webmin on ubuntu 11.04 (Natty) server

Source: http://www.ubuntugeek.com/how-to-install-webmin-on-ubuntu-11-04-natty-server.html

Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.

Install webmin on ubuntu 11.04 (Natty) server

 

We have already discussed how to install ubuntu 11.04 LAMP server now we will install webmin for easy administartion

Edit /etc/apt/sources.list file

sudo vi /etc/apt/sources.list

Add the following lines

deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

Save and exit the file

Now you need to import GPG key

wget http://www.webmin.com/jcameron-key.asc

sudo apt-key add jcameron-key.asc

Update the source list

sudo apt-get update

Install webmin

sudo apt-get install webmin

Now you need to access webmin using http://serverip:10000/ once it opens you should see similar to the following screen

Packaging Titanium desktop applications on Windows

Source:http://www.dionysopoulos.me/blog/packaging-titanium-dekstop-apps-on-windows

Maybe you have already tried Appcelerator’s Titanium. If not, you should have. It’s a very easy to use RAD framework for creating cross-platform desktop and mobile applications based on HTML, Javascript, PHP, Python and Ruby. However, I was having a grave issue lately with their desktop builds. No matter what, I could not build the Windows installation package of my applications. Appcelerator’s documentation on manually packaging applications is sketchy and outdated. So I did what any self-respecting hacker (in the good sense, i.e. geeky developer with a strong aspiration to solving complex problems) would. I figured out a solution myself and documented everything in the process.

First things first, we have to install some prerequisites to “prime” our environment for building installation packages of our Titanium applications. Sadly, Appcelerator’s documentation doesn’t mention much and is, of course, terribly outdated. To save you from trouble, I figured it all myself and present it to you right here.
SDK installation and setup

Before you begin, install Titanium Developer, launch it and install the desktop SDK. Do note that the first time you run it, it will prompt you to install the Mobile SDK. Do it. Then shut down the application, launch it again and it will prompt you to install the desktop SDK. Do it and shut down the application. Counter-intuitive it is, but it works…

You will also need to put Titanium’s SDK directory in the path. Once more, the documentation is just plain wrong and gives you an inexistent path. Anyway, Titanium SDK is ultimately installed in c:\ProgramData\Titanium\sdk\win32\VERSION, where VERSION is the Desktop API version. At the time of this writing the latest API was 1.1.0, so the path we need is c:\ProgramData\Titanium\sdk\win32\1.1.0.

In order to add that to the path, hit the Windows key + pause, click on Advanced system settings from the left bar, click on the Environment variables button, double click on path, append “;c:\ProgramData\Titanium\sdk\win32\1.1.0” without the quotes of course.

Finally, we need to put the directory of Titanium’s copy of ImageMagick to our path. In order to add that to the path, hit the Windows key + pause, click on Advanced system settings from the left bar, click on the Environment variables button, double click on path, append “;c:\ProgramData\Titanium\sdk\win32\1.1.0\magick” without the quotes of course.
Third party software required

Next up, let’s install the third party software we need. Unfortunately, the Appcelerator documentation doesn’t mention any of it and it’s all left to the imagination of the developer. Let me save you from the trouble of figuring out what and how you have to install.

The very first prerequisite is installing Python 2.6 from from http://www.python.org/download/releases/ (tested with 2.6.6). Next, let’s put Python in your path. Hit the Windows key + pause, click on Advanced system settings from the left bar, click on the Environment variables button, double click on path, append “;c:\Python26” without the quotes of course.

You will also need to install WiX from http://wix.sourceforge.net/downloadv3.html. This is required for Titanium to be able to build the installer executable file of your application. Download and install the regular MSI package, NOT the 64-bits one even if you have a 64-bit version of Windows. Remember that all Titanium apps run in 32-bits mode and need a 32-bit installer. During installation, ignore any warnings about missing Visual Studio.
Building your application

The good news is that you can build your Titanium application’s installer manually. The bad news is that you have to use the command line to do that. If you are afraid to use the command line (CMD.exe) or have no idea about DOS commands, tough luck. Otherwise, you can read on.

Very important note: Your application version number must be in the x.y.z.w format, where x, y, z and w are integers. For instance, you can’t use a version number like 1.0.a1 or your packaging job will simply fail.

I will assume that you are building an application named MyApp placed on your desktop in a directory named MyApp. If no such directory exists already, create the directory win32 inside the dist folder placed by Titanium Developer inside the MyApp directory.

Open a command prompt. Just hit Windows key + R, type in “cmd” without the quotes and hit the enter key on your keyboard. You are presented with the black command prompt window. Type in the following command:

python “c:\ProgramData\Titanium\sdk\win32\1.1.0\tibuild.py” -v -o win32 -t network -s “c:\ProgramData\Titanium” -a “c:\ProgramData\Titanium\sdk\win32\1.1.0” -d “MyApp\dist\win32” -p test.exe “MyApp”

You may notice something strange, the test.exe parameter. For the life of me, I don’t know why this is required. No idea, really. It is not used anywhere, but it just seems that if it is not specified the packaging will fail with a cryptic message about the wrong drive being specified!

If you did everything as I described, you now have a MyApp.exe installation package in MyApp\dist\win32. You can distribute that to your users.
The sexy stuff: customizing the installer

As you may have noticed, the installer’s stock artwork has a strong reference to Appcelerator’s Titanium brand. If you want to customize the installer’s header, all you have to do is replace C:\ProgramData\Titanium\sdk\win32\1.1.0\default_banner.bmp with one of your liking.

Liberian Geek – Tutorials for Linux, Ubuntu, Fedora and Windows Users! [Follow Us] Home About Us Contact Us Home How-To/Tips Internet Linux Security Web Windows How to Permanently Mount Samba Shares in Ubuntu 11.04 Natty Narwhal

Source:http://www.liberiangeek.net/2011/04/how-to-permanently-mount-samba-shares-in-ubuntu-11-04-natty-narwhal/

This article describes how to permanently mount Samba Shares in Ubuntu 11.04 Natty Narwhal. We have written many tutorials about file sharing on this site. This one shows you how to mount those shares permanently in Ubuntu. These can be shares on Windows  or Linux machines. When shares are permanently mounted, they will always be there everytime you login to your desktop.

 

Getting started:

 

To get started, press Ctrl – Alt – T to open Terminal. Then install Samba Server by running the command below:

sudo apt-get install samba smbfs

natty_samba_permanent

 

After installing Samba, run the command below to edit the fstab file.

gksu gedit /etc/fstab

natty_samba_permanent_1

 

When fstab file open, add the line below at the bottom of the file and save. Replace //SERVER/Shares with the IP Address or Hostname of the computer and the share name. For username and password, enter your username and password for the computer hosting the shares.

//SERVER/shares /MOUNTPOINT smbfs username=user,password=pass 0 0

natty_samba_permanent_2

 

Restart your computer and the file should be mounted at the mount point you specified automatically.

 

natty_samba_permanent_3

 

If you don’t have full access to the mounted shares, open the fstab file and add the below options to the line.

uid=username,gid=groupname

natty_samba_permanent_4

 

 

My personal option is shown below:

//HOSTNAME/shares /MountPoint smbfs username=richard,password=pass,uid=richard,gid=richard 0 0

Replace user with your Windows’ username and pass with your Windows’ password. Also replace and reference of ‘richard’ to your own Ubuntu account.

 

Enjoy!

Accessing LVM2 In Windows

Source: http://www.squidoo.com/accessing-an-lvm2-volume-in-windows

If you use both windows and Linux in a dual booting environment, sharing volumes between them is a common requirement. As volume systems go, LVM2 is very handy and progressive.

However, getting to a partition setup with LVM2 while Windows is booted can be a problem. How can this be done in fail safe way?

I tried a number of methods, which I will discuss, but to get you to the information you want first, I will show the one thing that worked first. This method will consistently work even on something else, like a Mac or Solaris box, as well as with Windows 2k, XP, Vista and Windows 7. I have not tried it on earlier versions like Windows 98.

Some of the other methods worked with varying success until I upgraded to Windows Vista. Here I explain a method that consistently works for accessing Lvm2 in Windows, is free and relatively easy to set up.
Contents
Why use LVM2?
The method that worked – Virtual Box
How it appears to Windows
Obtain and install virtual Box
Set Virtual box To Run As Administrator
Finding the drive number in Windows Vista
Make profile for raw disk access
More Info on Windows/Linux environments
Install OpenFiler
Extend your LVM2 Partition
Love This Lens?
Bookmark This Lens
What are your experiences with LVM?
LVM2 and Linux Links
Image Sources
About Me
Covering a very difficult techie area
Why use LVM2?
LVM2 stands for Linux Volume Management. This system is amazing, because you can have one initial drive or group of drives in a volume, and then add drives to it later if you need more space.

A volume is in this context one logical partition – a single file system. Files are portable across the drives or physical partitions that make up the volume – a volume group.

When you need to take away a drive, provided you have sufficient space on the rest of the physical partitions in the volume, you can instruct LVM2 to ensure that the data is distributed so that no data remains on the volume to be removed. You do not manually have to move your files – and it is still considered one complete logical volume.

If you find that you use a lot of disk space quickly, LVM2 is a very good option to future proof yourself a bit.

Western Digital WD Elements 2 TB USB 2.0 Desktop External Hard Drive

Amazon Price: $125.00 (as of 02/04/2012)

Western Digital My Passport Essential SE 1 TB USB 3.0 Portable External Hard Drive (Black)

Amazon Price: $121.99 (as of 02/04/2012)

Vantec NexStar TX 2.5-Inch SATA to USB 2.0 External Hard Drive Enclosure

Amazon Price: $6.99 (as of 02/04/2012)
The method that worked – Virtual Box
After trying a number of methods, the one that worked is to use Virtual Box.
Virtual Box allows a user to set up a Virtual Machine – a simulated computer running as software. It uses hardware to accelerate where possible, but it is a sandbox, where the programs running in it are separated from your main operating system. Put simply – it allows you to run Linux within Windows, or Windows within Linux as well as multiple Windows instances and so on.

Virtual Box is also free for personal use.

This method involves in short putting Linux on a virtual box, mounting the drive on the Virtual Machine, mounting the LVM2 partition on Linux, using Samba to share the mounted partition. It means that you will be able to have full browsable read and write access to the drive. By using a minimal Linux installation, you will be able to keep the overhead down by a huge amount.

Buy at AllPosters.com
Framed Mounted
How it appears to Windows
Windows will be able to mount a shared drive, which as long as sensible names are chosen, should be easy to find. To windows it would appear to be a normal windows share. Since it is actually local, and written directly to the hard drive, it should be relatively quick.

The virtual machine will be running but it can be set up to run without a GUI, and as a service – so it will become transparent once fully configured. The interface through Windows is the tip of an iceberg. The busy Linux system now become the hidden depths of something that just works.

Buy at AllPosters.com
Framed Mounted
Obtain and install virtual Box
Virtual Box is free, and really easy to get hold of.
Download Virtual Box.

Run the downloaded file to install it. On Vista you will need to give it permission to install. You can choose to use VMware or colinux for this, but the procedures will be different and your mileage with raw disk access may vary on them. I chose Virtual Box as this has worked every time for me.
Set Virtual box To Run As Administrator
Raw disk access requires admin priviledges

Bring up the properties dialog on the shortcut you will use to start it. I chose to do both the start menu one and the desktop one so Launchy can be used. Select the “Shortcut” tab and click the “Advanced” button highlighted.
Bring up the properties dialog on the shortcut you will use to start it. I chose to do both the start menu one and the desktop one so Launchy can be used. Select the “Shortcut” tab and click the “Advanced” button highlighted.
On the Advanced properties dialog, tick the “run as administrator” box, and hit Ok.
Finding the drive number in Windows Vista
You will need this to create write though access to the drive

First bring up the control panel. In the Windows Vista Control Panel, select System and Maintenance (highlighted in red).
First bring up the control panel. In the Windows Vista Control Panel, select System and Maintenance (highlighted in red).
Once in System and Maintenance, look for Administrative Tools, under this there will be an item “Create and format hard disk partitions” (highlighted in red). Click this to see Disk Management.
Once on the disk management Window, the disks will be displayed. Note that non-windows partitions will not have any labels, so you will need to note the disk which has a bunch of non-labelled partitions. Here there is a tiny 125mb boot, a larger 4gb swap, followed by the 293 gb LVM partition – which marks it out as my Linux drive.
Make profile for raw disk access
Currently this is the least friendly part of the process and involves a command line. It is also the most crucial step.
If you want to find out more on this, I suggest reading section 9.9 of the Virtual Box user manual. Here are the steps outlined:

Consider the path you want to create a virtual disk at – For now I suggest c:\users\<username>\rawdisk.vdmk. You can move it once you have done this.

Click start, run then type “cmd” and hit enter.

Type “cd c:\program files\Sun\xVM VirtualBox\” so you are in the Virtual Box program directory.

For the required disk or partition (changing paths as necessary):
VBoxManage internalcommands createrawvmdk -filename c:\users\<username>\rawdisk.vdmk -rawdisk \\.\PhysicalDrive0 -register

That last command line explained:

internalcommands selects a lower level command set in VboxManage

createrawvmdk instructs it to create a VMDK for raw drive access

-filename specifies the output filename for the VMDK

-rawdisk specifies the drive number. Note the notation here – the correct drive number, obtained from the previous step should be used here.

-register ensures that the newly created drive is registered (via the registry) with Vbox and will show up in the virtual box media manager – which will save you plenty a little fiddling and trouble later.

More Info on Windows/Linux environments
If, like me, you have a mixed environment where you regularly use both OS’s, there are a number of tips and tricks you will need to really get the best of the situation.

Linux Kernel in a Nutshell (In a Nutshell (O’Reilly))

by: Greg Kroah-Hartman

Amazon Price: (as of 02/03/2012)

Linux in a Windows World

by: Roderick W Smith Ph.D.

Amazon Price: $20.00 (as of 02/03/2012)

Windows and LinuxIntegration: Hands-on Solutions for a Mixed Environment

by: Jeremy Moskowitz, Thomas Boutell

Amazon Price: $22.73 (as of 02/03/2012)
Install OpenFiler
A reader put me onto this, as a much simpler way to get an LVM or other linux partition mountable for windows. This is to use the system Openfiler. Having tried it out – I agree and this has replaced the original Ubuntu GEOS recommended in this artical.

Setting up a virtual box filer install to get to an LVM drive (or LVM image)
Download OpenFiler – http://www.openfiler.com/ – it is a Free, Open source NAS/Drive management distro. It happens to have LVM setup available and configurable from a web interface. This will be by far the simplest way to gain access. Get an ISO disk image – you will want the latest x86 edition.

Set up the OpenFiler VM – open up virtual box, click “New” to create a new VM, then give it the name OpenFiler. Give it some memory – I’ve given it a gig, which may be too much. Create a virtual disk image for it – I gave it 8Gb – which again may be too much – it is the default.

Be sure to set networking to bridged or host-only as you’ll need to connect to this device. Other options require more configuration usually.
Boot it, and press enter. Skip the disk check.

Once the GUI shows up – follow this: http://www.openfiler.com/learn/how-to/graphical-installation.

The installer will complete and you’ll be asked to reboot.

OpenFiler will start.

It’ll display the IP/url to use – pop this into a browser and you should see the openfiler page load up.

You’ll now need to stop it, and add your drives to it – this is easier for images than physical drives. Look belwo for the steps to add those.

Restart it, and you can now manage your drives from the web interface.

Default login is openfiler, password.

FAFFING – had to try the intel (not AMD) virtual network.
DHCP – You may want to give it a static address – although it will tell you on boot what its initial adress is.
Extend your LVM2 Partition
Why not take advantage of the power of this system by extending your drive space? With an LVM2 partition, you do not need to manually copy files to the new driven and you can keep the old drive so you end up with a much larger net volume size.

%d bloggers like this: