Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 250829 - support ext4 extents with sys-boot/grub 0.97
Summary: support ext4 extents with sys-boot/grub 0.97
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-13 14:21 UTC by Sven
Modified: 2009-01-02 01:53 UTC (History)
15 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ebuild patch to include ext4 patch (grub-0.97-r8.ebuild.patch,327 bytes, patch)
2008-12-21 21:48 UTC, Holger Hoffstätte
Details | Diff
patch for booting from ext4 (grub-0.97-ext4extents.patch,8.76 KB, patch)
2008-12-21 21:48 UTC, Holger Hoffstätte
Details | Diff
Alternative ext4 patch (ext4-support,14.93 KB, text/plain)
2008-12-28 02:23 UTC, Diego Elio Pettenò (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sven 2008-12-13 14:21:52 UTC
Hi, grub 0.97 does not support ext4 extents.

I found some patches that might be worth a look. Actually, i'm going to test them, because i converted my system to ext4 some days ago and now i need a working grub.

I found one patch that adds support for extents to grub 0.97:
https://qa.mandriva.com/show_bug.cgi?id=41227
http://www.mail-archive.com/bug-grub@gnu.org/msg11458.html

Maybe you want to unclude that in a new masked ebuild?

Reproducible: Always

Steps to Reproduce:
Comment 1 Sven 2008-12-13 14:23:03 UTC
Oh, steps to reproduce:
- tune2fs -O extents /dev/sdaX
- reboot
- install new kernel
- reboot
- grub won't find the kernel image
(old files, that have been created prior to enabling extents will continue to work)
Comment 2 Sven 2008-12-13 15:45:33 UTC
I've put grub-0.97-r8 in my overlay and made it use the patch from above.

My system bootet fine from a ext4 based partition which grub-0.97-r6 wasn't able to handle.
Comment 3 Holger Hoffstätte 2008-12-21 21:48:21 UTC
Created attachment 176095 [details, diff]
ebuild patch to include ext4 patch
Comment 4 Holger Hoffstätte 2008-12-21 21:48:51 UTC
Created attachment 176097 [details, diff]
patch for booting from ext4
Comment 5 Holger Hoffstätte 2008-12-21 21:54:18 UTC
For completeness' sake I attached the necessary patches. They just saved my behind as I just accidentally converted my / (typo!) and was already looking forward to terrorbytes to restore from backup, manual booting procedures and whatnot. After remerging grub and adapting the fstab to ext4dev, It Just Worked.
Since official ext4 support is coming soon, many more people will need this..
Comment 6 Craig Andrews gentoo-dev 2008-12-25 07:56:13 UTC
ext4 just went stable in 2.6.28 release moments ago. :-)
Comment 7 Nikos Chantziaras 2008-12-26 18:33:50 UTC
The patch doesn't work for me.  Grub still refuses to boot from an ext4 partition (hangs at "Loading grub stage 2").
Comment 8 Holger Hoffstätte 2008-12-26 18:45:41 UTC
Did you reinstall the first stage? meaning: grub>root (hd0,0) & setup (hd0) or whatever your disks/partitions are.
Comment 9 Nikos Chantziaras 2008-12-26 18:54:11 UTC
No, I used:

  grub-install /dev/sda2

sda2 is ext4.  It contains both / as well as /boot.

I made an ext2 /boot partition in order to get it work.
Comment 10 Renato Caldas 2008-12-26 19:11:22 UTC
(In reply to comment #9)
> No, I used:
> 
>   grub-install /dev/sda2

You should have installed it to the MBR, that is /dev/sda. The old grub is still in the MBR...
Comment 11 Nikos Chantziaras 2008-12-26 19:42:03 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > No, I used:
> > 
> >   grub-install /dev/sda2
> 
> You should have installed it to the MBR, that is /dev/sda. The old grub is
> still in the MBR...

Hmm, even after all those years and I'm still confused by boot loaders it seems :P  I never did install to sda, only to sda2 which is marked active/bootable.  There's Windows XP in sda1 so I never touched the MBR.
Comment 12 Renato Caldas 2008-12-26 20:35:29 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > (In reply to comment #9)
> > > No, I used:
> > > 
> > >   grub-install /dev/sda2
> > 
> > You should have installed it to the MBR, that is /dev/sda. The old grub is
> > still in the MBR...
> 
> Hmm, even after all those years and I'm still confused by boot loaders it seems
> :P  I never did install to sda, only to sda2 which is marked active/bootable. 
> There's Windows XP in sda1 so I never touched the MBR.
> 

Are you sure? Do you select "windows" from grub or from the windows' bootloader? If you do select it from grub, then you must have it installed to the MBR.
Comment 13 Sven 2008-12-26 21:51:16 UTC
(In reply to comment #12)
> Are you sure? Do you select "windows" from grub or from the windows'
> bootloader? If you do select it from grub, then you must have it installed to
> the MBR.

Sorry, but you're wrong. You can install grub into the MBR or into the bootsector of any partition on the drive.

In case gurb is not installed in the MBR, the mbr had to filled with a little program (that usually comes with windows and even lilo offered sich a thing) that load the bootsector of the partition, that has been marked bootable. And that bootsector can contain grub.

This is how things work on a lot of my machines. I always do something like "grub-install /dev/sda2" and mark my sda2 as bootable.
Comment 14 Renato Caldas 2008-12-26 23:42:49 UTC
(In reply to comment #13)
> (In reply to comment #12)
> > Are you sure? Do you select "windows" from grub or from the windows'
> > bootloader? If you do select it from grub, then you must have it installed to
> > the MBR.
> 
> Sorry, but you're wrong. You can install grub into the MBR or into the
> bootsector of any partition on the drive.

Yes, I know,

> In case gurb is not installed in the MBR, the mbr had to filled with a little
> program (that usually comes with windows and even lilo offered sich a thing)
> that load the bootsector of the partition, that has been marked bootable. And
> that bootsector can contain grub.

Sorry, what I meant to say is probably different from what I actually said ;) I meant to ask if there is actually a first stage bootloader at the MBR or not.

Since grub was on the sda2 bootsector specially because windows was on sda1 (I understood that from the post), I assumed that on the MBR was the windows bootloader with its menu (I don't use windows so I don't really know...). Hence my (probably stupid) question... :)

 I didn't knew windows would cooperate with grub though
Comment 15 Sven 2008-12-26 23:50:37 UTC
(In reply to comment #14)
> Since grub was on the sda2 bootsector specially because windows was on sda1 (I
> understood that from the post), I assumed that on the MBR was the windows
> bootloader with its menu (I don't use windows so I don't really know...). Hence
> my (probably stupid) question... :)
> 
>  I didn't knew windows would cooperate with grub though

Since MS-DOS, Microsoft installs some tiny software into the MBR, which simply loads the bootsector of one of the primary partitions (the one that marked as bootable). The actual Windows bootloader (with the menu etc.) is in the bootsector of the partition onto which Windows has been installed.
Comment 16 Nikos Chantziaras 2008-12-27 11:20:03 UTC
If it works for everyone else, then it must be an error on my part. It's too painful to try it again though; non-working grub involves a rescue CD to bring the system to boot again, and it's even harder because rescue CDs right now lack recent tools for ext4.
Comment 17 Renato Caldas 2008-12-27 12:37:44 UTC
(In reply to comment #16)
> If it works for everyone else, then it must be an error on my part. It's too
> painful to try it again though; non-working grub involves a rescue CD to bring
> the system to boot again, and it's even harder because rescue CDs right now
> lack recent tools for ext4.

Ok, so much for my "expertise" (or lack of..) [shame on me]. I've only booted the system today, after having to move around all the stuff on my hd.

It also doesn't work for me, and it also hangs loading stage2.

At present I have two root partitions, one with ext3 and another with ext4. It's just a matter of finding my 64bit live cd to fix the setup back to boot from ext3. They both have the patched grub version, I just "install" from one or from the other. I'll try to find out what's wrong..

Now where is that 64 bit live cd??? :/
Comment 18 Renato Caldas 2008-12-27 12:46:28 UTC
Just checking, for those who can actually boot from an ext4 partition, have you converted from ext3 or formated as ext4 and copied over the files?

I ask this because unpatched grub should be able to read ext4 if it's still formated as ext3 (which happens if you just converted the partition).
Comment 19 Sven 2008-12-27 12:57:50 UTC
(In reply to comment #18)
> Just checking, for those who can actually boot from an ext4 partition, have you
> converted from ext3 or formated as ext4 and copied over the files?
> 
> I ask this because unpatched grub should be able to read ext4 if it's still
> formated as ext3 (which happens if you just converted the partition).

1) first my ext3 was only mounted using ext4 (rootfstype=ext4) without turning on the extents feature (unpatched grub worked fine)
2) then i turned on the extents feature (mounting as ext3 wouldn't work anymore)
and grub also continued to work, until the day i installed a new kernel. New files seem to use the extents feature while the old files remain readable for grub.
3) then i wrote my own grub-ebuild using the patch, re-emerged grub and booting worked again.
Comment 20 Nikos Chantziaras 2008-12-27 13:17:15 UTC
I copied my / with "rsync -axHA" to another ext3 partition. Then I booted from that partition and formatted my real one with "mkfs.ext4 -L GentooRoot /dev/sda2".  Then I rsynced the data back from the ext3 to the ext4 partition and installed (the patched) grub.
Comment 21 Renato Caldas 2008-12-27 13:27:31 UTC
Ok, so my procedure was very much like Nikos', except I used "cp -a".

I was able to boot the kernel from the ext4 partition if the bootloader files were on the ext3 one.

Sven, could you possibly cp grub files to another place, rm the old ones and mv them back? (This is probably dangerous!)

I suspect grub doesn't like its files to be on an ext4 partition... I've got to investigate this further.
Comment 22 Panagiotis Christopoulos (RETIRED) gentoo-dev 2008-12-27 14:04:02 UTC
I'm sorry guys, but do you actually have something to contribute here, except the original report + Holger's work on the patches? There are 21 comments, already, and most of them are chatting. Also, for the record, I hope you understand now, why there is still in hanbooks the separate /boot partition on ext2. Please, reconsider if your comment will be "helpful" for base-system@ , instead of just make them read 21 comments and 23-24 mails (some of them with "historical information"). Thank you all, and I hope I don't bother you. 
Comment 23 Nikos Chantziaras 2008-12-27 14:41:52 UTC
Yes, namely that the patch doesn't work. The people are trying to figure out if it's actually the patch that doesn't work or if they made some error with the install. Furthermore, if the patch indeed doesn't work for some people, they're trying to find out under what circumstances it works/doesn't work, which is always helpful in bug reports. Bug reports with just "doesn't work" in them are rather unhelpful.
Comment 24 Panagiotis Christopoulos (RETIRED) gentoo-dev 2008-12-27 15:12:33 UTC
It would be much appreciated if when you 're doing what you describe above, you can explain the situation more briefly, in order to let us understand what really matters. Thank you for your help, again. Let's just don't pollute more the bug, please.

Comment 25 Renato Caldas 2008-12-27 18:36:04 UTC
Ok, I'm now able to boot from ext4. I did two things, so it can be either of them (or both). Nikos can you try them please?

First I installed grub manually [grub, root (hd0,0), setup (hd0)], not with grub-install.

Second, I recompiled grub with -Os. I already had trouble with -O3 and was forced to compile with -O2. Even though it seemed to work, it was possibly malfunctioning.

I hope this helps :)
Comment 26 Roger 2008-12-28 00:47:19 UTC
Quick note, grub-install has always complained for the past year for me when booting from the gentoo install cd.  As such, easier install using grub command line.

Also, compiling grub w/ -03 (or other custom cflags) is a known killer!  (I found this with either -O3 or -march=pentium3)

echo "sys-boot/grub -custom-cflags" >> /etc/portage/package.use

Comment 27 Roger 2008-12-28 00:53:01 UTC
Another interesting note, this ebuild pulls grub version 1.96 from their ftp and the file is dated "02/03/08"!  This is almost a year old.
Comment 28 Diego Elio Pettenò (RETIRED) gentoo-dev 2008-12-28 02:23:17 UTC
Created attachment 176556 [details]
Alternative ext4 patch

I'm sincerely not sure where the patch in this bug comes from (I haven't read it too deeply to be honest), but this is a patch adapted out of http://code.google.com/p/grub4ext4/ (it's considerably bigger afaics), adapted to apply on the top of Gentoo's patches.

Prepared this in a hurry tonight after converting / without turning my brain on. The filesystem was formatted from scratch, and rsync'd over, extents enabled.
Comment 29 Roger 2008-12-28 07:08:24 UTC
FYI: Grub2 seems to have a new config file (& layout??).  As such, need to reconfigure before rebooting or you'll get a nice command grub prompt! ;-)
Comment 30 Roger 2008-12-28 07:10:49 UTC
@#$@#%@#$  Strike comment #29 from the record.  Was meant for another bug.  (D*rn bugzilla won't let me delete my own junk.)
Comment 31 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2009-01-02 01:53:48 UTC
patchset 1.9 now exists (0.97-r9) and contains flameeyes' patch.

I tested the patch on my laptop, with /boot on: ext2, ext3, ext4
# mkfs.ext4 /dev/sda1 -O large_file,dir_index,filetype,flex_bg,extent,uninit_bg,resize_inode,sparse_super -L /boot