Date: Sat, 20 Sep 2008 04:26:12 +0200 From: Alexey Shuvaev <shuvaev@physik.uni-wuerzburg.de> To: Marcel Moolenaar <marcel@FreeBSD.org>, xcllnt@mac.com Cc: freebsd-current@freebsd.org Subject: Re: Booting from gpt on i386/amd64? [PATCH] Message-ID: <20080920022612.GA4934@localhost.my.domain> In-Reply-To: <20080831103555.GA12957@wep4017.physik.uni-wuerzburg.de> References: <20080829205313.GA30330@wep4017.physik.uni-wuerzburg.de> <3a142e750808291416o25b6678bm2b6fa75d0f8e4714@mail.gmail.com> <20080831103555.GA12957@wep4017.physik.uni-wuerzburg.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Aug 31, 2008 at 12:35:55PM +0200, Alexey Shuvaev wrote: > On Fri, Aug 29, 2008 at 11:16:07PM +0200, Paul B. Mahol wrote: > > On 8/29/08, Alexey Shuvaev <shuvaev@physik.uni-wuerzburg.de> wrote: > > > Hello list! > > > > > > I have tried to install a system with pure gpt partitioning, > > > but haven't managed to boot from it. > > > > > > Partition table: > > > > > > => 34 976773101 ad6 GPT (500.1GB) > > > 34 1571840 1 freebsd-ufs (804.8MB) > > > 1571874 8388608 2 freebsd-swap (4.3GB) > > > 9960482 1024 3 freebsd-boot (524.3KB) > > > 9961506 8388608 4 freebsd-ufs (4.3GB) > > > 18350114 524288 5 freebsd-ufs (268.4MB) > > > 18874402 134217728 6 freebsd-ufs (68.7GB) > > > 153092130 823681005 - free - (421.7GB) > > > > > > All necessary files are already installed (ad6p1 = /, ad6p4 = /var, and > > > so on). The system is 8.0-CURRENT from 8 August (bootable usb flash). > > > Computer is Core2Duo E8400 3.0 GHz, 4 Gb RAM, ICH9, 500 GB SATA. > > > What have been done: > > > > > > gpart bootcode -b /path/to/pmbr ad6 > > > [Successful] > > > > > > gpart bootcode -p /path/to/gptboot -i 3 ad6 > > > gpart: /dev/ad6p3: Invalid argument > > > > > > I have tried to 'newfs /dev/ad6p3' and then mounting it and copying > > > gptboot into 'boot' directory on ad6p3, but looking at the sources it > > > seems to be wrong. > > > > > > Then I tried to 'dd if=gptboot of=/dev/ad6p3 bs=512', > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > This command writes gptboot only partially!!! > I have padded gptboot to nearest sector boundary and dd-ed it to ad6p3. > After that the system booted successfully. > As I have expected GENERIC kernel is enough. > > > > but in all cases during the boot the blinking cursor moves 1 line down > > > and computer freezes here. > > > > The remaining question is what is the correct way to put gptboot to > 'freebsd-boot' partition? > It seems that this functionality was in gpt(8) but is missing in > gpart(8). Any work in progress? While I am here should I look at it? > Ok, I have digged the sources a little bit and ended with this simple patch. Actually, the code is taken from gpt(8) utility. It adds automatic padding of gptboot bootcode to the nearest sector boundary. Alexey. --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch-gpart --- sbin/geom/class/part/geom_part.c.orig 2008-08-08 18:14:25.000000000 +0200 +++ sbin/geom/class/part/geom_part.c 2008-09-20 04:13:15.000000000 +0200 @@ -386,6 +386,8 @@ struct ggeom *gp; struct gprovider *pp; const char *s; + char *buf; + off_t bsize; int error, fd; s = gctl_get_ascii(req, "class"); @@ -421,7 +423,17 @@ errx(EXIT_FAILURE, "%s: not enough space", dsf); if (lseek(fd, 0, SEEK_SET) != 0) err(EXIT_FAILURE, "%s", dsf); - if (write(fd, code, size) != size) + + /* + * When writing to a disk device, the write must be + * sector aligned and not write to any partial sectors, + * so round up the buffer size to the next sector and zero it. + */ + bsize = (size + pp->lg_sectorsize - 1) / + pp->lg_sectorsize * pp->lg_sectorsize; + buf = calloc(1, bsize); + bcopy(code, buf, size); + if (write(fd, buf, bsize) != bsize) err(EXIT_FAILURE, "%s", dsf); close(fd); } else --DocE+STaALJfprDB--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080920022612.GA4934>