Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1FhVLu-0005Av-Bt for mharc-grub-devel@gnu.org; Sat, 20 May 2006 13:34:58 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FhVLs-00059I-DX for grub-devel@gnu.org; Sat, 20 May 2006 13:34:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FhVLr-00058L-A6 for grub-devel@gnu.org; Sat, 20 May 2006 13:34:55 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FhVLr-00058B-22 for grub-devel@gnu.org; Sat, 20 May 2006 13:34:55 -0400 Received: from [85.160.2.143] (helo=host0.dyn.jankratochvil.net) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FhVPP-0007Pj-Od for grub-devel@gnu.org; Sat, 20 May 2006 13:38:37 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.13.6/8.13.4) with ESMTP id k4KHYlKU003522; Sat, 20 May 2006 19:34:47 +0200 Received: (from lace@localhost) by host0.dyn.jankratochvil.net (8.13.6/8.13.6/Submit) id k4KHYjpO003516; Sat, 20 May 2006 19:34:45 +0200 Date: Sat, 20 May 2006 19:34:45 +0200 From: Jan Kratochvil To: grub-devel@gnu.org, johninsd@san.rr.com Message-ID: <20060520173445.GA2112@host0.dyn.jankratochvil.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="5vNYLRcllDrimb99" Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Cc: Jan Kolar Subject: [patch] Universal RAID1 safe BIOS booting 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: Sat, 20 May 2006 17:34:56 -0000 --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, there is AFAIK no solution for safe booting from RAID1 devices such as in the typical case of two harddrives in a PC (Primary Master+Primary Slave or Primary Master+Secondary Master). Created a BIOS wrapper to automatically detect disk failure and swap 0x80<->0x81 reading so it applies to stage1/stage2/kernel/initrd/whatever loading. It was tested using QEMU patches simulating various disk failures. http://cvs.jankratochvil.net/viewcvs/biosautoraid/biosautoraid.tar.gz?tarball=1 http://cvs.jankratochvil.net/viewcvs/biosautoraid/README?rev=HEAD WHY: The loading of stage2 can be fixed only for 0x80 or 0x81 but there is never a foolproof choice. Sometimes the primary drive 0x80 dies while becoming unreadable, in some other cases it dies while disappearing from POST so 0x81 becomes 0x80. If you set 0x80 or 0x81 there are always some disk crash cases where the booting will fail. Fallback to the second drive during failure of the kernel load is AFAIK not possible with LILO and it is even a bit complicated to configure with GRUB. REQUIREMENTS: This solution is fully independent of the used loader. Either LILO or GRUB can be used, both have been tested. Just the sectors required for booting need to be exactly at the same sectors of both disks. This is satisfied with standard Linux-RAID devices /dev/md* if both disks are partitioned the same way. DISADVANTAGE: Currently it does not support LBA32 handling so you must install the boot stuff under the first 8GB. I have some draft LBA32 support done but it never got debugged/finished as there are no business needs for it. The whole swapping wrapper no longer fits into 1 sector so it needs its own stage2 loader (also with automatic drives swapping) etc. TESTING/DEBUGGING: Used the attached "block-limit.diff" QEMU patch, it is user unfriendly to use. SPONSORSHIP: Development paid by the courtesy of JK Labs s.r.o. Some integration into GRUB/LILO would be wised? Do you find it useful? Regards, Lace --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="block-limit.diff" Index: block-qcow.c =================================================================== RCS file: /sources/qemu/qemu/block-qcow.c,v retrieving revision 1.6 diff -u -p -r1.6 block-qcow.c --- block-qcow.c 18 Dec 2005 18:28:15 -0000 1.6 +++ block-qcow.c 27 Feb 2006 21:07:09 -0000 @@ -458,6 +458,15 @@ static int qcow_read(BlockDriverState *b int ret, index_in_cluster, n; uint64_t cluster_offset; + static BlockDriverState *bs_first=NULL; + if (!bs_first) + bs_first=bs; + if (bs==bs_first && sector_num) { +fprintf(stderr,"%p:%lld+%d: %s\n",bs,(long long)sector_num,nb_sectors,bs->filename); +puts("fail"); + return -1; + } + while (nb_sectors > 0) { cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0); index_in_cluster = sector_num & (s->cluster_sectors - 1); Index: block.c =================================================================== RCS file: /sources/qemu/qemu/block.c,v retrieving revision 1.25 diff -u -p -r1.25 block.c --- block.c 18 Dec 2005 18:28:15 -0000 1.25 +++ block.c 27 Feb 2006 21:07:10 -0000 @@ -709,6 +709,25 @@ static int raw_read(BlockDriverState *bs BDRVRawState *s = bs->opaque; int ret; + static BlockDriverState *bs_first=NULL; + if (!bs_first) + bs_first=bs; + if (!strcmp(bs->filename,"/tmp/sda-head.bin") && bs==bs_first && sector_num) { +fprintf(stderr,"%p:%lld+%d: %s\n",bs,(long long)sector_num,nb_sectors,bs->filename); +puts("fail"); + return -1; + } +#if 0 + fprintf(stderr,"%p:%lld+%d: %s\n",bs,(long long)sector_num,nb_sectors,bs->filename); + if (!strcmp(bs->filename,"/tmp/sda-head.bin") && bs==bs_first && ((sector_num/63)&1)) { +puts("fail"); + return -1; + } + if (!strcmp(bs->filename,"/tmp/sda-head.bin") && bs!=bs_first && !((sector_num/63)&1)) { +puts("fail"); + return -1; + } +#endif lseek(s->fd, sector_num * 512, SEEK_SET); ret = read(s->fd, buf, nb_sectors * 512); if (ret != nb_sectors * 512) --5vNYLRcllDrimb99--