December 8

Linux: Grub repair tips

One of the most common problems when you have a dual boot option is a dreaded Grub error message at boot up…this can happen for instance if you resize a partition using programs like Gparted in linux…thing is you cannot resize your linux partition if your using it…so to do this you have to “Boot to the Live” distro to make changes to existing partitions.

So ok we resized or deleted partition and allocated free space to expand your drive…now in some cases like mine recently i had one of my systems duel boot with XP pro / Ubuntu 8.10

I decided to delete the XP pro and resize my linux…then i hit on a problem at boot up

I got the dreaded Grub loading error 22 message and could not boot to any OS on the system…so had to manually repair the grub boot loader…here is what iI did and it might help others if you have the same problem:

This is not new and a well documented linux procedure am just doing it here for GSO members who might have had the same problem like I did.

OK lets begin:

1)Boot from a live distro ie Ubuntu

2)Open a console

3)type in: sudo grub

4)type in: root (hd and hit the TAB button

this will then show you what physical drives you have and return usually as

root (hd0, or hd1

hit the TAB again and it will list possible partitions similar to this

grub> root (hd0,
Possible partitions are:
Partition num: 0, Filesystem type unknown, partition type 0�7
Partition num: 2, Filesystem type is ext2fs, partition type 0�83
Partition num: 4, Filesystem type unknown, partition type 0�7
Partition num: 5, Filesystem type is fat, partition type 0xb
Partition num: 6, Filesystem type is fat, partition type 0xb
Partition num: 7, Filesystem type unknown, partition type 0�82

The one were interested in is 2 with the ext2fs … this is the one with the linux installed to

so we type

root(hd0,2)

*caution*

providing hd0 is the main physical partition it could be hd1 remember !!

ok so after you have typed root(hd0,2)

you need to type:

setup (hd0)

close terminal exit live cd and reboot…you should have your grub loader repaired

REMEMBER this is for Linux repair… NOT… windows you need to reset MBR if you deleted linux partition and getting a grub loading error message.

By: Kenny

Category: Linux | Comments Off on Linux: Grub repair tips
December 8

Linux: Grub2 commands and tips

sudo os-prober (looks for available OS on partitions)

sudo update-grub (rebuilds the Grub boot menu)

gksu gedit /etc/default/grub (Dangerous file that allows you to modify Grub options) – Back this up before modifying

Category: Linux | Comments Off on Linux: Grub2 commands and tips
December 8

Linux: Reinstalling Grub

Boot into a live Linux CD or USB
(Note: It is safest to us the same version of OS that is on your PC, but at minimum match the 32bit or 64bit and the Grub version)

Start a terminal session
Type: sudo fdisk -l
Find the boot partition of you linux installation (In this example we have it install on /dev/sda5)

sudo mount /dev/sda5 /mnt *****Using the linux installation on your hard drive instead of /dev/sda5
Create some neccessary hardlinks
sudo mount –bind /dev /mnt/dev
sudo mount –bind /proc /mnt/proc
sudo mount –bind /sys /mnt/sys
sudo chroot /mnt
grub-install /dev/sda *****Using your boot device instead of /dev/sda
CTRL-D
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt

 

By: Nixie modified by Nighthawk

Category: Linux | Comments Off on Linux: Reinstalling Grub
December 7

Linux: Bash History Control

Clear history:
history -c

rm ~/.bash_history
touch ~/.bash_history

Clear a point in history:
history -d ###

Special History Control:

export HISTORYCONTROL=ignorespace (Put a space before any command and it will not be logged)

export HISTIGNORE=”pass:wget:ls” (Any command in the “” will not be logged in the history file)

Note: You can use the unset command to stop bash from remembering a variable:
eg. unset password

By: HAK5

Category: Linux | Comments Off on Linux: Bash History Control