Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Grub2 + Raid1 + LVM
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Tha-Fox
n00b
n00b


Joined: 20 Dec 2011
Posts: 7

PostPosted: Wed Dec 21, 2011 8:10 pm    Post subject: Grub2 + Raid1 + LVM Reply with quote

I'm doing my first installation for the third time, so please bear with me. I'm trying to get going with the combination of Grub2, RAID1 and LVM.

I assume I need Grub2 since I want to use RAID with newer superblock 1.x. Right now my disk layout looks like this:

sda1 and sdb1 are in raid1 and form md1.
sda2 and sdb2 are swap.
sda3 and sdb3 are in raid1 and form md3.
sda4 and sdb4 are in raid 1 and form md4.

md1 is a /boot partition. I understood it's better to leave it outside the lvm because recovering from error is easier.
md3 and md4 are in the same volume group. md3 is a logical volume for root and md4 is a logical volume for home.

When I tried installing for the first time, I was able to install Grub2 but couldn't create initramfs which I assume is needed because root is inside lvm. Does it make any difference that I have /boot outside lvm?

For the second time I chose bigger disks (more space to make mistakes). And now for some reason I can't install Grub2. I do everything the same way I did in the first time but the result differs. I've followed the wiki page and this is what I get.

Code:

emerge -av sys-boot/grub:2

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N    *] sys-boot/grub-9999  USE="nls -custom-cflags -debug -device-mapper -efiemu -sdl -static -truetype" GRUB_PLATFORMS="-coreboot -efi-32 -efi-64 -emu -ieee1275 -multiboot -pc -qemu -qemu-mips -yeeloong" 0 kB

Total: 1 package (1 new), Size of downloads: 0 kB

Would you like to merge these packages? [Yes/No] yes

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) sys-boot/grub-9999
>>> Unpacking source...
 * bzr branch start -->
 *    repository: http://bzr.savannah.gnu.org/r/grub/trunk/grub/ => /usr/portage/distfiles/bzr-src/grub
bzr: ERROR: exceptions.TypeError: readline() takes exactly 1 argument (2 given)

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/bzrlib/commands.py", line 912, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/bzrlib/commands.py", line 1112, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.7/site-packages/bzrlib/commands.py", line 690, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.7/site-packages/bzrlib/commands.py", line 705, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/bzrlib/cleanup.py", line 135, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/bzrlib/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/bzrlib/builtins.py", line 1209, in run
    from_location)
  File "/usr/lib/python2.7/site-packages/bzrlib/bzrdir.py", line 1032, in open_tree_or_branch
    bzrdir = klass.open(location)
  File "/usr/lib/python2.7/site-packages/bzrlib/bzrdir.py", line 911, in open
    return BzrDir.open_from_transport(t, _unsupported=_unsupported)
  File "/usr/lib/python2.7/site-packages/bzrlib/bzrdir.py", line 941, in open_from_transport
    redirected)
  File "/usr/lib/python2.7/site-packages/bzrlib/lazy_import.py", line 125, in __call__
    return obj(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/bzrlib/transport/__init__.py", line 1657, in do_catching_redirections
    return action(transport)
  File "/usr/lib/python2.7/site-packages/bzrlib/bzrdir.py", line 928, in find_format
    transport, _server_formats=_server_formats)
  File "/usr/lib/python2.7/site-packages/bzrlib/bzrdir.py", line 1949, in find_format
    return format.probe_transport(transport)
  File "/usr/lib/python2.7/site-packages/bzrlib/bzrdir.py", line 3292, in probe_transport
    server_version = medium.protocol_version()
  File "/usr/lib/python2.7/site-packages/bzrlib/smart/medium.py", line 632, in protocol_version
    client_protocol.query_version()
  File "/usr/lib/python2.7/site-packages/bzrlib/smart/protocol.py", line 791, in query_version
    self.call('hello')
  File "/usr/lib/python2.7/site-packages/bzrlib/smart/protocol.py", line 631, in call
    self._request.finished_writing()
  File "/usr/lib/python2.7/site-packages/bzrlib/smart/medium.py", line 439, in finished_writing
    self._finished_writing()
  File "/usr/lib/python2.7/site-packages/bzrlib/transport/http/__init__.py", line 646, in _finished_writing
    data = self._medium.send_http_smart_request(self._buffer)
  File "/usr/lib/python2.7/site-packages/bzrlib/transport/http/__init__.py", line 615, in send_http_smart_request
    code, body_filelike = t._post(bytes)
  File "/usr/lib/python2.7/site-packages/bzrlib/transport/http/_urllib.py", line 139, in _post
    accepted_errors=[200, 403]))
  File "/usr/lib/python2.7/site-packages/bzrlib/transport/http/_urllib.py", line 79, in _perform
    response = self._opener.open(request)
  File "/usr/lib/python2.7/urllib2.py", line 394, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 412, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 372, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/site-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 709, in http_open
    return self.do_open(HTTPConnection, request)
  File "/usr/lib/python2.7/site-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 649, in do_open
    response = connection.getresponse()
  File "/usr/lib/python2.7/site-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 263, in getresponse
    self._response = httplib.HTTPConnection.getresponse(self)
  File "/usr/lib/python2.7/httplib.py", line 1027, in getresponse
    response.begin()
  File "/usr/lib/python2.7/site-packages/bzrlib/transport/http/_urllib2_wrappers.py", line 184, in begin
    httplib.HTTPResponse.begin(self)
  File "/usr/lib/python2.7/httplib.py", line 439, in begin
    self.msg = HTTPMessage(self.fp, 0)
  File "/usr/lib/python2.7/mimetools.py", line 25, in __init__
    rfc822.Message.__init__(self, fp, seekable)
  File "/usr/lib/python2.7/rfc822.py", line 108, in __init__
    self.readheaders()
  File "/usr/lib/python2.7/httplib.py", line 280, in readheaders
    line = self.fp.readline(_MAXLINE + 1)
TypeError: readline() takes exactly 1 argument (2 given)

bzr 2.2.2 on python 2.7.2 (Linux-3.0.6-gentoo-i686-Intel-R-_Celeron-R-_CPU_2.80GHz-with-gentoo-2.0.3)
arguments: ['/usr/bin/bzr', 'branch', '--no-tree', 'http://bzr.savannah.gnu.org/r/grub/trunk/grub/', '/usr/portage/distfiles/bzr-src/grub']
encoding: 'ANSI_X3.4-1968', fsenc: 'ANSI_X3.4-1968', lang: None
plugins:
  bash_completion      /usr/lib/python2.7/site-packages/bzrlib/plugins/bash_completion [2.2.2]
  launchpad            /usr/lib/python2.7/site-packages/bzrlib/plugins/launchpad [2.2.2]
  netrc_credential_store /usr/lib/python2.7/site-packages/bzrlib/plugins/netrc_credential_store [2.2.2]
  news_merge           /usr/lib/python2.7/site-packages/bzrlib/plugins/news_merge [2.2.2]

*** Bazaar has encountered an internal error.  This probably indicates a
    bug in Bazaar.  You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    including this traceback and a description of the problem.
 * ERROR: sys-boot/grub-9999 failed (unpack phase):
 *   bzr.eclass: can't branch from http://bzr.savannah.gnu.org/r/grub/trunk/grub/
 *
 * Call stack:
 *     ebuild.sh, line   56:  Called src_unpack
 *   environment, line 3463:  Called bzr_src_unpack
 *   environment, line  790:  Called bzr_fetch
 *   environment, line  757:  Called bzr_initial_fetch 'http://bzr.savannah.gnu.org/r/grub/trunk/grub/' '/usr/portage/distfiles/bzr-src/grub'
 *   environment, line  782:  Called die
 * The specific snippet of code:
 *       ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" || die "${EBZR}: can't branch from ${repo_uri}"
 *
 * If you need support, post the output of 'emerge --info =sys-boot/grub-9999',
 * the complete build log and the output of 'emerge -pqv =sys-boot/grub-9999'.
 * The complete build log is located at '/var/tmp/portage/sys-boot/grub-9999/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-boot/grub-9999/temp/environment'.
 * S: '/var/tmp/portage/sys-boot/grub-9999/work/grub-9999'

>>> Failed to emerge sys-boot/grub-9999, Log file:

>>>  '/var/tmp/portage/sys-boot/grub-9999/temp/build.log'

 * Messages for package sys-boot/grub-9999:

 * ERROR: sys-boot/grub-9999 failed (unpack phase):
 *   bzr.eclass: can't branch from http://bzr.savannah.gnu.org/r/grub/trunk/grub/
 *
 * Call stack:
 *     ebuild.sh, line   56:  Called src_unpack
 *   environment, line 3463:  Called bzr_src_unpack
 *   environment, line  790:  Called bzr_fetch
 *   environment, line  757:  Called bzr_initial_fetch 'http://bzr.savannah.gnu.org/r/grub/trunk/grub/' '/usr/portage/distfiles/bzr-src/grub'
 *   environment, line  782:  Called die
 * The specific snippet of code:
 *       ${EBZR_FETCH_CMD} ${EBZR_OPTIONS} "${repo_uri}" "${branch_dir}" || die "${EBZR}: can't branch from ${repo_uri}"
 *
 * If you need support, post the output of 'emerge --info =sys-boot/grub-9999',
 * the complete build log and the output of 'emerge -pqv =sys-boot/grub-9999'.
 * The complete build log is located at '/var/tmp/portage/sys-boot/grub-9999/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-boot/grub-9999/temp/environment'.
 * S: '/var/tmp/portage/sys-boot/grub-9999/work/grub-9999'


I asked from the IRC and got the impression that Grub2 shouldn't depend on grub-9999. But when I tried to install Grub2 without adding grub-9999 to /etc/portage/package.accept_keywords, it gave me this.

Code:

The following keyword changes are necessary to proceed:
#required by sys-boot/grub:2 (argument)
>=sys-boot/grub-9999 **


So how could I install Grub2? I found some older threads that told to install rc-version of Grub2, something like grub1.99-rc2. Should I try that?

Edit: Forgot to mention that I'm using self-compiled kernel and I'd like to avoid using genkernel even though it creates initramfs automatically. I need only a couple of modules and drivers so I think it's wiser to use custom kernel.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43546
Location: 56N 3W

PostPosted: Wed Dec 21, 2011 8:52 pm    Post subject: Reply with quote

Tha-Fox,

Welcome to Gentoo.

If you want boot on raid1 with rais superblock version >0.90 you need lilo or grub2. The painless way is to use grub1 and make /boot raid1 with superblock version 0.90
a Few words on grun versioning.
Grub1 is any version <=1 ... thats all the 0.97 version is portage.
Grub2 is any version <=2 ... thats grub-1.99-r2 just now and is all you should need
grub-9999 is the live source code, as it is when you attempt to build it. It may not build and if it builds it may not work.

Grub2 is not supported in Gentoo yet, so you get to keep all the pieces if/when it breaks. However, it must be mostly harmless as the grub-1.99-r2.ebuild contains
Code:
        # Masked until documentation guys consolidate the guide and approve
        # it for usage.
        #KEYWORDS="~amd64 ~mips ~x86"


You will need to keyword it with something like
Code:
<=sys-boot/grub-2 **
which will get you
grub-1.99-r2 but not grub-9999
You may need to unmask it too.

I have several systems with /boot on a version 0.90 raid1 and everything else in lvm.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43546
Location: 56N 3W

PostPosted: Wed Dec 21, 2011 8:54 pm    Post subject: Reply with quote

Moved from Installing Gentoo to Unsupported Software.

That doesn't mean you get no support. Its a warning to others that the topic addresses something that Gentoo does not offcially support.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
tclover
Guru
Guru


Joined: 10 Apr 2011
Posts: 516

PostPosted: Wed Dec 21, 2011 11:09 pm    Post subject: Reply with quote

There is an excellent article on the official wiki on GRUB2! You may consult it for GRUB2 specific installation instructions but also on RAID and LVM combination.
_________________
home/:mkinitramfs-ll/:supervision/:e-gtk-theme/:overlay/
Back to top
View user's profile Send private message
Tha-Fox
n00b
n00b


Joined: 20 Dec 2011
Posts: 7

PostPosted: Thu Dec 22, 2011 1:04 pm    Post subject: Reply with quote

Thank you both for your anwers! Now I got the Grub2 installed and I'm trying to create initramfs next. Any advice for that?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43546
Location: 56N 3W

PostPosted: Thu Dec 22, 2011 2:17 pm    Post subject: Reply with quote

Tha-Fox,

Make your kernel so that it does not need any modules loaded to get you booted.
That way your initrd is not tied to the kernel and you do not need to update it every kernel update. I just contains the user space tools needed to decrypt your filestem, deal with raid and LVM. Read this wiki page in particular, the initrd part. It will be asy enough to adapt to your needs.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Tha-Fox
n00b
n00b


Joined: 20 Dec 2011
Posts: 7

PostPosted: Thu Dec 22, 2011 2:54 pm    Post subject: Reply with quote

Now I think I have my initramfs set up. I created it using the wiki page you recommended and then adding the rescue shell: http://en.gentoo-wiki.com/wiki/Initramfs#Rescue_Shell

The last thing preventing me from booting the new system up is Grub2. I'm quite sure it doesn't detect anything since my /boot/grub2/grub.cfg looks like this:

Code:


#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
true
}

if sleep --interruptible 0 ; then
  set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
Back to top
View user's profile Send private message
tclover
Guru
Guru


Joined: 10 Apr 2011
Posts: 516

PostPosted: Thu Dec 22, 2011 5:52 pm    Post subject: Reply with quote

I'd diverge from Neddy because you do not need any initramfs to boot RAID and/or LVM2 volumes. Did you followed my advice to read https://wiki.gentoo.org/wiki/GRUB2 ? Everything you need is there.
_________________
home/:mkinitramfs-ll/:supervision/:e-gtk-theme/:overlay/
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43546
Location: 56N 3W

PostPosted: Thu Dec 22, 2011 7:03 pm    Post subject: Reply with quote

tclover,

There you go. I'm last out of the past again.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2971
Location: Germany

PostPosted: Fri Dec 23, 2011 12:31 am    Post subject: Reply with quote

tclover wrote:
I'd diverge from Neddy because you do not need any initramfs to boot RAID and/or LVM2 volumes.


Even if the bootloader (grub) supports reading kernel images from RAID / LVM nowadays (dunno if it does), the kernel still needs to be able to mount them, and that's where the initramfs comes in. With RAID alone you could get by with RAID autodetect (which is considered a deprecated feature and may be removed in the future, and it only works for old raid metadata format 0.90), with LVM no chance unless you keep the root partition separate and put only usr, var, home and others on LVM.

In general, however, if root on raid and/or lvm and/or encrypted, then initramfs is a must have.
Back to top
View user's profile Send private message
tclover
Guru
Guru


Joined: 10 Apr 2011
Posts: 516

PostPosted: Fri Dec 23, 2011 2:56 am    Post subject: Reply with quote

Right, frostschultz. I've just slipped from booting and loading kernel/initrd, indeed, an initramfs is mandatory to mount rootfs.
_________________
home/:mkinitramfs-ll/:supervision/:e-gtk-theme/:overlay/
Back to top
View user's profile Send private message
Tha-Fox
n00b
n00b


Joined: 20 Dec 2011
Posts: 7

PostPosted: Fri Dec 23, 2011 6:58 am    Post subject: Reply with quote

I noticed that I should mount /boot when I'm in chrooted environment. While installing I followed this guide and it uses Grub1. So I exited chroot and unmounted /boot. Then back to chroot and mounted /boot again. But still no menuentrys.

Edit: This is my current situation. I think I have everything done but Grub2 can't see my md1 which contains /boot.

Code:

/etc/mdadm.conf

ARRAY /dev/md1 metadata=1.2 name=livecd:1 UUID=15b1f5e9:ec8cb1e3:e9bd4525:f660d1be
ARRAY /dev/md3 metadata=1.2 name=livecd:3 UUID=f5cf9cdb:d294a133:7f3a4e20:3b006b30
ARRAY /dev/md4 metadata=1.2 name=livecd:4 UUID=f446440d:e09184f0:f289a453:dec83bea


Code:

/etc/fstab

/dev/md1                /boot           ext4            noatime         1 2
/dev/juurivg/juurilv    /               ext3            noatime         0 1
/dev/sda2               none            swap            sw              0 0
/dev/sdb2               none            swap            sw              0 0
/dev/kotivg/kotilv      /home           ext4            noatime         0 3


Code:

vgs

 VG      #PV #LV #SN Attr   VSize   VFree
  juurivg   1   1   0 wz--n-  10.00g    0
  kotivg    1   1   0 wz--n- 137.95g    0


Code:

lvs

 LV      VG      Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  juurilv juurivg -wi-ao  10.00g
  kotilv  kotivg  -wi-ao 137.95g


I can't get Grub2 to find my devices so I created a custom config.

Code:

/etc/grub.d/40_custom

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Gentoo, Linux-ydin 3.0.6' {
        insmod mdraid1x
        insmod raid
        insmod lvm
        insmod ext4
        set root='(md1)'
        linux   /boot/kernel root=/dev/juurivg/juurilv
        initrd  /boot/initramfs
}


The errors it gives me:

Code:

Error: no such disk

You need to load the kernel first.
Back to top
View user's profile Send private message
tclover
Guru
Guru


Joined: 10 Apr 2011
Posts: 516

PostPosted: Fri Dec 23, 2011 12:38 pm    Post subject: Reply with quote

Sorry, for the previous confused advice, however, if you followed the link to the official wiki, there is a link to an example for RAID-1 set up for `/boot' and root `/'.

The issue that seems to plague GRUB2 which prevent grub2-mkconfig to not detect your raid arrays is: grub2-mkdevicemap fails to rightly list your raid arrays.

Just checkout the content of `/boot/grub2/device.map' and post the content of the file. You should get a list `(hdN) /dev/disk/by-id/ata-<brand_model_sn>' and `(hdN) /dev/disk/by-id/md-uuid-<uuid>'. The raid array list should be wrong as the `(hdN)' should be `(mdN)' instead and the <uuid> value should be wrong as well.

You could do something like the following to correct that file and delete the wrong raid array list. [that piece of code come from the reference of the offcial wiki.]
Code:
for i in 1 3 4; do
UUID=$(mdadm -D /dev/md$i | grep UUID | awk '{ print $3 }')
echo -n "(md$i)    /dev/disk/by-id/md-uuid-$UUID"  >> /boot/grub2/device.map
unset UUID; done

And then re-generate GRUB2 configuration file. Checkout out the generated cfg file to see if everything is fine at this point.

It seems you should again correct the <uuid> value of the grub.cfg file because it should be wrong again. sigh. You should checkout the `search ...' line for that and correct the uuid with what you have in `/boot/grub2/device.map' and in the right format with that: some in the line of `12345678-1234-1234-1234-123456789abc' instead of the `12345678:12345678:12345678:12345678' format.

I am the one who started the GRUB2 article in te official Wiki but I do not use any RAID set up and I did not pay much attention to RAID until I started writing it. Now I'm going to take a close look to it to finish the article. And with that I will add RAID support to my mkinitramfs-ll project--which is almost done, I just had to decide something before commiting the changes to the github repository.

So report if what I've written above, mainly extracted from that reference, is correct. And then, I could finish to edit the RAID section of the official Wiki.

NOTE: And yes, you need an initramfs to mount rootfs. You can make a simple one with mdadm and lvm.static binaries yourself if you want.

EDIT: Don't forget to post a handful part of your grub.cfg file to be able to checkout the `search' commands.

EDIT2: Anyway, you can avoid wasting your time with correcting the 'root' argument UUID and use a custom menu entry with something like `set root=(md1)'. You could make use of a custom menu entry file `/etc/grub.d/15_linux' for example. All that is explained in the article.
_________________
home/:mkinitramfs-ll/:supervision/:e-gtk-theme/:overlay/


Last edited by tclover on Fri Dec 23, 2011 3:13 pm; edited 3 times in total
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2843

PostPosted: Fri Dec 23, 2011 12:48 pm    Post subject: Reply with quote

I would suggest stop using grub and switch to extlinux (syslinux).

syslinux support raid1 metadata-1.0, create /boot with metadata 1.0 and install extlinux. Assuming that you have ext2/3/4 filesystem mounted on /mnt/gentoo/boot

Code:
mkdir /mnt/gentoo/boot/extlinux
cp -v /usr/share/syslinux/{menu.c32,memdisk,chain.c32} /mnt/gentoo/boot/extlinux
extlinux --install --raid /mnt/gentoo/boot/extlinux
dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/mbr.bin of=/dev/sda
dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/mbr.bin of=/dev/sdb


and create /mnt/gentoo/boot/extlinux/extlinux.conf.

The only reason I suggest you syslinux is that I found grub(2) way too annoying to setup for such simple task like boot from damn raid1 array. Syslinux is as simple as lilo and as powerful as grub2.

example extlinux.conf
Code:
TIMEOUT 30
UI menu.c32

MENU TITLE Boot Menu
MENU COLOR title   1;37;40
MENU COLOR border   30;40
MENU COLOR unsel   37;40

LABEL kernel1_bzImage-3.1.4
   MENU LABEL Gentoo Linux bzImage-3.1.4
   LINUX /bzImage-3.1.4
   INITRD /initramfs.cpio.gz
   APPEND rootfstype=ext4 softraid root=LABEL=rootfs


the initramfs.cpio.gz is better-initramfs image.
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
tclover
Guru
Guru


Joined: 10 Apr 2011
Posts: 516

PostPosted: Fri Dec 23, 2011 1:35 pm    Post subject: Reply with quote

You're assuming he's trying to boot from BIOS/MBR SlashBeast! I have no idea what he's trying to do in that regard BIOS/MBR or BIOS/GPT because he said nothing about it... or I did not take a close look of his issue? maybe.
_________________
home/:mkinitramfs-ll/:supervision/:e-gtk-theme/:overlay/
Back to top
View user's profile Send private message
SlashBeast
Moderator
Moderator


Joined: 23 May 2006
Posts: 2843

PostPosted: Fri Dec 23, 2011 2:02 pm    Post subject: Reply with quote

well, syslinux support gpt as well so it does not matter, just use gptmbr.bin instead of mbr.bin.
_________________
BitBucket -- better-initramfs
Back to top
View user's profile Send private message
Tha-Fox
n00b
n00b


Joined: 20 Dec 2011
Posts: 7

PostPosted: Tue Dec 27, 2011 7:04 am    Post subject: Reply with quote

SlashBeast: I'm in a bit of hurry with this server because I need to back up some important files. After that I'll grab another computer and start tinkering with EFI, GPT and maybe syslinux as well.

tclover: I bet this is a dumb question, but do you mean with `search' line in:
Code:
 You should checkout the `search ...' line for that and correct the uuid with what you have in `/boot/grub2/device.map' and in the right format with that: some in the line of `12345678-1234-1234-1234-123456789abc' instead of the `12345678:12345678:12345678:12345678' format.
Does it just mean I should replace colons with dashes?

This is my current situation.

Code:

/boot/grub2/device.map

(md125)    /dev/disk/by-id/md-uuid-f5cf9cdb:d294a133:7f3a4e20:3b006b30
(md126)    /dev/disk/by-id/md-uuid-15b1f5e9:ec8cb1e3:e9bd4525:f660d1be
(md127)    /dev/disk/by-id/md-uuid-f446440d:e09184f0:f289a453:dec83bea


The names of the md devices have changed for some unknown reason. md125 is originally md3 aka LV for my / partition. md126 aka md1 is the raid1 array for /boot and md127 aka md4 is the LV for my /home.
Back to top
View user's profile Send private message
tclover
Guru
Guru


Joined: 10 Apr 2011
Posts: 516

PostPosted: Thu Dec 29, 2011 2:06 am    Post subject: Reply with quote

Tha-Fox wrote:
Does it just mean I should replace colons with dashes?

This is my current situation.

Code:

/boot/grub2/device.map

(md125)    /dev/disk/by-id/md-uuid-f5cf9cdb:d294a133:7f3a4e20:3b006b30
(md126)    /dev/disk/by-id/md-uuid-15b1f5e9:ec8cb1e3:e9bd4525:f660d1be
(md127)    /dev/disk/by-id/md-uuid-f446440d:e09184f0:f289a453:dec83bea

Of course not: you have to respect 8,4,4,4,12 characters between dashes and not simply colon by dashes.

So you should have something like `search --no-floppy --fs-uuid --set 15b1f5e9-ec8c-b1e3-e9bd-4525f660d1be' in your grub.cfg file or something similar.

Anyway, you can set up your custom menu entry like:
Code:
...
insmod raid
insmod raid09
search  --no-floppy --fs-uuid --set=root 15b1f5e9-ec8c-b1e3-e9bd-4525f660d1be
kernel /boot/vmlinuz
initrd /boot/initrd.cpio.xz
...

or even replace simply the search command line by:
Code:
set root=(md126)

That array number is weird... You could post your grub.cfg if need be.

EDIT: And you should correct the `(md<n>)' uuid in `/boot/grub2/device.map to have 8,4,4,4,12 characters between dashes accordingly as well as the above example! Otherwise grub might not found the device. Anyway, report what works for you.
_________________
home/:mkinitramfs-ll/:supervision/:e-gtk-theme/:overlay/
Back to top
View user's profile Send private message
Tha-Fox
n00b
n00b


Joined: 20 Dec 2011
Posts: 7

PostPosted: Thu Dec 29, 2011 8:58 pm    Post subject: Reply with quote

Maybe I get this working during the next year :D Grub2 is still not detetcting anything for me. My custom entry gives me Grub menu, but fails to boot. Here are some details.

Code:

/boot/grub2/grub.cfg

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  insmod vbe
  insmod vga
  insmod video_bochs
  insmod video_cirrus
}

if sleep --interruptible 0 ; then
  set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Gentoo, Linux-ydin 3.0.6' {
        insmod raid
        insmod raid09
        insmod mdraid
        insmod mdraid1
        insmod mdraid1x
        insmod dm-mod
        insmod lvm
        insmod ext4
        search  --no-floppy --fs-uuid --set=root 15b1f5e9-ec8c-b1e3-e9bd-4525f660d1be
        linux   /boot/kernel
        initrd  /boot/initramfs.cpio.gz
}

### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###



Code:

/boot/grub2/device.map

(md1)    /dev/disk/by-id/md-uuid-f5cf9cdb-d294-a133-7f3a-4e203b006b30
(md3)    /dev/disk/by-id/md-uuid-15b1f5e9-ec8c-b1e3-e9bd-4525f660d1be
(md4)    /dev/disk/by-id/md-uuid-f446440d-e091-84f0-f289-a453dec83bea


Code:

init

#!/bin/sh

mount -t proc none /proc
CMDLINE=`cat /proc/cmdline`

mount -t sysfs none /sys

#wait a little to avoid trailing kernel output
sleep 3

#raid
/bin/mdadm -A /dev/md1 /dev/sda1 /dev/sdb1
/bin/mdadm -A /dev/md3 /dev/sda3 /dev/sdb3
/bin/mdadm -A /dev/md4 /dev/sda4 /dev/sdb4
/bin/busybox mdev -s

#If you have a msg, show it:
#cat /etc/msg

#lvm
lvm vgscan --mknodes
lvm lvchange -aly juurivg/juurilv
lvm lvchange -aly kotivg/kotilv

#root filesystem
mount -r -t ext4 /dev/mapper/juurivg-juurilv /newroot

#unmount pseudo FS
umount /sys
umount /proc

#root switch
exec /bin/busybox switch_root /newroot /sbin/init ${CMDLINE}



With these when I try to boot, I get Grub menu and it shows my kernel. When I try to boot it, it gives me following errors:

Code:

error: file not found
error: file not found
error: file not found
error: file not found
error: file not found
error: no such device f5cf9cdb-d294-a133-7f3a-4e203b006b30
error: file not found
error: you need to load the kernel firs


Then I press "c" and drop to Grub shell. If I try "ls" it shows me all partitions, md-devices and lvs. For some reason md-devices are md/1, md/3 and md/4. I can try bootiong my kernel with following commands.

Code:

set root=(md/1)
linux /kernel
initrd /initramfs.cpio.gz
boot


I may have given "insmod raid" also but I'm not certain. The boot end up with following error:

Code:

mounting /dev/mapper/juurivg-juurilv on /newroot failed: no such file or directory


I have /newroot in my initram environment. What could be the problem?
Back to top
View user's profile Send private message
tclover
Guru
Guru


Joined: 10 Apr 2011
Posts: 516

PostPosted: Fri Dec 30, 2011 3:15 am    Post subject: Reply with quote

Good, at least grub2 can boot from your RAID/LVM. Now, could you post the output of `grub2-mkdevicemap'? you could backup your old file with `mv /boot/grub2/device.map{,.bak}'.

Now for your root LV: you cannot get your device files without mounting `/dev', so you need something like
Code:
mount -t tmpfs tmpfs /dev
busybox --install -s
mdev -s
echo /sbin/mdev > /proc/sys/kernel/hotplug

just after your `mount -t sysfs sysfs /sys' line and you should get `/dev' populated with devices nodes.

You could get an initramfs package to take care of mounting rootfs. If you need one, just follow the link on my signature or use something in portage like dracut or even genkernel.

EDIT: the file not found error is likely caused by the `insmod <module>' with inexistant <module> like mdraid etc. There are only mdraid09 and mdraid1x.
_________________
home/:mkinitramfs-ll/:supervision/:e-gtk-theme/:overlay/
Back to top
View user's profile Send private message
Tha-Fox
n00b
n00b


Joined: 20 Dec 2011
Posts: 7

PostPosted: Mon Jan 02, 2012 1:25 pm    Post subject: Reply with quote

I ran grub2-mkdevicemap.

Code:

(fd0)   /dev/fd0
(hd0)   /dev/disk/by-id/ata-ST3160023AS_5MT25SR5
(hd1)   /dev/disk/by-id/ata-ST3160023AS_5MT2B999


I tried manually loading modules from Grub command line and setting root to (md1) but got still the same error even after adding your lines to my initramfs. Maybe I'll try next those initrams you mentioned in your post.
Back to top
View user's profile Send private message
tclover
Guru
Guru


Joined: 10 Apr 2011
Posts: 516

PostPosted: Mon Jan 02, 2012 3:45 pm    Post subject: Reply with quote

I don't have the time to examine your init script, but that thing is ore than dubious with the previous missing lines to mount /dev... and passing your kernel cmdline to /sbin/init at the end! You sure will get kernel panics.
_________________
home/:mkinitramfs-ll/:supervision/:e-gtk-theme/:overlay/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum