LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   cfdisk, add new partition, boot problems (https://www.linuxquestions.org/questions/linux-software-2/cfdisk-add-new-partition-boot-problems-400429/)

haertig 01-06-2006 09:28 PM

cfdisk, add new partition, boot problems
 
This has got to be simple, but I'll ask in case someone knows the answer and can shorten my research and recovery time.

I used cfdisk to add a new partition in unused space. This shifted all my existing Linux partitions up by one number (because my free space was in the middle of the disk, not the end). Now I have two boot problems: (1) grub appears to have lost it's menu.lst, and (2) if I manually boot from grub it dies with a kernel panic that it can't find an ext3 filesystem on /dev/hda7 (and it won't, because /dev/hda7 is the new swap). I made changes to menu.lst and also to fstab before rebooting, but something didn't work as I expected.

Partitions:

BEFORE:
/dev/hda1 FAT32 (primary)
/dev/hda2 NTFS (primary)
/dev/hda3 (extended)
/dev/hda5 Linux LVM (logical)
/dev/hda6 swap (logical)
/dev/hda7 / (logical)
/dev/hda8 /boot (logical)

AFTER:
/dev/hda1 FAT32 (primary)
/dev/hda2 NTFS (primary)
/dev/hda3 (extended)
/dev/hda5 Linux LVM (logical) <- the newly created LVM
/dev/hda6 Linux LVM (logical) <- the original LVM
/dev/hda7 swap (logical)
/dev/hda8 / (logical)
/dev/hda9 /boot (logical)

Before rebooting, I changed /boot/grub/menu.lst as appeared appropriate. "root (hd0,7)" was changed to "root (hda0,8)" and the kernel line was changed to reflect "root=/dev/hda8". I also edited /etc/fstab and changed the line for swap from /dev/hda6 to /dev/hda7. Similar changes for the / (changed /dev/hda7 to /dev/hda8) and /boot (changed /dev/hda8 to /dev/hda9). I thought this should have repointed everything to the newly numbered partitions. I thought these changes would make me good to go. Wrong!

Reboot, and it comes straight up to a grub> prompt. No errors. It just looks like it doesn't know about /boot/grub/menu.lst anymore.

I can force it to continue boot by manually typing in the appropriate root, kernel, initrd, and boot lines at the grub> prompt and off it goes. It finds vmlinuz, etc., and starts to boot.

Shortly thereafter it dies with a kernel panic saying it can't find an ext3 filesystem on /dev/hda7. Well, I guess that's true given /dev/hda7 is now the swap partition. What I don't understand is WHY is it looking for ext3 on hda7? Nothing in fstab tells it that. I booted Knoppix and verified the changes to menu.lst and fstab were accurately done. I will triple check this, but my eyeballs and Knoppix keep telling me I did what I intended!

The specific messages when it dies are:
Code:

VFS: can't find ext3 filesystem on dev hda7
mount: wrong fstype, bad option.....
Switching root...
/usr/lib/yaird/exec/run_init: current directory is on same fielsystem as the root: Success
Kernel panic - not syncing: Attempted to kill init!

Note: /usr is mentioned above. I have /usr as a seperate mountpoint on LVM. I can't scroll back on the screen to see what messages have already flown past (the system is halted) but I don't think any LVM stuff would have been done yet.

I must have missed something simple in my above steps. Anybody know WHAT?

[edit]
I should have mentioned, but forgot: Grub is not installed in my MBR. It is installed up there in /boot (hda9). I use XOSL as a boot loader to jump things up to hda9. That part works fine, as I'm getting to a grub> prompt.
[/edit]

Thanks!

bigrigdriver 01-07-2006 12:13 AM

Since you can manually get it to boot from grub prompt, all is not lost.

Question: did you format /dev/hda7 for swap after creating the partition? If not, mkswap /dev/hda7 will fix that. The error message you are getting seems to indicate that it's not formated yet.

"I changed /boot/grub/menu.lst as appeared appropriate. "root (hd0,7)" was changed to "root (hda0,8)""

I hope that "root (hda0,8)" is a typo. It should be "root (hd0,8)"

Beyond this, I'd need to see the menu.lst entry and fstab entries for the partitions.

haertig 01-07-2006 12:38 AM

Quote:

Originally Posted by bigrigdriver
Since you can manually get it to boot from grub prompt, all is not lost.

Question: did you format /dev/hda7 for swap after creating the partition? If not, mkswap /dev/hda7 will fix that. The error message you are getting seems to indicate that it's not formated yet.

"I changed /boot/grub/menu.lst as appeared appropriate. "root (hd0,7)" was changed to "root (hda0,8)""

I hope that "root (hda0,8)" is a typo. It should be "root (hd0,8)"

Beyond this, I'd need to see the menu.lst entry and fstab entries for the partitions.

Thanks for the quick reply!

I did not do a mkswp on /dev/hda7. That is because this partition was previously /dev/hda6 and had already been functioning as a swap file. My cfdisk renumbered the partitions, but I figure if /dev/hda6 used to be a swap, and now it's /dev/hda7 then it would still be a swap ... without any further mkswp-ing on my part.

(hda0,8) was a typo. I meant (hd0,8).

Below are my fstab and menu.lst. These are my modified versions, after I made changes that I thought would work with my cfdisk.

I tried to run a "fdisk -l /dev/hda" from Knoppix, but it just doesn't seem to want to give me any output. I'm not sure about how to get that info dumped from within Knoppix. It appears that it can't read /dev/hda. however, it has automounted /dev/hda7, 8, and 9 (also /dev/hda1 and 2 - my Windows partitions).

[edit]
Duh! It helps to become root while in Knoppix if you want fdisk output! Here it is:
Code:

Disk /dev/hda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hda1              1          34      273073+  b  W95 FAT32
/dev/hda2              35        799    6144862+  7  HPFS/NTFS
/dev/hda3            2272      24321  177116625    f  W95 Ext'd (LBA)
/dev/hda5            2272      22939  166015678+  8e  Linux LVM
/dev/hda6          22940      24214    10241406  8e  Linux LVM
/dev/hda7          24215      24278      514048+  82  Linux swap / Solaris
/dev/hda8          24279      24317      313236  83  Linux
/dev/hda9  *      24318      24321      32098+  83  Linux

Also note: When booting Knoppix, it recognizes and uses /dev/hda7 as swap space.
[/edit]

Code:

# /etc/fstab: static file system information.
#
# <file system> <mount point>  <type>  <options>      <dump>  <pass>
proc            /proc          proc    defaults        0      0
/dev/hda8      /              ext3    defaults,errors=remount-ro 0      1
/dev/hda9      /boot          ext3    defaults        0      2
/dev/mapper/vg0-debian_home /home          ext3    defaults        0      2
/dev/mapper/vg0-debian_opt /opt            ext3    defaults        0      2
/dev/mapper/vg0-debian_tmp /tmp            ext3    defaults        0      2
/dev/mapper/vg0-debian_usr /usr            ext3    defaults        0      2
/dev/mapper/vg0-debian_var /var            ext3    defaults        0      2
/dev/hda7      none            swap    sw              0      0
/dev/hdc        /media/cdrom0  iso9660 ro,user,noauto  0      0
/dev/hda2        /mnt/familyroom/c        ntfs        ro,noauto,umask=0222        0        0
/dev/hda1        /mnt/familyroom/d        vfat        noauto,umask=0000        0        0
//192.168.0.51/c        /mnt/bedroom/c        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0
//192.168.0.51/f        /mnt/bedroom/f        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0
//192.168.0.51/h        /mnt/bedroom/h        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0
//192.168.0.53/c        /mnt/livingroom/c        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0

Code:

# menu.lst - See: grub(8), info grub, update-grub(8)
#            grub-install(8), grub-floppy(8),
#            grub-md5-crypt, /usr/share/doc/grub
#            and /usr/share/doc/grub-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.         
default                0

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout                5

# Pretty colours
color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line)  and entries protected by the
# command 'lock'
# e.g. password topsecret
#      password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title                Windows 95/98/NT/2000
# root                (hd0,0)
# makeactive
# chainloader        +1
#
# title                Linux
# root                (hd0,1)
# kernel        /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
# kopt=root=/dev/hda7 ro

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,7)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
##      alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
##      lockalternative=false
# lockalternative=false

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
##      altoptions=(recovery mode) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
##      howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
##      memtest86=false
# memtest86=true

## ## End Default Options ##

title                Debian GNU/Linux, kernel 2.6.14-1-686
root                (hd0,8)
kernel                /vmlinuz-2.6.14-1-686 root=/dev/hda8 ro
initrd                /initrd.img-2.6.14-1-686
savedefault
boot

title                Debian GNU/Linux, kernel 2.6.14-1-686 (recovery mode)
root                (hd0,8)
kernel                /vmlinuz-2.6.14-1-686 root=/dev/hda8 ro single
initrd                /initrd.img-2.6.14-1-686
savedefault
boot

### END DEBIAN AUTOMAGIC KERNELS LIST

## This is a divider, added to separate the menu items below from the Debian
## ones.
#title                Other operating systems:
#root
#
#
## This entry automatically added by the Debian installer for a non-linux OS
## on /dev/hda2
#title                Microsoft Windows 2000 Professional
#root                (hd0,1)
#savedefault
#chainloader        +1
#


bigrigdriver 01-07-2006 01:03 AM

Either you have an error in fstab, or grub is more flexible that I was aware. In your fstab, you have "/dev/hda7 none swap". In Suse, that would be "/dev/hda7 swap swap".

Also, your menu.lst is significantly different from mine.

Yours:
titleDebian GNU/Linux, kernel 2.6.14-1-686
root (hd0,8)
kernel /vmlinuz-2.6.14-1-686 root=/dev/hda8 ro
initrd /initrd.img-2.6.14-1-686

Mine:
title SUSE LINUX 9.3
kernel (hd0,8)/vmlinuz root=/dev/hda8
initrd (hd0,8)/initrd

Notice that (hd0,8) in mine is the /boot partition, followed by root=/dev/hda8, the root of the filesystem.

I don't know if "root (hd0,8)" is throwing things off or not, since the root of your installation is /dev/hda8 (hd0,7), and /boot is /dev/hda9 (hd0,8). It could be just two ways of doing the same job, in two different distros.

haertig 01-07-2006 11:24 AM

I went back and checked my before and after copies of fdisk -l output, /etc/fstab, and /boot/grub/menu.lst Luckily I use RCS to keep backup versions of all system files that I modify, and I could get at those RCS files using Knoppix. I'm really scratching my head on this one. Everything looks good to me. Obviously I don't know what I'm doing (just thought I did!)

I think the minor differences in menu.lst and fstab formats are OK. Probably just differences in the way SUSE and Debian set things up. I checked another Debian box and found it also does the fstab "none swap" thing rather than the "swap swap" like SUSE. Ditto for the "root (hd0,x)" thing in menu.lst.

Maybe it will be easier to pick out my error(s) looking at my before's and after's below (I edited out the irrelevent and coment lines from menu.lst for brevity, sorry for some duplication of data presented above):

BEFORE:
Code:

BEFORE:
################################################################################

Disk /dev/hda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hda1              1          34      273073+  b  W95 FAT32
/dev/hda2              35        799    6144862+  7  HPFS/NTFS
/dev/hda3          22940      24321    11100915    f  W95 Ext'd (LBA)
/dev/hda5          22940      24214    10241406  8e  Linux LVM
/dev/hda6          24215      24278      514048+  82  Linux swap / Solaris
/dev/hda7          24279      24317      313236  83  Linux
/dev/hda8  *      24318      24321      32098+  83  Linux

################################################################################

# /etc/fstab: static file system information.
#
# <file system> <mount point>  <type>  <options>      <dump>  <pass>
proc            /proc          proc    defaults        0      0
/dev/hda7      /              ext3    defaults,errors=remount-ro 0      1
/dev/hda8      /boot          ext3    defaults        0      2
/dev/mapper/vg0-debian_home /home          ext3    defaults        0      2
/dev/mapper/vg0-debian_opt /opt            ext3    defaults        0      2
/dev/mapper/vg0-debian_tmp /tmp            ext3    defaults        0      2
/dev/mapper/vg0-debian_usr /usr            ext3    defaults        0      2
/dev/mapper/vg0-debian_var /var            ext3    defaults        0      2
/dev/hda6      none            swap    sw              0      0
/dev/hdc        /media/cdrom0  iso9660 ro,user,noauto  0      0
/dev/hda2        /mnt/familyroom/c        ntfs        ro,noauto,umask=0222        0        0
/dev/hda1        /mnt/familyroom/d        vfat        noauto,umask=0000        0        0
//192.168.0.51/c        /mnt/bedroom/c        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0
//192.168.0.51/f        /mnt/bedroom/f        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0
//192.168.0.51/h        /mnt/bedroom/h        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0
//192.168.0.53/c        /mnt/livingroom/c        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0

################################################################################

# menu.lst

default                0
timeout                5
color cyan/blue white/blue

title                Debian GNU/Linux, kernel 2.6.14-1-686
root                (hd0,7)
kernel                /vmlinuz-2.6.14-1-686 root=/dev/hda7 ro
initrd                /initrd.img-2.6.14-1-686
savedefault
boot

title                Debian GNU/Linux, kernel 2.6.14-1-686 (recovery mode)
root                (hd0,7)
kernel                /vmlinuz-2.6.14-1-686 root=/dev/hda7 ro single
initrd                /initrd.img-2.6.14-1-686
savedefault
boot

AFTER:
Code:

AFTER:
################################################################################

Disk /dev/hda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/hda1              1          34      273073+  b  W95 FAT32
/dev/hda2              35        799    6144862+  7  HPFS/NTFS
/dev/hda3            2272      24321  177116625    f  W95 Ext'd (LBA)
/dev/hda5            2272      22939  166015678+  8e  Linux LVM
/dev/hda6          22940      24214    10241406  8e  Linux LVM
/dev/hda7          24215      24278      514048+  82  Linux swap / Solaris
/dev/hda8          24279      24317      313236  83  Linux
/dev/hda9  *      24318      24321      32098+  83  Linux

################################################################################

# /etc/fstab: static file system information.
#
# <file system> <mount point>  <type>  <options>      <dump>  <pass>
proc            /proc          proc    defaults        0      0
/dev/hda8      /              ext3    defaults,errors=remount-ro 0      1
/dev/hda9      /boot          ext3    defaults        0      2
/dev/mapper/vg0-debian_home /home          ext3    defaults        0      2
/dev/mapper/vg0-debian_opt /opt            ext3    defaults        0      2
/dev/mapper/vg0-debian_tmp /tmp            ext3    defaults        0      2
/dev/mapper/vg0-debian_usr /usr            ext3    defaults        0      2
/dev/mapper/vg0-debian_var /var            ext3    defaults        0      2
/dev/hda7      none            swap    sw              0      0
/dev/hdc        /media/cdrom0  iso9660 ro,user,noauto  0      0
/dev/hda2        /mnt/familyroom/c        ntfs        ro,noauto,umask=0222        0        0
/dev/hda1        /mnt/familyroom/d        vfat        noauto,umask=0000        0        0
//192.168.0.51/c        /mnt/bedroom/c        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0
//192.168.0.51/f        /mnt/bedroom/f        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0
//192.168.0.51/h        /mnt/bedroom/h        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0
//192.168.0.53/c        /mnt/livingroom/c        smbfs        noauto,umask=0000,credentials=/etc/cred        0        0

################################################################################

# menu.lst

default                0
timeout                5
color cyan/blue white/blue

title                Debian GNU/Linux, kernel 2.6.14-1-686
root                (hd0,8)
kernel                /vmlinuz-2.6.14-1-686 root=/dev/hda8 ro
initrd                /initrd.img-2.6.14-1-686
savedefault
boot

title                Debian GNU/Linux, kernel 2.6.14-1-686 (recovery mode)
root                (hd0,8)
kernel                /vmlinuz-2.6.14-1-686 root=/dev/hda8 ro single
initrd                /initrd.img-2.6.14-1-686
savedefault
boot


haertig 01-07-2006 01:44 PM

It looks like I may need to make a new initrd image. Some other poor soul here seems to have the same problem as me. The last post in the thread below mentions the initrd image.

http://kerneltrap.org/node/5925

Now, I'm trying to figure out how I go about using mkinitrd, since I can't boot into my Debian install (2.6.14-1-686). I can boot Knoppix (2.6.11, and it can mount /boot and / from the non-bootable Debian) but I'm not quite sure how to use mkinitrd from within Knoppix to create myself the Debian image I need. Hmmm ... any suggestions or tips welcome. I've never used mkinitrd before. I'm just now researching and learning what an initrd image is in the first place!

haertig 01-07-2006 03:48 PM

Continuing talking to myself ... (in case anyone else has similar problems and is following this).

I got it to boot, finally. Grub still can't find it's menu.lst, but I'll figure that out later. I had to rebuild my initrd image.

From Knoppix:
=============

$ su -
# mount /dev/hda8 /mnt/hda8
# mount /dev/hda9 /mnt/hda9
# mv /mnt/hda9/initrd.img-2.6.14-1-686 /mnt/hda9/BAK.initrd.img-2.6.4-1-686
# ln -s /mnt/hda8/lib/modules/2.6.14 /lib/modules/2.6.14
# ln -s /mnt/hda8/lib/modules/2.6.14-1-686 /lib/modules/2.6.14-1-686
# mkinitrd -r /dev/hda8 -d /mnt/hda8/etc/mkinitrd -o /mnt/hda9/initrd.img-2.6.14-1-686 2.6.14-1-686
# rm /lib/modules/2.6.14
# rm /lib/modules/2.6.14-1-686
# umount /dev/hda9
# umount /dec/hda8
# reboot

Then from the grub> prompt:
===========================

grub> configfile (hd0,8)/grub/menu.lst

It booted fine from there. It did complain about the LVM volume's last mount time being in the future, but I know that one. It's just a system clock setting thing. Easily fixed.

Plans:
======

From within my freshly booted Debain, I will redo the mkinitrd thing. Because if you look closely enough above you'll see I was using some stuff (the command itself) from Knoppix and files from my Knoppix-mounted Debian partitions. I'm not sure if that was all 100% correct, given possible version mismatch, but it did get me a bootable initrd image at least.

Figure out why grub can't find menu.lst. If I have to, I can just reinstall grub to /dev/hda9.

syg00 01-07-2006 04:22 PM

Quote:

Originally Posted by haertig
If I have to, I can just reinstall grub to /dev/hda9.

Yep, as simple as that - re-installing is trivial. Bootloaders are by their nature sensitive to the location of (later) stage files. Shouldn't trash your conf file, but you'd best back it up just to be safe.

haertig 01-07-2006 04:53 PM

Quote:

Originally Posted by syg00
... but you'd best back it up just to be safe.

Always! That's why I didn't panic terribly (OK, a *little* bit) when I couldn't boot Debian. I could have restored from backups, but I wanted to work and learn if I could recover given what was right in front of me.

Thanks!

haertig 01-07-2006 06:50 PM

As expected, "grub-install /dev/hda9" reinstalled grub to the /boot partition. This didn't mess with the menu.lst file (as expected).

Rebooted and my system was all back to normal. Yeah!


All times are GMT -5. The time now is 07:45 AM.