GRUB is a boot loader commonly used with linux operating system. It can be used to managed dual boot environment where linux and windows can coexist easily in a same machine without problem provided you install the windows OS first so that when you install linux, GRUB will overwrite Windows boot loader and automatically detect and manage both operating system the next time you boot your computer. Problems will happen if you alter your partitions outside the knowledge of GRUB, for example, you create new partition in your hard drive using windows. This will cause GRUB to automatically go into GRUB shell when boot. To restore back your GRUB is very simple, just follow easy steps below:
1. find in which partition does GRUB store its configuration file, which is your /boot partition. (hd0,2) means third partition of the first hard drive
grub> find /boot/grub/stage1
(hd0,2)
2. set the root for GRUB to be (hd0,2)
grub> root (hd0,2)
3. write GRUB to the Master boot record(MBR) of your hard drive. Change (hd0) to (hd0,2) to write GRUB to your /boot partition instead
grub> setup (hd0)
4. Reboot machine
grub> reboot
All those steps can also be used using livecd, if let say the grub shell did not come out but you cannot boot your machine or you cannot boot your linux due to messed up GRUB. just boot from livecd, open a terminal, and type "grub" as a superuser to go to GRUB shell
Tuesday, September 29, 2009
Restore GRUB
Thursday, August 6, 2009
Mounting Windows shared folder on linux
Mounting windows shared folder on linux is very easy provided you know the ip of the windows machine, the name of the folder that is being shared, the username and password of the windows machine. As far as I know, there are 2 ways you can mount your windows shared folder on your linux machine.
The first way:
For gnome user, type Ctrl+F2, and type smb://windows_machine_ip/shared_folder_name. For example, see below picture
You can access the folder from Places
The second way:
Using command line;
sudo mount -t cifs //windows_machine_ip/shared_folder_name /directory_to_mount -o username=username,password=userpassword
example for mounting a shared folder named MP3 on 192.168.1.110 using windows username usin and password 123456 to /home/user/mp3:
$ sudo mount -t cifs //192.168.1.110/MP3 /home/user/mp3 -o username=usin,password=123456
Your shared folder now can be accessed from /home/user/mp3
That's all friends :)
Friday, July 24, 2009
Labeling linux partition
In linux, to label a partition, there are 3 tools that can be used. The tools are e2label, tune2fs and mke2fs.
To use e2label to label the second partition of the first hardisk with label DATA:
# e2label /dev/sda2 DATA
To use tune2fs to do the similar job as above:
# tune2fs -L DATA /dev/sda2
The third tool, mke2fs is actually a tool to build ext2/ext3 filesystem. So, if you want to build the partition's filesystem as ext2/ext3 and at the same time label it, this command can be used. Be careful though, because it will delete all existing data on that particular partition
# mke2fs -L DATA /dev/sda2
To view the label that you have set, there are 3 ways which are using e2label, blkid and viewing /dev/disk/by-label.
To check using e2label:
# e2label /dev/sda2
DATA
blkid tool is even more useful, because it can list out all the partitions that you have in the machine together with their labels,uuid and filesystem type:
# blkid
/dev/sda1: LABEL="/" UUID="1CC08F13C08EF276" TYPE="ext3"
/dev/sda2: LABEL="DATA" UUID="2063f830-fe5d-438e-b727-571b313cb89e" TYPE="ext3"
/dev/sda3: TYPE="swap" LABEL="SWAP" UUID="3e266b53-42e0-4f09-8fe3-d1cf79cb5d37"
To view the /dev/disk/by-label
# ls -l /dev/disk/by-label
total 0
lrwxrwxrwx 1 root root 10 2009-07-24 05:38 / -> ../../sda1
lrwxrwxrwx 1 root root 10 2009-07-24 05:38 DATA -> ../../sda2
lrwxrwxrwx 1 root root 10 2009-07-24 05:38 SWAP -> ../../sda3
Note that the label will stay with the partition although the disk is moved to another computer.
To use it in /etc/fstab:
LABEL=/ / ext3 defaults 1 1
LABEL=DATA /DATA ext3 defaults 1 2
LABEL=SWAP swap swap defaults 0 0
Monday, June 22, 2009
Hyper terminal for linux
For people that manage hardware devices such as storage, routers and many more using Microsoft Windows, the term hyper terminal is a familiar thing. They use hyper terminal to connect to all the devices mentioned above using serial cable. But what if you have to manage all those devices using linux?
The answer is, linux has 2 alternatives to hyper terminal; one is command line based and the other is GUI based. Let me start with the command line tool first. It is called minicom. You can install this tool using package manager of your linux machine. In fedora/redhat/centos:
# yum install minicom
Running it for the first time requires you to do some settings by running below command as root:
# minicom -s
Picture below shows the screen after command minicom -s
This is where you set the baudrate, serial device you want to use etc. After finish with the setting, save it so that you do not have to do it every time. You can save it to default .dfl file, with the name of .minirc.dfl in your home folder, or you can specify the name and location yourselves. To change the saved setting, just use the above command back.
The second tool is called cutecom, a graphical serial terminal. To install it on fedora,centos or redhat:
# yum install cutecom
It is easier to use since it has GUI. Picture below shows cutecom main screen, where you can set your device, parity, baudrate etc.
Monday, June 15, 2009
Validate your downloaded files using md5
When you download files, especially iso for your favourite linux distro, how do you validate the files is properly downloaded or not? This is where md5 checksum comes into picture. From manpage of md5sum; md5sum is used to compute and check MD5 message digest. What is MD5 exactly?
"MD5 is a widely used cryptographic hash function with a 128-bit hash value. As an Internet standard (RFC 1321), MD5 has been employed in a wide variety of security applications, and is also commonly used to check the integrity of files. However, it has been shown that MD5 is not collision resistant; as such, MD5 is not suitable for applications like SSL certificates or digital signatures that rely on this property. An MD5 hash is typically expressed as a 32 digit hexadecimal number "
The above definition is extracted from www.wikipedia.org
To make it simple, the usage to this magnificent tool is just to validate the correctness of any file that we download from the internet. This is very important especially when we downloaded big files such as linux distro iso so that we won't burn a corrupted iso. The easiest way to check the correctness of the iso is by using md5sum
How to use:
to check the md5sum of a file
$ md5sum filename
Example:
Lets say we have a file named test.txt. Run the md5sum command to this file:
$ md5sum test.txt
d968a9cf53f4cb21b06a888e2a6f4cb6
Compare the string that we got with the md5 string provided by the provider of the file. If similar, test.txt is in good order.
If you have more than one file to be checked, use flag -c to check from file. Example, we have 2 files, test.txt and test2.txt, and we want to check both using md5 validation. First, create a file that follow the format
d968a9cf53f4cb21b06a888e2a6f4cb6 test.txt
52dba85eb1460f265ddf3de51e91652a test2.txt
Save the file as md5sum.txt
Place the md5sum.txt with test.txt and test2.txt in a same folder
Run md5sum command to check:
$ md5sum -c md5sum.txt
If success, the output will be like this:
test.txt OK
test2.txt OK
You are done with the testing and test.txt and test2.txt is validated as correct using MD5 checksum :)