Date: Tue, 31 Jan 2006 23:22:13 +0000 (GMT) From: wpaul@FreeBSD.ORG (Bill Paul) To: rizzo@icir.org (Luigi Rizzo) Cc: freebsd-stable@FreeBSD.ORG Subject: Re: fdisk, bsdlabel and hidden tricks Message-ID: <20060131232213.7F35F16A422@hub.freebsd.org> In-Reply-To: <20060131135731.B59599@xorpc.icir.org> from Luigi Rizzo at "Jan 31, 2006 01:57:31 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
> recently i was playing with fdisk and bsdlabel to create > a new FreeBSD slice (?) in the MBR on the same disk i > booted from, and later to create a slice and > create partitions on it on a second disk. I did a lot of futzing around with fdisk and friends recently to create a bootable FreeBSD 6.0 system on a compactflash module so I could boot my Soekris board standalone. The basic tricks I used are: - Use sysinstall to create the initial partition table on the disk, not fdisk, if you're in a rush. Run sysinstall, select a custom install, create your partition layout in the partition editor, then select W to write the changes out. - You can use sysinstall's label editor instead of bsdlabel too, _BUT_ beware of the following brain damage. You can set up your desired filesystem layout using the label editor and then use W to write out the changes just as with the partition editor, it will create the label and newfs the new filesystems, but then it will stupidly try to mount the newly created filesystems too. The problem with this is if you told it to create, say, /, /var and /usr, they will be mounted on top of your existing /, /var and /usr filesystems. Of course, since the new filesystems are empty, you've effectively made your whole system disappear, and now you can't get it back except by rebooting. To avoid this, make sure to call the new filesystems something like /mnt/, /mnt/var and /mnt/usr. Also, when creating what's supposed to be /, make sure you toggle off softupdates in the label editor. It's smart enough to only enable softupdates by default on non-root filesystems, but it only knows this by checking if the name of the filesystem is /. Why is this important? I don't know if this is a bug or expected broken behavior, but when I created / with softupdates enabled, I found the ls(1) command would crash or report strange output whenever I did ls -l. It seems to be unable to read the file mode information correctly. This was true of _all_ filesystems, not just /. The Soekris board would otherwise run correctly. Once I realized my mistake, I went back and recreated the rootfs with softupdates off, and the problem went away. This is probably yet another "we don't do that by default so we won't bother testing it" bug. - If you want to use fdisk, use fdisk -u <diskname> and follow the bouncing menus. - If you want to write a custom boot block to sector 0, you can only do it with fdisk -B /my/boot/block.bin -b <diskname> - fdisk will emit a Geom error of some kind when it writes out the MBR and/or boot block. Ignore it. The changes are still written out successfully. - I didn't have to do any screwing around with kern.geom.debugflags to make fdisk work. - If you're using the FreeBSD boot block and boot loader, boot0cfg can be used to install the boot block. You can choose between the normal or serial console boot blocks, but nothing else. I've found in many cases that I need "boot0cfg -o packet <diskname>" to make the first stage bootstrap successfully load the second stage if I've done something weird with the geometry. -Bill -- ============================================================================= -Bill Paul (510) 749-2329 | Senior Engineer, Master of Unix-Fu wpaul@windriver.com | Wind River Systems ============================================================================= <adamw> you're just BEGGING to face the moose =============================================================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060131232213.7F35F16A422>