Archive for 'Learn Linux – Linux help'

Are You Ready for Java Application Development on Linux?

Java logoBy Adam George

Today, Linux is best recognized as the fastest-growing J2EE application development platform. It’s so popular among the developer as well as enterprise community since it contributes in saving a lot of time and money.

Java, a programming language powered by Sun Microsystems, offers a complete range of programming scope to the Java developers’ community. These seasoned Java developers are well versed in building “out-of-the-box” computer applications as well as applications for a wide array of hand-held devices.

Almost every one of us knows that Java is an object-oriented language that can be run across a number of platforms. No wonder why Java is often referred to as “Compile once, run anywhere” platform independent programming language.

Now if we talk about J2EE application development on Linux, it’s important to consider the context and environment in which the applications are being developed. It may baffle a newbie Java developer to Linux in understanding the way Java finds environment on the Linux platform.

Well, there are some pre-requisites that need to be there to get started with Java application development on Linux platform namely, current working directory, command-line parameters, current shell’s environment variables and location of data files. However, the usage of these parameters is variable as you can use the one that is in tandem with your application development requirements and the portability index you desire in your Java-based applications.

The program invocation offers the primary external information. This can be in different forms as arguments or the basic information, which can further point a program to scalability and implementation and deployment.

Let’s talk a bit about command-line arguments. In a scenario where the program is run using a command line, the program name would suffice for the purpose. The open source has encouraged Java developers to build new utilities for creating better applications in a more efficient and effective manner. This is supported by Linux and hence the trend has flourished to such a remarkable extent. Though a novice developer would find the Linux commands taxing to learn in the first place; however, once done with that, the following journey is a treat.

Further, the developer needs to learn about using Linux development tools like Ant, JUnit, GNU Compiler for Java (GCJ) etc. Then follows the development of some logic layers by making use of Java Database Connectivity (JDBC). JSPs are used to integrate a web interface, and Abstract Windows Toolkit (AWT) for integrating a GUI.

Now that you know a fair deal about Java application development on Linux, it’s time to get started with the same.

Adam George is a well known writer. He has written many articles on various topics including outsourcing, Presently writing on Software services, Software Development, JAVA Application Development and other Software testing services.

Tags: , ,

260px-GRUB_screenshotBy Eddison Sherry

Booting (booting up) in computing is the process of starting the Operating System when the computer is switched on. A boot sequence is the initial set of operations performed when the computer is switched on. Some commonly used bootloaders are GRUB, BOOTMGR, Syslinux, LILO, NTLDR. Linux booting process is much simple to understand and much things to learn.

300px-LiloFor Linux, the most common boot loaders are LILO(LInux Loader), LOADLIN (LOAD LINux) and GRUB (GRand Unified Bootloader). LILO is the most popular boot loader for those users who employ Linux as the main, or only, operating system.LILO is a very fast bootloader. LOADLIN is used by those who have multiple operating systems. LOADLIN is sometimes used as a backup boot loader for Linux in case LILO fails. GRUB is preferred by many users of Red Hat Linux.

A boot loader consists of three programs:

The boot sector program (512 bytes) is directly loaded by the BIOS at boot time.

The second stage program is loaded by the boot sector program and it can do everything you program it for.

The boot loader installer is used to install the boot loader and the second stage program onto the boot disk. These have to be stored in special locations, into the first sector of boot device. So they cannot be copied with a mere copy command.

Now we will compare the features of mostly used GRUB and LILO bootloaders.GRUB is capable of loading a variety of free and proprietary operating systems. GRUB will work well with Linux, DOS, Windows, or BSD. GRUB is dynamically configurable which means changes can be made during the boot time, which includes altering existing boot entries, adding custom entries, selecting different kernels, or modifying initrd. GRUB supports Logical Block Address mode meaning if the computer has a modern BIOS which can access more than 8GB (first 1024 cylinders) of hard disk space, GRUB will automatically be able to access it. Besides these GRUB can be run from or be installed to any device like floppy disk, hard disk, CD-ROM, USB drive, network drive and can load operating systems from just as many locations, including network drives. It can also decompress operating system images before booting them.

LILO is a sensible option for many Linux users and is a fast bootloader. LILO does not depend on a particular file system.One of up to sixteen different images can be selected at boot time. Parameters can be set independently for each kernel. LILO can be placed either in the master boot record (MBR) or the boot sector of a partition. At system start, only the BIOS drivers are available for LILO to access hard disks. So with very old BIOS, the accessible area is limited to cylinders 0 to 1023 of the first two hard disks. For later BIOS, LILO can use 32-bit logical block addressing (LBA) to access all the hard disks that the BIOS allows. LILO has some disadvantages when compared with GNU GRUB.

LILO supports only up to 16 different boot selections; GRUB supports an unlimited number of boot entries.

LILO cannot boot from network.

LILO must be written again every time you change the configuration file; GRUB does not.

LILO does not have an interactive command interface.

Finally, there are multiple choices of bootloaders which work with the Linux operating system of which the user can choose the ones best suited for the requirements.

Eddison Sherry had been working in Linux and other Unix flavours for long years. He had been writing blogs and article on the Linux Storage, Linux Commands and Linux Server Administration. If you are working on Linux or Unix Server its best to have a look on his blogs at Linux Technical Forum.

Tags: , ,

MySQL for Beginners – Its Important Features and Advantages

MySQL logoBy Eric Datu Agustin

MySQL for beginners requires you to first know Structured Query Language (SQL), a general query language, through which you can extract, sort, update, delete and insert data. With SQL, you can manipulate data as you used relational database management systems (RDBMS) such as MySQL, Access, Ingres MicrosoftSQL Server, PostgresSQL, Oracle, Sybase, etc.

mysql-version-history

MySQL versions

Structured Query Language (SQL) has full support from the American National Standards Institute (ANSI), which has laid down certain rules for its use. So, when you want to build a strong foundation in SQL, you can choose from one of the aforementioned RDBMS that is specific for your use. As a caveat, you should have to consider three primary factors before you opt for a database system, as follows: the platform on which you work, what you want to achieve and your finances.

As you may know, all the important and common SQL statements are supported by any of these RDBMS; however, each RDBMS has its own set of proprietary statements and extensions. In layman’s terms, a database stores or housed your data files (such as names and emails of your friends). If you use small programs such as Perl for your database, your information is displayed and your data analyzed based on the program’s search criteria features.

Some of the important features of MySQL for beginners are, as follows:

a) It is very fast and much reliable for any type of application;

b) Its command line tool is powerful that it can run SQL queries against database;

c) It supports binary objects and indexing;

d) It allows changes to structure of table while server is running;

e) It has a wide user base with fast thread based memory allocation system;

f) Its code is tested with different compilers;

g) It is written in C and C++ language;

h) It is available as a separate program for use in a server/client network environment;

i) It is available for most Unix operating platform;

j) It is available for window operating system window 98 and 95, and window NT;

k) Its programming libraries for C, Delphi, Java, PHP, Python, etc. are available to connect to MySQL database; and,

l) A lot more.

In addition to the above, some of the advantages using MySQL are, as follows:

a) Its source code is available and can even be recompiled;

b) It supports more than twenty different platforms, which include Linux distribution Mac OS X, Microsoft Windows and Unix;

c) It is considered one of the world’s most popular open-source database system;

d) It is high performing and very reliable RDBMS where it can store many gigabytes of data; and,

e) It is a very powerful yet uncomplicated software that can handle most corporate database applications.

If you are one of the ardent supporters of open source software worldwide, you would consider “what is MySQL” for Linux, which is 100% free and that the combination of Linux, Apache, My SQL and PHP (LAMP) is incomparable.

There are other things you know more about MySQL for beginners as a RDBMS for beginners; however, suffice to say that, a good sign up and online tutorial will help you more regarding its actual use.

I am a professional SEO writer. Most of the articles that I publish have something to do with my work, hobby and studies. You can also suggest to me articles that I should write and post. To see some of my articles, please click this link: http://www.happy-niches.blogspot.com. Thanks.

Tags: , ,

By Christopher P Wakefield

64px-Virtualbox_logoHow do you manage virtual machines over a network using Oracle Virtualbox? I have been asked this a couple of times recently and today I will show you how. Most of my tutorials on Virtualbox have been along the lines of installing the software onto a system and managing the virtual machines on that system in person. This works well if you have a couple of virtual desktop machines but when you have quite a few servers involved going between each server to carry out maintenance becomes very tedious.

This is where you need a piece of software called phpvirtualbox. Phpvirtualbox is an open source web based front end for Virtualbox which allows you to manage all of your virtual machines over the internet.

linux-mint-logo-128x128So lets take a look at how we set this up. For the basis of this tutorial I will be using Linux Mint 12 and Virtualbox 4.1.4.

We first need to download and install the current version of Virtualbox from the Virtualbox website.

Once installed we need to add a user who will run Virtualbox. Open up a terminal as root and type:

adduser vbox

When asked supply a user password. Next we have to add the vbox user to the vboxusers group in the /etc/group file. So type (as root):

gedit /etc/group

Add vboxusers:x:113:vbox to the file and save.

Once we have finished with Virtualbox it is time to set up our web server. Since this is Linux we will be using Apache. Open up a terminal and install the following packages:

apache2

php5-mysql

libapache2-mod-php5

mysql-server

During the install process MySQL will ask you for a root password. Make this something complex but do not forget it!!!

Once installed open up a web browser and type your server address into the address bar and you will see the message IT WORKS! This means that you have a working web server.

Now we need to download, install and configure phpvirtualbox. The current release can be downloaded from the phpvirtualbox website.

I am assuming your downloads go to your Download folder. If not replace Downloads with the location that the file was downloaded to. Open up a terminal and type the following commands one at a time:

cd Downloads

cp -a phpvirtualbox-4.1.7 /var/www/phpvirtualbox

cd /var/www/phpvirtualbox

mv config.php-example config.php

It is now time to configure the config.php file so type:

sudo gedit config.php

———————————–

/**

* phpVirtualBox example configuration.

* [@version] $Id: config.php-example 366 2011-12-01 19:56:57Z

*

* rename to config.php and edit as needed.

*

*/

class phpVBoxConfig {

/* Username / Password for system user that runs VirtualBox */

var $username = ‘vbox’;

var $password = ‘*********’;

/* SOAP URL of vboxwebsrv (not phpVirtualBox’s URL) */

var $location = [http://127.0.0.1:18083/]

/* Default language. See languages folder for more language options.

* Can also be changed in File -> Preferences -> Language in

* phpVirtualBox.

*/

var $language = ‘en’;

————————————

Locate the username and password (BOLD above) and change the password to the one you created earlier. Once done save and exit.

Now we need to make sure that Virtualbox can start at boot time and that means configuring init scripts. Open up a terminal and type:

cd /etc/init.d

and then:

sudo touch /etc/init.d/vbox.start

Now we need to configure the file so type:

sudo gedit /etc/init.d/vbox.start

Copy /usr/bin/vboxwebsrv -b into the file. Save and exit.

That is Virtualbox configured to start at boot time but we now have to enable it so type:

chmod +x /etc/init.d/vbox.start

followed by:

update-rc.d vbox.start defaults

Now it is time to reboot the server. Once it has rebooted go to a web browser and point it to your server address/phpvirtaulbox

You will now be able to manage all the virtual machines on the network from the comfort of your own chair.

Hi I am Chris the owner of ComTech. I provide IT support to both personal and business clients from my base in Alloa, Clackmannanshire. For a list of what I can offer you why not visit my website www.comtech247.net where you will find my blog, testimonials, services and much more. Start supporting a local business today so I can start supporting you.

Tags: , , , , , , ,

gnuBy Rand Whitehall

In the Linux command line shell, moving around from directory to directory, adding new directories, and deleting old directories is easy once you know the proper commands. Again, with Linux, you are limited only by your brain! If you know all the commands, then you weild great power. But if you know only a few commands, it’s like you are standing in the airport in Tokyo and want to know where the bathroom is, but only know how to say hi and bye in Japanese.

Let’s get to it. Open a shell (or terminal) and type each line below followed by enter:

cd

pwd

You should be in your home directory, which is the same name as your username. So if your username is barney22, your home directory should be /home/barney22.

Now, let’s create a new directory to play with. (Remember, when learning the command line in Linux, always play with new directories and files you create to practice with. Never practice with important files and directories.) Type this:

mkdir doggy [enter]

ls [enter]

Now you should see your new directory called doggy in the ls output. Great! Now what? Let’s change the name. Type:

mv doggy doggyDo [enter]

ls [enter]

And you should see the directory name has been changed from doggy to doggyDo. Great! Hmmm… Now let’s go into the doggyDo directory and create a text file.

cd doggyDo [enter]

touch shibaken.txt [enter]

ls [enter]

Now, you should be in your doggyDo directory and see the new text file you created with the touch command. If for some reason you got lost somewhere along the line, go “home” by typing this:

cd [enter]

A cd command with no destination will take you home every time.

Now, let’s say you want to move the doggyDo directory into another directory. Let’s create another directory first, like this:

cd [enter]

mkdir doggyDocs [enter]

Now let’s move the doggyDo directory into the doggyDocs directory like this:

mv doggyDo doggyDocs [enter]

ls [enter]

You should see the doggyDocs directory now, but not the doggyDo directory because it is inside doggyDocs.

cd doggyDocs [enter]

ls [enter]

You should see your doggyDo directory there inside doggyDocs.

I hope you learned a lot about creating and moving directories around in the Linux command line. If this was a bit confusing, then just go through it again slowly. With a little practice your fingers will know what to do as soon as you think of it!

Rand writes about web design, Linux, men’s health and more. Please check out his DE safety razor site for shaving info and tips and the latest on the Merkur Futur safety razor. It’s a great resource for those who are passionate about a quality, close shave.

Tags: , , , , , ,

logosBy Drake Q Harris

What do you think is the one upgrade that can very much help web developers in increasing their productivity, speed and their quality of work? It’s probably the simplest thing in web designing but most developers tend to overlook it.

So, what is it, you may ask? Well, it’s your text editor, of course!

No matter what language you use, only the right tools can actually make you a better programmer. All that programming needs is a clean and precise organization of information that would enable any developer, who might pick up the said file, to understand what it’s supposed to do and how to make alterations if necessary. With that, a quality text editor is a must and would probably be the single most important tool a programmer can have.

There are a lot of text editors to choose from and here are just a few of the best text editors for web designing available today.

What to Choose?

1. Text pad

This is a Windows-based editor and it’s very popular because of its easy macro recording feature. It has the standard toolbar and menu interface, just like any Windows-based tool. It also has the ability to restore its data to the last configuration used on startup. So, this is very useful because you don’t need to individually re-open your project’s file every time you start.

2. Notepad++

This is probably the most recommended text editor to upcoming developers as the most indispensable tool they can have for their line of work. It’s actually available under the GNU Public license, so what that basically means is that it can be widely shared among different developers.

3. Vim

Vim is actually the most recent execution of the Venerable VI text editor that is pretty common to UNIX systems for the past decades. It is indubitably a programmer’s editor in web designing, it is often the principal tool with which administrators install, configure and practically maintain their systems that are running UNIX or its other variants like Sun OS.

4. Textmate

Textmate is technically the only Mac-only text editor in this list. But even if this might pose a problem for programming some applications, it is actually so far exceeding most of its competition that some developers would actually want to buy a Mac just to get their hands on this top quality application. Again, this is a UNIX-based OSX so it gives users access to command line functions and all together offering some of the finest features that the Apple desktop offers.

There are still loads to choose from when it comes to text editors for web designing, but, of course, the choice is always in your hands.

Here’s the Top Four Text Editors used in Web Designing today! Check these out!

Tags: , , , ,

GNOME logoBy Marcos Aguilar

With the arrival of Gnome3 and Ubuntu 11.04 with Unity, it is necessary to clarify two concepts that are different and that tend to generate confusion: Desktop Environment and Window Manager.

DESKTOP ENVIRONMENT

(GNOME, KDE, XFCE, LXDE)

What a desktop environment does is bring together different X clients and use them to create a common graphical user environment and a development platform. These advanced desktop environments allow X clients and the applications to run and communicate with each other, allowing those applications to perform advanced tasks, such as drag and drop, eg.

WINDOW MANAGERS

(Metacity, Compiz, Mutter, Kwin)

They are X client programs that can also be independent (eg. Mwm). Its main purpose is to control the way graphical windows are displayed (position, resize, move, appearance.) and features (links to the mouse buttons, title bars, shortcuts, focus behavior).

Kwin-> Window manager for KDE. Supports interchangeable styles, which control not only its appearance but also some aspects of their behavior.

Distribution: Kubuntu

Metacity-> This is for GNOME2. It has few configuration options. But in return Gnome2 is highly configurable and allows other operators to install more advanced customizable applications like Compiz.

Distribution: Ubuntu 10.10 and above

Mutter-> This is for GNOME3 (new) not allowed to use any window manager without rewriting code, so that no window manager different than Mutter can be installed in Gnome3.

Distribution: Fedora 15

Compiz-> This is for GNOME-Unity in Ubuntu 11.04. It is the most advanced and configurable manager and can usually be installed anywhere, provided you have 3D acceleration (OpenGL).

Distribution: Ubuntu 11.04

Xfwm-> This is for Xfce. Provides its own compositing manager, the first of its kind when it was released. Supports keyboard shortcuts and its graphics are completely modifiable.

Distribution: Xubuntu

Openbox-> This is for LXDE. Was derived from Blackbox 0.65 in the beginning, but has been completely rewritten and is no longer based on Blackbox. It is designed to be fast and consume a minimum amount of resources while sacrificing some features.

Distribution: Lubuntu

Fluxbox-> It is a minimalist, light and customizable. Its visual appearance is changed from text files. It is based on Blackbox code.

IceWM-> is a lightweight and minimalist. Its main goal is to be good looking and still light. It is configured from text files. The themes IceWM can also be used with KWin (KDE), provided the kdeartwork package installed.

Motif(mwm) -> is a very basic and independent manager. Not to be used with GNOME or KDE.

Read more about KDE and GNOME.

Our blog is run and maintained by Linux & Unix fans who volunteered to share their experience with the world at no cost!! This is the power of Linux & Unix!! Visit us on http://www.linux2aix.com.

Tags: , , , , , , , , , , , ,

WINE logoBy Marcos Aguilar

It may occur that the user needs to run a Windows application or game in Ubuntu and it finds that it cannot install windows programs.

Wine is a piece of software that tricks programs to believe they are running in a Windows environment.

In addition, this article will explain how to install Winetricks libraries needed to run windows, and PlayOnLinux applications to run games.

WINE

Wine comes in the Ubuntu repositories, ready to install. All the user has to do is open a terminal (applications -> accessories -> terminal) and enter the following command:

sudo apt-get install wine

The best option is to get the latest version of wine so the user should add its repositories.

Note: Ubuntu 12.04 has the latest version of Wine (version number 1.4) so it is not need to add its repositories.

For earlier versions of Ubuntu, open a terminal and run the following command:

sudo add-apt-repository ppa:ubuntu-wine/ppa

Press Enter, write the root password (for security reasons, not visible while the user types), we hit Enter.

Update the repository with the following command:

sudo apt-get update

Press Enter and the user would be ready for installation.

Once the repositories were added, and depending on whether there is a version of Wine already installed, do one of the following:

If Wine is not installed, issue the following command:

sudo apt-get install wine

If the user has an earlier version of Wine (the official Ubuntu repositories) installed, it can be updated with the following command:

sudo apt-get upgrade

Running Wine:

The Wine Menu already shows under Applications. It can be used to access Windows programs and Configure Wine (you can also configure it from a terminal with the winecfg command).

To install a.exe program, click the right mouse button on it and select “open with wine windows program loader”.

We can also run a program on a terminal with the following command:

sudo wine program.exe

It is a good idea that before installing a piece of software, especially if it’s powerful and complex, check the official WineHQ site, to see if the program would work well. It sometimes happens that it is necessary to install a library or dll for the program to work properly.

WINETRICKS

Often, the application the user tries to run fails because there is a required missing dynamic link library (DLL).

Winetricks is a script that will help the user in that task. With this script, the user can download and install the libraries that are required by the windows programs.

To install:

For the latest version of wine:

Those who have added the Wine repositories in Ubuntu and/or have installed the latest version of Wine, they should have winetricks with a package repository included. This is because it is automatically installed as a dependency when wine is installed.

It may also be desired to install the cabextract package:

sudo apt-get install cabextract

To launch it, press the ALT + F2 key combination and run:

winetricks

A window showing all the libraries will open, select the needed ones, press accept and install as in windows: accept, accept… end.

For other versions of wine:

Open a terminal:

Download winetricks with the following command:

wget http://www.kegel.com/wine/winetricks

This will download the script in users’ personal folder and should never be deleted.

Winetricks does not need to be installed and libraries, it can be installed directly with the following command:

sh winetricks library

Eg. to install the “corefonts” and “directx9″ libraries run:

sh winetricks directx9 corefonts

PLAYONLINUX

PlayOnLinux allows users to run games. It’s in the Ubuntu repositories and can be installed with this command:

sudo apt-get install playonlinux

To install the very last version, add the proper repositories for the Ubuntu version the user has:

Ubuntu 11.04:

wget -q “deb.playonlinux.com/public.gpg” -O- | sudo apt-key add -

sudo wget deb.playonlinux.com/playonlinux_natty.list -O /etc/apt/sources.list.d/playonlinux.list

Ubuntu 10.10:

wget -q “deb.playonlinux.com/public.gpg” -O- | sudo apt-key add -

sudo wget deb.playonlinux.com/playonlinux_maverick.list -O /etc/apt/sources.list.d/playonlinux.list

Ubuntu 10.04:

wget -q “deb.playonlinux.com/public.gpg” -O- | sudo apt-key add -

sudo wget deb.playonlinux.com/playonlinux_lucid.list -O /etc/apt/sources.list.d/playonlinux.list

Once the repositories are added, PlayOnLinux is updated and installed with:

sudo apt-get update

sudo apt-get install playonlinux

For Debian Squeeze, would be:

wget -q “deb.playonlinux.com/public.gpg” -O- | apt-key add -

wget deb.playonlinux.com/playonlinux_squeeze.list -O /etc/apt/sources.list.d/playonlinux.list

apt-get update

apt-get install playonlinux

Learn more about wine compatible software.

Our blog is run and maintained by Linux & Unix fans who volunteered to share their experience with the world at no cost!! This is the power of Linux & Unix!! Visit us on http://www.linux2aix.com.

Tags: , , , , , , ,

"hello world" javascript in LinuxBy David J Selden-Treiman

JavaScript is often useful for website design. It can allow you to dynamically generate content for individual visitors. You can load content dynamically using AJAX. You can create animations that may increase the effectiveness of your website.

However, JavaScript has some drawbacks too.

1. Increased Loading Time

In order for your JavaScript to be loaded by your visitors’ browsers it will need to be downloaded to their computer. This increases the amount of time required to load your webpage.

If you have a very fast internet connection, this may seem insignificant. JavaScript files are often smaller than 100kB, and on a modern wireless or Ethernet connection it will load in less than a second.

However, not all visitors to your website will have a fast internet connection. Some may living in remote locations with slow internet connections. Remember dialup? Some internet connections haven’t gotten much faster than that.

Your webpage may also downloaded by people on mobile devices. While cellphone data connections are getting faster, in many areas, especially in rural parts of the world away from cities, internet connections are still slow. If you use JavaScript on your website, your visitors on these connections will have to wait for it to download.

2. Increased Waiting Time

After your JavaScript has loaded, your visitors’ computers will need to execute your code. If you are using a fast, modern computer, your browser can probably perform your JavaScript quickly and easily.

However, not everybody uses a developer-level computer. Some people use computers that will require a significant amount of time to even start up a browser.

If your JavaScript requires a large amount of time to complete, visitors with slower computers will need to wait… and wait… for your JavaScript to be performed. This may even prevent them from using their computer in other ways.

Having to wait can greatly decrease the quality of these visitors’ experience.

3. Different Implementations

Just like CSS is implemented differently on different computers by different browsers, JavaScript is executed differently depending on the visitors’ machine. This can cause your JavaScript to not work or even make your website unusable.

In general, there are commonly agreed upon standards for how portions of code should be executed. However, not every browser agrees to follow all of the rules. Internet Explorer has historically failed to accept web development standards, causing problems for web developers. (But, thankfully for developers, Microsoft has been getting better about complying with them.)

In addition to browser differences, your code will likely need to operate differently depending on each visitors’ individual machine. Windows, Mac OS, Linux, iOS, Android, and other operating systems all have slightly different (or some times very different) ways of displaying website content.

To compensate for these differences, you will need to design your JavaScript to work with all of these different OSs.

In addition, your JavaScript will need to work with different screen sizes. If you have JavaScript that influences an image that it assumes is 500px by 500px, and a visitor’s screen decreases the size of the image, your JavaScript may not work as you intended. It may harm the appearance of the image or even make the entire page unusable.

Because of the complexity of implementing JavaScript for different browser, OS, and machine configurations, it is usually easier to use alternatives, such as CSS, where possible.

Tags: , , ,

RAID1By Robert Camilleri

We start by listing the partition tables present on the server to locate the new hard disk

[root@mail ~]# fdisk -l

Disk /dev/hda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 13 104391 fd Linux raid autodetect
/dev/hda2 14 6387 51199155 fd Linux raid autodetect
/dev/hda3 6388 6769 3068415 fd Linux raid autodetect
/dev/hda4 6770 60801 434012040 fd Linux raid autodetect

Disk /dev/hdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/hdc doesn’t contain a valid partition table

Disk /dev/md1: 52.4 GB, 52427816960 bytes
2 heads, 4 sectors/track, 12799760 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md1 doesn’t contain a valid partition table

Disk /dev/md3: 444.4 GB, 444428255232 bytes
2 heads, 4 sectors/track, 108502992 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md3 doesn’t contain a valid partition table

Disk /dev/md2: 3141 MB, 3141926912 bytes
2 heads, 4 sectors/track, 767072 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md2 doesn’t contain a valid partition table

Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn’t contain a valid partition table

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 121601 976760001 83 Linux
[root@mail ~]#

The above output shows that there are two hard disks (hda and hdc). Partitions are visible on hda however hdc does not contain a valid partition table. In fact this is the replacement for the faulty disk.

To view the health of the Software RAID type cat /proc/mdstat

[root@mail ~]# cat /proc/mdstat

Personalities: [raid1]

md0: active raid1 hda1[1]

104320 blocks [2/1] [_U]

md2: active raid1 hda3[1]
3068288 blocks [2/1] [_U]

md3: active raid1 hda4[1]
434011968 blocks [2/1] [_U]

md1: active raid1 hda2[1]
51199040 blocks [2/1] [_U]

unused devices:
[root@mail ~]#

Note that [2/1] shows that there are 2 disks in the array however only 1 is active. The symbols [_U] mean that one of the two disks is missing from the array and must be reconfigured.

Since the new disk is /dev/hdc we need create the partitions required for the RAID. Use fdisk to create the boot partition on the new disk.

[root@mail ~]# fdisk /dev/hdc

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

The number of cylinders for this disk is set to 60801.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0×0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/hdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-60801, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801): +100M

Command (m for help): p

Disk /dev/hdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 1 13 104391 83 Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): l

0 Empty 1e Hidden W95 FAT1 80 Old Minix be Solaris boot
1 FAT12 24 NEC DOS 81 Minix / old Lin bf Solaris
2 XENIX root 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
4 FAT16 5 Extended 41 PPC PReP Boot 85 Linux extended c7 Syrinx
6 FAT16 42 SFS 86 NTFS volume set da Non-FS data
7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set db CP/M / CTOS /.
8 AIX 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
f W95 Ext’d (LBA) 54 OnTrackDM6 a5 FreeBSD ee EFI GPT
10 OPUS 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
14 Hidden FAT16 16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fd Linux raid auto
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fe LANstep
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT
1c Hidden W95 FAT3 75 PC/IX
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/hdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 1 13 104391 fd Linux raid autodetect

Command (m for help):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@mail ~]#

Type fdisk -l to verify creation of partition on the second disk

[root@mail ~]# fdisk -l

Disk /dev/hda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 13 104391 fd Linux raid autodetect
/dev/hda2 14 6387 51199155 fd Linux raid autodetect
/dev/hda3 6388 6769 3068415 fd Linux raid autodetect
/dev/hda4 6770 60801 434012040 fd Linux raid autodetect

Disk /dev/hdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 1 13 104391 fd Linux raid autodetect

Disk /dev/md1: 52.4 GB, 52427816960 bytes
2 heads, 4 sectors/track, 12799760 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md1 doesn’t contain a valid partition table

Disk /dev/md3: 444.4 GB, 444428255232 bytes
2 heads, 4 sectors/track, 108502992 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md3 doesn’t contain a valid partition table

Disk /dev/md2: 3141 MB, 3141926912 bytes
2 heads, 4 sectors/track, 767072 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md2 doesn’t contain a valid partition table

Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn’t contain a valid partition table

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 121601 976760001 83 Linux
[root@mail ~]#

Software RAID requires disks in the array to be partitioned identically. You can try to do this manually calculating the exact number of cylinders required for each partition to match their counterparts on the other disk. This is highly discouraged. Instead we use the sfdisk command.

[root@mail ~]# sfdisk -d /dev/hda

# partition table of /dev/hda

unit: sectors

/dev/hda1: start= 63, 208782, Id=fd
/dev/hda2: start= 208845, Id=fd
/dev/hda3: start=102607155, 6136830, Id=fd
/dev/hda4: start=108743985, Id=fd
[root@mail ~]#

The output above displays the partition sizes on the primary disk

In order to create identical partitions on the secondary disk we type the following

[root@mail ~]# sfdisk -d /dev/hda | sfdisk /dev/hdc

Checking that no-one is using this disk right now... 

OK

Disk /dev/hdc: 60801 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/hdc1 0+ 12 13- 104391 fd Linux raid autodetect
/dev/hdc2 0 – 0 0 0 Empty
/dev/hdc3 0 – 0 0 0 Empty
/dev/hdc4 0 – 0 0 0 Empty
New situation:
Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
/dev/hdc1 63 208844 208782 fd Linux raid autodetect
/dev/hdc2 208845 102607154 102398310 fd Linux raid autodetect
/dev/hdc3 102607155 108743984 6136830 fd Linux raid autodetect
/dev/hdc4 108743985 976768064 868024080 fd Linux raid autodetect
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table…

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
[root@mail ~]#

Typing fdisk -l once again displays that the partitions on both disks are in fact identical

[root@mail ~]# fdisk -l

Disk /dev/hda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 13 104391 fd Linux raid autodetect
/dev/hda2 14 6387 51199155 fd Linux raid autodetect
/dev/hda3 6388 6769 3068415 fd Linux raid autodetect
/dev/hda4 6770 60801 434012040 fd Linux raid autodetect

Disk /dev/hdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdc1 1 13 104391 fd Linux raid autodetect
/dev/hdc2 14 6387 51199155 fd Linux raid autodetect
/dev/hdc3 6388 6769 3068415 fd Linux raid autodetect
/dev/hdc4 6770 60801 434012040 fd Linux raid autodetect

Disk /dev/md1: 52.4 GB, 52427816960 bytes
2 heads, 4 sectors/track, 12799760 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md1 doesn’t contain a valid partition table

Disk /dev/md3: 444.4 GB, 444428255232 bytes
2 heads, 4 sectors/track, 108502992 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md3 doesn’t contain a valid partition table

Disk /dev/md2: 3141 MB, 3141926912 bytes
2 heads, 4 sectors/track, 767072 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md2 doesn’t contain a valid partition table

Disk /dev/md0: 106 MB, 106823680 bytes
2 heads, 4 sectors/track, 26080 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn’t contain a valid partition table

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 121601 976760001 83 Linux
[root@mail ~]#

Now that the partitions are identical we can re-sync the information across the RAID configuration

Type mdadm -a /dev/md0 /dev/hdc1 to add /dev/hdc1 partition to the /dev/md0 RAID partition.

[root@mail ~]# mdadm -a /dev/md0 /dev/hdc1

mdadm: added /dev/hdc1

[root@mail ~]#

Type cat /proc/mdstat to view the re-syncing process

[root@mail ~]# cat /proc/mdstat

Personalities: [raid1]

md0: active raid1 hdc1[2] hda1[1]

104320 blocks [2/1] [_U]

[=>... ] recovery = 7.8% (8512/104320) finish=0.7min speed=2128K/sec

md2: active raid1 hda3[1]
3068288 blocks [2/1] [_U]

md3: active raid1 hda4[1]
434011968 blocks [2/1] [_U]

md1: active raid1 hda2[1]
51199040 blocks [2/1] [_U]

unused devices:
[root@mail ~]# cat /proc/mdstat
Personalities: [raid1]
md0: active raid1 hdc1[2] hda1[1]
104320 blocks [2/1] [_U]
[=======>... ] recovery = 37.2% (39808/104320) finish=0.5min speed=1809K/sec

md2: active raid1 hda3[1]
3068288 blocks [2/1] [_U]

md3: active raid1 hda4[1]
434011968 blocks [2/1] [_U]

md1: active raid1 hda2[1]
51199040 blocks [2/1] [_U]

unused devices:

The below shows how the output should be when the re-syncing process has ended. Note the “[UU]“. This confirms that both disks are active.

[root@mail ~]# cat /proc/mdstat

Personalities: [raid1]

md0: active raid1 hdc1[0] hda1[1]

104320 blocks [2/2] [UU]

md2: active raid1 hda3[1]
3068288 blocks [2/1] [_U]

md3: active raid1 hda4[1]
434011968 blocks [2/1] [_U]

md1: active raid1 hda2[1]
51199040 blocks [2/1] [_U]

unused devices:
[root@mail ~]#

The same process has to be performed on the other partitions

[root@mail ~]# mdadm -a /dev/md1 /dev/hdc2

mdadm: added /dev/hdc2

[root@mail ~]# mdadm -a /dev/md2 /dev/hdc3

mdadm: added /dev/hdc3

[root@mail ~]# mdadm -a /dev/md3 /dev/hdc4

mdadm: added /dev/hdc4

[root@mail ~]# cat /proc/mdstat

Personalities: [raid1]

md0: active raid1 hdc1[0] hda1[1]

104320 blocks [2/2] [UU]

md2: active raid1 hdc3[2] hda3[1]
3068288 blocks [2/1] [_U]
resync=DELAYED

md3: active raid1 hdc4[2] hda4[1]
434011968 blocks [2/1] [_U]
resync=DELAYED

md1: active raid1 hdc2[2] hda2[1]
51199040 blocks [2/1] [_U]
[>... ] recovery = 0.0% (37376/51199040) finish=501.5min speed=1698K/sec

unused devices:
[root@mail ~]#

Finally we need to install GRUB on the second disk’s MBR.

[root@mail ~]# grub
GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]

grub> find /grub/grub.conf
(hd0,0)
(hd1,0)

grub> root (hd1,0)
Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd1)
Checking if “/boot/grub/stage1″ exists… no
Checking if “/grub/stage1″ exists… yes
Checking if “/grub/stage2″ exists… yes
Checking if “/grub/e2fs_stage1_5″ exists… yes
Running “embed /grub/e2fs_stage1_5 (hd1)”… 15 sectors are embedded.
succeeded
Running “install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2 /grub/grub.conf”… succeeded
Done.

grub> quit

Tags: , , , , ,
« Previous posts Back to top