Пример #1
0
static long
default_capacity(struct storage *s, const char *mtpt)
{
	unsigned long boot, root, swap;
	unsigned long capacity;
	unsigned long mem;

	capacity = slice_get_capacity(storage_get_selected_slice(s));
	mem = storage_get_memsize(s);

	/*
	 * Try to get 768M for /boot, but if space is tight go down to 128M
	 * in 128M steps.
	 * For swap, start with 2*mem but take less if space is tight
	 * (minimum is 384).
	 * Rest goes to / (which is at least 75% slice size).
	 */

	root = capacity / 4 * 3;
	swap = 2 * mem;
	if (swap > SWAP_MAX)
		swap = SWAP_MAX;
	boot = 768;
	while (boot + root > capacity - 384)
		boot -= 128;
	if (boot + root + swap > capacity)
		swap = capacity - boot - root;

	if (capacity < DISK_MIN)
		return(-1);
	else if (strcmp(mtpt, "/boot") == 0)
		return(boot);
	else if (strcmp(mtpt, "swap") == 0)
		return(swap);
	else if (strcmp(mtpt, "/") == 0)
		return(-1);

	/* shouldn't ever happen */
	return(-1);
}
Пример #2
0
/*
 * state_select_slice: ask the user which slice they wish to install
 * DragonFly on.  In order to avoid confusing them, refer to it as
 * a primary partition, but tell them what BSD has traditionally called
 * it, too.
 */
void
state_select_slice(struct i_fn_args *a)
{
	char msg_buf[1][1024];

	snprintf(msg_buf[0], sizeof(msg_buf[0]),
	    _("Select the existing primary partition (also "
	    "known as a `slice' in the BSD tradition) on "
	    "which to install %s.\n\n"
	    "Note that if you do not have any existing "
	    "primary partitions on this disk, you must "
	    "first create some. This installer does not "
	    "currently have the ability to do this, so "
	    "you will have to exit and run fdisk (in "
	    "DOS or *BSD) or parted (in Linux) to do so."),
	    OPERATING_SYSTEM_NAME);

	a->short_desc = msg_buf[0];
	a->cancel_desc = _("Return to Select Disk");
	fn_select_slice(a);
	if (!a->result || storage_get_selected_slice(a->s) == NULL) {
		state = state_select_disk;
	} else {
		if (measure_activated_swap_from_slice(a, storage_get_selected_disk(a->s),
		    storage_get_selected_slice(a->s)) > 0) {
			if (swapoff_all(a) == NULL) {
				inform(a->c, _("Warning: swap could not be turned off."));
				state = state_select_slice;
				return;
			}
		}

		if (slice_get_capacity(storage_get_selected_slice(a->s)) < DISK_MIN) {
			inform(a->c, _("WARNING: you should have a primary "
			    "partition at least %dM in size, or "
			    "you may encounter problems trying to "
			    "install %s."), DISK_MIN, OPERATING_SYSTEM_NAME);
		}

		if (confirm_dangerous_action(a->c,
		    _("WARNING!  ALL data in primary partition #%d,\n\n%s\n\non the "
		    "disk\n\n%s\n\n will be IRREVOCABLY ERASED!\n\nAre you "
		    "ABSOLUTELY SURE you wish to take this action?  This is "
		    "your LAST CHANCE to cancel!"),
		    slice_get_number(storage_get_selected_slice(a->s)),
		    slice_get_desc(storage_get_selected_slice(a->s)),
		    disk_get_desc(storage_get_selected_disk(a->s)))) {
			if (!format_slice(a)) {
				inform(a->c, _("Primary partition #%d was "
				    "not correctly formatted, and may "
				    "now be in an inconsistent state. "
				    "We recommend re-formatting it "
				    "before proceeding."),
				    slice_get_number(storage_get_selected_slice(a->s)));
			} else {
				inform(a->c, _("Primary partition #%d was formatted."),
				    slice_get_number(storage_get_selected_slice(a->s)));
				state = state_ask_fs;
			}
		} else {
			inform(a->c, _("Action cancelled - no primary partitions were formatted."));
			state = state_select_slice;
		}
	}
}
Пример #3
0
static int
check_capacity(struct i_fn_args *a)
{
	struct subpartition *sp;
	long min_capacity[] = {128, 0, DISK_MIN - 128, 0};
	unsigned long total_capacity = 0;
	unsigned long remaining_capacity;
	int mtpt, warn_smallpart = 0;

	remaining_capacity = slice_get_capacity(storage_get_selected_slice(a->s));
	for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
	     sp != NULL; sp = subpartition_next(sp)) {
		if (subpartition_get_capacity(sp) != -1)
			remaining_capacity -= subpartition_get_capacity(sp);
	}

	for (sp = slice_subpartition_first(storage_get_selected_slice(a->s));
	     sp != NULL; sp = subpartition_next(sp)) {
		long subpart_capacity = subpartition_get_capacity(sp);
		const char *mountpt = subpartition_get_mountpoint(sp);

		if (subpart_capacity == -1)
			total_capacity++;
		else
			total_capacity += subpart_capacity;
		for (mtpt = 0; def_mountpt[mtpt] != NULL; mtpt++) {
			if (strcmp(mountpt, def_mountpt[mtpt]) == 0 &&
			    subpart_capacity < min_capacity[mtpt] &&
			    subpart_capacity != -1) {
				inform(a->c, _("WARNING: The size (%ldM) specified for "
				    "the %s subpartition is too small. It "
				    "should be at least %ldM or you will "
				    "risk running out of space during "
				    "the installation."),
				    subpart_capacity, mountpt,
				    min_capacity[mtpt]);
			}
		}
		if (strcmp(mountpt, "/boot") != 0 &&
		    strcmp(mountpt, "swap") != 0) {
			if ((subpart_capacity == -1 && remaining_capacity < HAMMER_MIN) ||
			    (subpart_capacity != -1 && subpart_capacity < HAMMER_MIN))
				warn_smallpart++;
		}
	}

	if (total_capacity > slice_get_capacity(storage_get_selected_slice(a->s))) {
		inform(a->c, _("The space allocated to all of your selected "
		    "subpartitions (%luM) exceeds the total "
		    "capacity of the selected primary partition "
		    "(%luM). Remove some subpartitions or choose "
		    "a smaller size for them and try again."),
		    total_capacity, slice_get_capacity(storage_get_selected_slice(a->s)));
		return(0);
	}

	if (warn_smallpart)
		return (confirm_dangerous_action(a->c,
		    _("WARNING: HAMMER filesystems less than 50GB are "
		    "not recommended!\n"
		    "You may have to run 'hammer prune-everything' and "
		    "'hammer reblock'\n"
		    "quite often, even if using a nohistory mount.\n\n"
		    "NOTE: HAMMER filesystems smaller than 10GB are "
		    "unsupported. Use at your own risk.")));

	return(1);
}