LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Ubuntu Custom kernel - kp: cannot open root device "sda1" (https://www.linuxquestions.org/questions/linux-software-2/ubuntu-custom-kernel-kp-cannot-open-root-device-sda1-695898/)

Thaidog 01-08-2009 01:21 PM

Ubuntu Custom kernel - kp: cannot open root device "sda1"
 
I am trying to compile a custom kernel for Ubuntu and I am getting a kernel panic:

VFS: Cannot open root device "sda1" or unkown-block(0,0)

This same kernel boots on Gentoo so i know I have the right device drivers and filesystem drivers.

Any idea why this is going to a kernel panic?

kilgoretrout 01-08-2009 01:38 PM

Are you using and initrd and if so, how was it generated? Usually, you get that type of error message when you don't have the drivers for your root partition to be recognized or you have a misconfigured grub which also results in your root partition not being found. You may want to post the grub entry you are using for the custom kernel as it appears in both gentoo and ubuntu.

Thaidog 01-08-2009 02:45 PM

Quote:

Originally Posted by kilgoretrout (Post 3401438)
Are you using and initrd and if so, how was it generated? Usually, you get that type of error message when you don't have the drivers for your root partition to be recognized or you have a misconfigured grub which also results in your root partition not being found. You may want to post the grub entry you are using for the custom kernel as it appears in both gentoo and ubuntu.

I'm not using an initrd with this kernel.

I compiled another kernel on Gentoo and moved to Ubuntu and this time it errors here:


VFS: Cannot open root device "sda1" or unkown-block(2,0)

instead of:

VFS: Cannot open root device "sda1" or unkown-block(0,0)

I went in to grub and set it up manually on both systems and it's working fine on Gentoo.

rm_dash_rf_star 01-08-2009 03:45 PM

I recently had this same issue.

When the kernel boots, it uses udev to assign device nodes to physical devices. What you need to do is create a udev rule that will make sure that the kernel assigns the root of your Ubuntu filesystem (your root device) to a consistent name that you choose (/dev/hda1 might be an example in the case of an IDE/ATA hard drive).

Then, when you bootstrap your kernel, pass in the root=/dev/hda1 option (or whatever other device node that you choose) to the kernel so that it knows where to find your root device. From there, the kernel will execute /sbin/init to load your boot scripts and continue booting.

It is likely that Ubuntu already has said rule, and all that you need to do is determine which name udev is giving your hard drive.

One other thought---

I think that you are missing a driver in your kernel (or at least it is compiled in as a module, in which case having an initrd would solve the problem this `other' issue).

What I did was issue a `make ARCH=i386 defaultconfig' to configure the kernel. Look at the `README' file in the .../linux directory in order to figure out what the exact name of defaultconfig is (such as defconfig).

I think that this will fix this problem, in which case the only thing left for you to do is to pass in root=<device node> as per udev's rules.

Thaidog 01-08-2009 04:29 PM

Quote:

Originally Posted by rm_dash_rf_star (Post 3401571)
I recently had this same issue.

When the kernel boots, it uses udev to assign device nodes to physical devices. What you need to do is create a udev rule that will make sure that the kernel assigns the root of your Ubuntu filesystem (your root device) to a consistent name that you choose (/dev/hda1 might be an example in the case of an IDE/ATA hard drive).

Then, when you bootstrap your kernel, pass in the root=/dev/hda1 option (or whatever other device node that you choose) to the kernel so that it knows where to find your root device. From there, the kernel will execute /sbin/init to load your boot scripts and continue booting.

It is likely that Ubuntu already has said rule, and all that you need to do is determine which name udev is giving your hard drive.

One other thought---

I think that you are missing a driver in your kernel (or at least it is compiled in as a module, in which case having an initrd would solve the problem this `other' issue).

What I did was issue a `make ARCH=i386 defaultconfig' to configure the kernel. Look at the `README' file in the .../linux directory in order to figure out what the exact name of defaultconfig is (such as defconfig).

I think that this will fix this problem, in which case the only thing left for you to do is to pass in root=<device node> as per udev's rules.

This makes since but I have tried using the UUID parameter already defined by Ubuntu as a UUID and I get the same thing.

It looks like this:

kernel=/boot/kernel-custom root=UUID=43h4l5lh235lh34h345j3534'53j45

or

kernel=/boot/kernel-custom root=/dev/sda1

either fails with the same message.

I know the driver is not missing bc I have booted the same system on Gentoo and it boots fine.

Thaidog 01-08-2009 04:34 PM

It looks like the udev HD rules are in /etc/udev/rules.d/60-persistent-storage.rules

Not sure what to do with this file though...

root@linux-desktop:/etc/udev/rules.d# cat 60-persistent-storage.rules
# do not edit this file, it will be overwritten on update

# persistent storage links: /dev/disk/{by-id,by-uuid,by-label,by-path}
# scheme based on "Linux persistent device names", 2004, Hannes Reinecke <hare@suse.de>

# forward scsi device event to corresponding block device
ACTION=="change", SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST=="block", ATTR{block/*/uevent}="change"

ACTION!="add|change", GOTO="persistent_storage_end"
SUBSYSTEM!="block", GOTO="persistent_storage_end"

# skip rules for inappropriate block devices
KERNEL=="ram*|loop*|fd*|nbd*|gnbd*|dm-*|md*", GOTO="persistent_storage_end"

# never access non-cdrom removable ide devices, the drivers are causing event loops on open()
KERNEL=="hd*[!0-9]", ATTR{removable}=="1", DRIVERS=="ide-cs|ide-floppy", GOTO="persistent_storage_end"
KERNEL=="hd*[0-9]", ATTRS{removable}=="1", GOTO="persistent_storage_end"

# ignore partitions that span the entire disk
TEST=="whole_disk", GOTO="persistent_storage_end"

# /sys/class/block will export this
ENV{DEVTYPE}!="?*", ATTR{range}=="?*", ENV{DEVTYPE}="disk"
ENV{DEVTYPE}!="?*", ATTR{start}=="?*", ENV{DEVTYPE}="partition"

# for partitions import parent information
ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"

# by-id (hardware serial number)
KERNEL=="hd*[!0-9]", IMPORT{program}="ata_id --export $tempnode"
KERNEL=="hd*[!0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}"
KERNEL=="hd*[0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/ata-$env{ID_MODEL}_$env{ID_SERIAL}-part%n"

KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", ENV{ID_SERIAL}="$attr{ieee1394_id}", ENV{ID_BUS}="ieee1394"
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{program}="usb_id --export %p"
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $tempnode", ENV{ID_BUS}="scsi"
KERNEL=="cciss?c[0-9]d[0-9]", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $tempnode", ENV{ID_BUS}="cciss"
KERNEL=="sd*[!0-9]|sr*|cciss?c[0-9]d[0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
KERNEL=="sd*[0-9]|cciss*p[0-9]", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"

# libata compat (links like hd*)
KERNEL=="sd*[!0-9]|sr*", ENV{ID_VENDOR}=="ATA", PROGRAM="ata_id $tempnode", RESULT=="?*", ENV{ID_ATA_COMPAT}="$result", SYMLINK+="disk/by-id/ata-$env{ID_ATA_COMPAT}"
KERNEL=="sd*[0-9]", ENV{ID_ATA_COMPAT}=="?*", SYMLINK+="disk/by-id/ata-$env{ID_ATA_COMPAT}-part%n"

KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
KERNEL=="mmcblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}-part%n"

# by-path (shortest physical path)
ENV{DEVTYPE}=="disk", IMPORT{program}="path_id %p"
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"

# skip unpartitioned removable media devices from drivers which do not send "change" events
ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1", GOTO="persistent_storage_end"
# skip optical drives without media
ENV{DEVTYPE}=="disk", KERNEL=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT}!="?*", GOTO="persistent_storage_end"

# import filesystem metadata
IMPORT{program}="vol_id --export $tempnode"

# by-label/by-uuid links (filesystem metadata)
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"

LABEL="persistent_storage_end"


All times are GMT -5. The time now is 02:37 PM.