Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KEW0k-0006Qx-6f for mharc-grub-devel@gnu.org; Thu, 03 Jul 2008 17:06:38 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KEW0h-0006QA-SZ for grub-devel@gnu.org; Thu, 03 Jul 2008 17:06:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KEW0g-0006Pm-AL for grub-devel@gnu.org; Thu, 03 Jul 2008 17:06:35 -0400 Received: from [199.232.76.173] (port=42707 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KEW0g-0006Pj-5r for grub-devel@gnu.org; Thu, 03 Jul 2008 17:06:34 -0400 Received: from ti-out-0910.google.com ([209.85.142.187]:12634) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KEW0f-0000Kv-AE for grub-devel@gnu.org; Thu, 03 Jul 2008 17:06:33 -0400 Received: by ti-out-0910.google.com with SMTP id u5so24350tia.10 for ; Thu, 03 Jul 2008 14:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=uvJ1qagwvA1nPAyllz+4EziTqmMr8064n5+pR2VCh18=; b=avTtIuFsNVFAgxb78rht5BJle7xsm7GFjTv3YwhbH67/PXEPVCwyyCHrd+OjLpu7Ob brqGvAXcPUZMoTaFociUnoP1G85mYNWUq2BRi3lzx8nT5IEKJ/NmylME+nFvXWoPW3sx MjLEiwneYRh+XivrD8R7Pwrc+X/ij3EyFxSr4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=HKASWosoNeut5AsA71t1NWkO/BPMiAFK56Ed0gqZtkIaJzmTcgFcYxb4qGbthAmEqn UIXzvtiu0J3L1rzEthHh0Pk/bhkESZ7x3FLHud1VmK5e6mgntMi40uYO3fCRakK+xUyf pWq+KeeZvJhhogRIOEu7B2L/9IBUgkCFHFptU= Received: by 10.110.37.17 with SMTP id k17mr636tik.13.1215119191789; Thu, 03 Jul 2008 14:06:31 -0700 (PDT) Received: by 10.110.16.5 with HTTP; Thu, 3 Jul 2008 14:06:31 -0700 (PDT) Message-ID: Date: Fri, 4 Jul 2008 05:06:31 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: <87hcb64s5q.fsf@xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080615132552.GA17222@thorin> <20080701155427.GA6985@thorin> <877ic27skd.fsf@xs4all.nl> <1215108580.4585.11.camel@dv> <87hcb64s5q.fsf@xs4all.nl> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: [PATCH] Save/Load environment variable support X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jul 2008 21:06:36 -0000 On Fri, Jul 4, 2008 at 4:41 AM, Marco Gerards wrote: > Pavel Roskin writes: > >> On Thu, 2008-07-03 at 20:04 +0200, Marco Gerards wrote: >> >>> Great! Can you explain how it works? >> >> Very good question. It's not "discoverable". I could not find way to >> figure out that /boot/grub/grubenv is the default without looking at the >> code. > > Actually, I meant how it works technically. Hi, It first reads the first 8192 bytes into memory, then, set read_hook and do it again. Inside the hook, it records the sector location. It then uses the location list to read from disk, and compare the result. If they match, we assume it's the right one. There are some consideration about the environment file. First, it must be at least 8192 bytes long, this is used to avoid tail packing in some fs. Then, we have the signature "GeNv", followed by the length of the block. The signature doesn't need to the at the beginning, but it has to been within the first 8192 byte, and dword aligned. This is used to simplify the search function, also reduce the change of a mismatch. The environment block consists of name=value strings, terminated by an empty string. The environment block can be embedded in other files, like core.img. Then we can use grub-editenv, or save_env from grub console, to set variable which can be used to locate root at runtime, like uuid, etc. But this is the subject of another patch. -- Bean