# [solved] Kernel panic after adding a new HD

## ozric

Hi!

Please forgive me if this is a dumb question. Even after several years of experimenting with Gentoo, I still lack (a lot of) basic knowledge and once again need help from the community. 

After adding another SATA drive to my box, I receive a kernel panic when booting. I first needed to reconfigure my bios and set my Gentoo disk (containing grub2 and system) as the first in the hard disk boot order, since the new drive had taken its place.

So kernel panic, removed the new disk, made sure the Gentoo disk was 1st in priority and it boots correctly again.

Here's where I am guessing I should share my dmesg output - but the one in my system is the one generated after my second, successful boot.

4.0.5-gentoo with grub2.

Additional info required will be provided at the speed of light. Thank you kindly!Last edited by ozric on Wed Sep 02, 2015 4:52 pm; edited 1 time in total

----------

## DONAHUE

did you run grub2-mkconfig -o /boot/grub/grub.cfg after the disk swap?

----------

## ozric

I never swapped disks. I simply added a new disk to an available SATA connector in my PC for additional data storage. The disk containing my OS and Grub boot loader is left precisely as before I added it. After installing the new disk on my computer, the bios wanted to boot from the new drive so I changed the boot order to recognize the disk containing the OS first (the way it was before installing the new drive).

When doing so, the boot process is halted with a kernel panic message.

I then removed the new drive, once again made sure my Gentoo system disk was 1st in order to boot in the bios, and then it works.

So I need to figure out why I am getting a kernel panic when the new disk is installed.

----------

## DONAHUE

did you run grub2-mkconfig -o /boot/grub/grub.cfg after the disk addition?

----------

## ozric

Thanks for the answer, I should have mentioned that more clearly, but after the disk installation I cannot boot the system at all (kernel hangs already early in the boot process), so I can't run grub2-mkconfig or anything else for that matter  :Smile: 

----------

## Tony0945

As a guess, your first drive is not attached to the first controller and your second drive was attached to a lower numeric controller causing it to be /dev/sda when both drives were in the system. Now for the system I'm currently on:

```
X3 tony # ls -l /sys/block/sda

lrwxrwxrwx 1 root root 0 Sep  1 17:00 /sys/block/sda -> ../devices/pci0000:00/0000:00:11.0/ata1/host0/target0:0:0/0:0:0:0/block/sda

X3 tony # ls -l /sys/block/sdb

lrwxrwxrwx 1 root root 0 Sep  1 17:00 /sys/block/sdb -> ../devices/pci0000:00/0000:00:11.0/ata3/host2/target2:0:0/2:0:0:0/block/sdb

X3 tony # ls -l /sys/block/sdc

lrwxrwxrwx 1 root root 0 Sep  2 08:24 /sys/block/sdc -> ../devices/pci0000:00/0000:00:13.2/usb2/2-2/2-2:1.0/host8/target8:0:0/8:0:0:0/block/sdc

X3 tony # ls -l /sys/block/sdd

ls: cannot access /sys/block/sdd: No such file or directory

```

My sda is attached to the first controller (of six) but my second drive is attached to the third controller. If i were to add another drive and plugged it into the slot for controller 2, it would become sdb and the current sdb would become sdc. Since the ATA controller is scanned first, the USB drive would move up no matter which port the SATA drive was plugged into.

Motherboard manuals can be really confusing as to which port is which.

On my portage server: *Quote:*   

> 
> 
> gentoo ~ # ls -l /sys/block/sd*
> 
> lrwxrwxrwx 1 root root 0 Sep  2 08:35 /sys/block/sda -> ../devices/pci0000:00/0000:00:08.0/ata1/host0/target0:0:0/0:0:0:0/block/sda
> ...

 

On my oldest system that is IDE with no SATA *Quote:*   

> biostar ~ # ls -l /sys/block/sd*
> 
> ls: cannot access /sys/block/sd*: No such file or directory
> 
> biostar ~ # ls -l /sys/block/hd*
> ...

 

If you would, please post your results for "ls -l /sys/block/sd*"

----------

## DONAHUE

what tony said.

might be well to make disk attachments sane.

your motherboard and its manual should identify sata controllers and connections, suggest put the gentoo drive on sata1 and the new drive on sata 3.

boot install cd/usb, mount the gentoo partitions, enter chroot to do work with new disk installed 

grub2-mkconfig -o /boot/grub/grub.cfg 

reboot to gentoo

----------

## ozric

Thanks kindly for your replies. This is the output from /sys/block/sd* and my system disk resides on sda. This is without the new disk installed.

```

ls -l /sys/block/sd*

lrwxrwxrwx 1 root root 0 Sep  2 14:32 /sys/block/sda -> ../devices/pci0000:00/0000:00:11.0/ata4/host3/target3:0:0/3:0:0:0/block/sda

lrwxrwxrwx 1 root root 0 Sep  2 14:32 /sys/block/sdb -> ../devices/pci0000:00/0000:00:11.0/ata5/host4/target4:0:0/4:0:0:0/block/sdb

lrwxrwxrwx 1 root root 0 Sep  2 14:32 /sys/block/sdc -> ../devices/pci0000:00/0000:00:11.0/ata6/host5/target5:0:0/5:0:0:0/block/sdc

```

----------

## DONAHUE

 *Quote:*   

> This is without the new disk installed.

  No surprise.

add the new disk boot install media run /sys/block/sd*  or parted -l or fdisk -l

at boot the kernel probes for hard drives, the first one found is enumerated as sda

----------

## Tony0945

 *ozric wrote:*   

> Thanks kindly for your replies. This is the output from /sys/block/sd* and my system disk resides on sda. This is without the new disk installed.
> 
> ```
> 
> ls -l /sys/block/sd*
> ...

 

You have them on the last three controllers instead of the first three. Seems simplest to move the SATA connecters. Unplug them, then plug the boot drive until it shoes up ata1. Then do the same with the other two. A lot of booting & shutting down, but safer than messing with the installation.

lrwxrwxrwx 1 root root 0 Sep  2 14:32 /sys/block/sda -> ../devices/pci0000:00/0000:00:11.0/ata4/host3/target3:0:0/3:0:0:0/block/sda

lrwxrwxrwx 1 root root 0 Sep  2 14:32 /sys/block/sdb -> ../devices/pci0000:00/0000:00:11.0/ata5/host4/target4:0:0/4:0:0:0/block/sdb

lrwxrwxrwx 1 root root 0 Sep  2 14:32 /sys/block/sdc -> ../devices/pci0000:00/0000:00:11.0/ata6/[/b]host5/target5:0:0/5:0:0:0/block/sdc

----------

## Buffoon

Looking at the motherboard and the manual will reveal how ports are numbered.

----------

## ozric

Thanks again for your replies. Correct that the disks were connected to the mobo in the wrong order (they were even neatly numbered).

My mistake was assuming the bios would pass the appropriate information to the kernel (ie. moving my system drive to the first position would solve the problem) - but the system is actually depending on the physical SATA ports (makes sense).

Solved by re-connecting the drives to the SATA ports on the mobo in the right order (system drive at port 0).

Thanks for your help!

----------

