Date: Mon, 02 Aug 2010 15:39:22 -0700 From: Devin Teske <dteske@vicor.com> To: freebsd-sysinstall@freebsd.org Subject: Funky-See, Funky-Do (nonInteractive UFS1 specification) Message-ID: <1280788762.19910.473.camel@localhost.localdomain>
next in thread | raw e-mail | index | archive | help
Let's have some fun. And while we're at it, contribute a patch that may benefit others. Let's say, for argument's sake, that you wanted to install FreeBSD-8.1 onto a UFS1 formatted filesystem (again... purely for your own enjoyment or luciferous paideia). Such a feat is indeed possible, and here's how: 1. When you are in the Disk Label Editor,... 2. Simply highlight the disk label and... 3. Press '1' on the keyboard. NOTE: A literal '1' is shown in the flags column. sysinstall(8) will indeed adhere to your desires and pass "-O1" (that's dash-oh-one) to newfs, causing the filesystem to be formatted as UFS1. Now, let's say that you wanted to do the SAME EXACT thing with the non- interactive scripting abilities of sysinstall(8). You're dead in the water. Although it's possible to do this in the interactive prompt-based install, it's NOT possible to do this in the non-interactive scripted install. For those not in the know, you can tell sysinstall to automatically format the target installation disk, using lines similar to those shown below in a sysinstall(8) configuration file: disk=/dev/da0 da0s1-1=ufs 2097152 / 0 da0s1-2=swap 2097152 none 0 da0s1-3=ufs 2097152 /var 1 da0s1-4=ufs 2097152 /tmp 1 da0s1-5=ufs 0 /usr 1 Here's the format: [disk]s1-N=[type] [size] [mntdir] [soft-updates] The size is in sectors. The last numeral (0 or 1) is a boolean flag for whether the given filesystem should have 'tunefs -n enable' called, enabling Soft-Updates (a performance enhancing feature). One thing that you may notice about the above format is that there is no way to specify the filesystem version for a ufs filesystem. In the above example, there are 4x ufs partitions which will all be formatted as UFS2 because there is no mechanism in sysinstall's scripting abilities to indicate that you would like UFS1 rather than UFS2. Enter patch... --- usr.sbin/sysinstall/label.c.orig 2010-02-19 12:26:30.000000000 -0800 +++ usr.sbin/sysinstall/label.c 2010-08-02 12:29:37.000000000 -0700 @@ -1611,10 +1611,11 @@ diskLabelNonInteractive(Device *dev) for (entries = 1;; entries++) { intmax_t sz; int soft = 0; + int ufs1 = 0; snprintf(name, sizeof name, "%s-%d", c1->name, entries); if ((cp = variable_get(name)) == NULL) break; - if (sscanf(cp, "%s %jd %s %d", typ, &sz, mpoint, &soft) < 3) { + if (sscanf(cp, "%s %jd %s %d %d", typ, &sz, mpoint, &soft, &ufs1) < 3) { msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp); status = DITEM_FAILURE; break; @@ -1647,6 +1648,7 @@ diskLabelNonInteractive(Device *dev) pi = tmp->private_data = new_part(PART_FILESYSTEM, mpoint, TRUE); tmp->private_free = safe_free; pi->newfs_data.newfs_ufs.softupdates = soft; + pi->newfs_data.newfs_ufs.ufs1 = (ufs1 == 1) ? true : false; } } } With the above patch, you can now write the disk configuration as (specifying that each : disk=/dev/da0 da0s1-1=ufs 2097152 / 0 1 da0s1-2=swap 2097152 none 0 1 da0s1-3=ufs 2097152 /var 1 1 da0s1-4=ufs 2097152 /tmp 1 1 da0s1-5=ufs 0 /usr 1 1 Any other value in the last column will cause the filesystem to be written in the default UFS version (currently UFS2). Also note that with the above patch, the last column is optional, allowing us to retain backward compatibility with the old format (which lacks our new column). Only the first three columns are required. (ducks for flying fruit -- because he knows that a great many will not understand the beauty of his genius... aka madness) -- Cheers, Devin Teske -> CONTACT INFORMATION <- Business Solutions Consultant II FIS - fisglobal.com 510-735-5650 Mobile 510-621-2038 Office 510-621-2020 Office Fax 909-477-4578 Home/Fax devin.teske@fisglobal.com -> LEGAL DISCLAIMER <- This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. -> END TRANSMISSION <-
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1280788762.19910.473.camel>