Tuesday, September 18, 2012

Netinstall CentOS 6.3 from USB disk

From Windows:
Use Ubootnetin:





From Linux :
If you want to install CentOS from USB disk you simply need to download the netinstall.iso (which is analog to the boot.iso that Red Hat provides).

It seems they made this netinstall.iso a hybrid one. (can be booted from cd and from disk (USB))

So you can just dd it to your USB disk.

To check what device udev made for your inserted USB check last dmesg output

[ 5620.253160] scsi 6:0:0:0: Direct-Access     SanDisk  Cruzer           8.02 PQ: 0 ANSI: 0 CCS
[ 5620.256030] sd 6:0:0:0: Attached scsi generic sg5 type 0
[ 5620.256236] sd 6:0:0:0: [sdd] 7856127 512-byte logical blocks: (4.02 GB/3.74 GiB)
[ 5620.257637] sd 6:0:0:0: [sdd] Write Protect is off
[ 5620.257643] sd 6:0:0:0: [sdd] Mode Sense: 45 00 00 08
[ 5620.258645] sd 6:0:0:0: [sdd] No Caching mode page present
[ 5620.258666] sd 6:0:0:0: [sdd] Assuming drive cache: write through
[ 5620.262683] sd 6:0:0:0: [sdd] No Caching mode page present
[ 5620.262718] sd 6:0:0:0: [sdd] Assuming drive cache: write through
[ 5620.264633]  sdd: sdd1
[ 5620.268622] sd 6:0:0:0: [sdd] No Caching mode page present
[ 5620.268643] sd 6:0:0:0: [sdd] Assuming drive cache: write through
[ 5620.268652] sd 6:0:0:0: [sdd] Attached SCSI removable disk


 Then do the dd:

dd CentOS-6.3-x86_64-netinstall.iso /dev/sdd
What the netinstall iso does, is booting the anaconda installer. It does not contain any repository. In the installer you have to select which repository you want to use. For example: http://linux.mirrors.es.net/centos/6.3/os/x86_64/

Saturday, September 15, 2012

How to rescue missing /boot partition on fedora

How to rescue missing /boot partition.

There are many cases for where the /boot partition can go missing.

It can be accidently erased/corrupted when using dd with a wrong device or in windows (when dual booting), etc

But there is an easy fix to get your /boot partition back without using any backup/restore method!

I tested this in fedora 16, but probably also applicable in all fedora, RHEL, CentOS, Scientific linux releases.

What you have to do is to boot from your fedora 16 install media (DVD).

When booted, choose rescue installed system menu option.

Make sure you enable the network and letting it discover all filesystem in the wizards that follow.
Once the wizards are done, go into shell and use chroot /mnt/sysimage.

First thing you have to try is to mount /boot from the device where it was installed before. If this fails you have to recreate the /boot filesystem:

My /boot was a filesystem on top of dedicated raid mirror so I did:

mdadm -A --scan
mkfs.ext4 /dev/mdo
mount /dev/md0 /boot

(/dev/md0 can be replaced to whatever your /boot filesystem resides on).

Probably your fstab uses the UUID of /boot to mount it. Comment /boot line in fstab for now with vi. We will enable it back once we are booted again.

Next, you need to have the kernel and the initramfs on the /boot filesystem along with grub2 files.
To achieve this run:

yum install kernel (to get kernel and initramfs back)

(you can use yum reinstall kernel also if you do not want the latest available in the repository).

If for any reason your bootloader is broken too you have to reinstall/reconfigure it.

In my case I had grub2 as a bootloader (when using grub consult documentation on how to reinstall this in rescue mode)

In my case I have a mirror raid for /boot, so I reinstall grub2 on the two devices (to be able to boot from the second if the first one fails)

grub2-install /dev/sda
grub2-install /dev/sdb


Regenerate the grub2 config file
grub2-mkconfig -o /boot/grub2/grub.cfg

Eject your fedora16 dvd and boot normally. Voila, your system is up and running again!

In your booted system you still need to add /boot back to fstab (Reason is to not break grub2 tools)

blkid /dev/md0

Replace the returned UUID in fstab

If you have SElinux enabled:

restorecon -vR /boot

So highlevel summary of the steps:
  • Boot into rescue mode
  • Recreate /boot filesystem
  • Reinstall kernel
  • Reinstall grub2 (if applicable)
  • Reconfigure grub2 (if applicable)
  • Reboot