Wednesday, March 31, 2010

mengembalikan grub ubuntu 9.10 setelah install windows 7

Bermula dari pengalaman yg saya alami. Linux / Ubuntu memiliki boot loader yang disebut dengan Grub ( GRand Unified Bootloader ). Kurang lebih grub adalah menu di awal booting laptop/PC kita. Isinya untuk memilih OS mana yang akan kita gunakan untuk booting. ( Dengan catatan kita memiliki lebih dari 1 OS ). Masalahnya, Grub milik windows, tidak bisa memunculkan menu untuk booting ubuntu saya, sedangkan Grub milik Ubuntu lengkap, bisa memunculkan semua OS yang terinstall di PC/Laptop saya. ( Pengalaman saya menggunakan 3 OS, semua bisa muncul di menu Grub ubuntu)
Sekarang, saya ingin menjelaskan cara mengembalikan Grub milik ubuntu yang hilang karena tertimpa oleh Grub windows.

caranya :
Nyalakan PC/laptop dan booting dari LiveCD Ubuntu atau flashdisk (yang sudah terisi OS Ubuntu). Cara mengubah urutan booting (boot priority) pada BIOS bisa dicari sendiri lewat google.
Masukkan LiveCD Ubuntu ke dalam CD-ROM (atau flashdisk, tergantung mana yang ingin digunakan).
Pilih Try Ubuntu without any changes to your computer. Tunggu sampai Ubuntu tampil dengan sempurna.
Setelah berhasil masuk ke Ubuntu, buka terminal (klik Applications > Accessories > Terminal, atau tekan kombinasi tombol Ctrl+Alt+F2).
kemudian, muncul menu di terminal.

### lihat partisi kita dengan perintah sudo fdisk -l :

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x996e996e

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20482843+ 7 HPFS/NTFS
/dev/sda2 2551 6559 32202292+ f W95 Ext'd (LBA)
/dev/sda5 2551 5100 20482843+ b W95 FAT32
/dev/sda6 5101 6316 9767488+ 83 Linux
/dev/sda7 6317 6559 1951866 82 Linux swap / Solaris

# Sekarang ketik sudo mount -t ext4 /dev/sda6 /mnt/. CATATAN: sda6 adalah nama partisi Linux di laptop saya. Anda bisa menggantinya sesuai dengan nama partisi Linux di komputer Anda.

# Ketik sudo mount -t proc proc /mnt/proc/
# Ketik sudo mount -t sysfs sys /mnt/sys/
# Ketik sudo mount -o bind /dev/ /mnt/dev/
# Ketik sudo chroot /mnt/ /bin/bash
# Ketik grub-install /dev/sda. Hasilnya muncul tulisan seperti di bawah ini:
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install’.
(hd0) /dev/sda
# Ketik grub-install /dev/sda6. Hasilnya muncul pesan seperti ini:
grub-setup: warn: Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea.
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and its use is discouraged.
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install’.
(hd0) /dev/sda
# ketik update-grub. Hasilnya seperti di bawah ini:
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.31-14-generic
Found initrd image: /boot/initrd.img-2.6.31-14-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows 7 on /dev/sda2
done


Catatan :
Cara ini digunakan untuk ubuntu 9.10 yang menggunakan grub2. sedangkan seri ubuntu 9.04 ke bawah menggunakan grub versi sebelum grub2. Caranya lebih mudah.sama seperti cara di atas sampai tahap masuk terminal, kemudian :

# ketik sudo grub
- root@ubuntu:/boot# grub

# setelah masuk ke grub editor, untuk melihat urutan partisi kita, ketik geometry (hd0);
- grub> geometry (hd0);
geometry (hd0)
drive 0x80: C/H/S = 9729/255/63, The number of sectors = 156301488, /dev/sda
Partition num: 0, Filesystem type unknown, partition type 0xaf
Partition num: 1, Filesystem type is fat, partition type 0xc
Partition num: 3, Filesystem type is fat, partition type 0xb
Partition num: 5, Filesystem type is ext2fs, partition type 0x83
Partition num: 6, Filesystem type unknown, partition type 0x82
Partisi ubuntu saya di num 5 linux, lalu saya ketik:
- grub> root (hd0,5);
lalu untuk menjadikan GRUB Loader-nya berada di MBR, saya ketik;
- grub> setup (hd0)

Jika berhasil akan muncul menu kata2 sukses..

SELAMAT MENCOBA

No comments: