<sect1 id="howto-resizepartition">
	<title>How-To: Resizing a Partition</title>

	<para>
		This how-to explains the resizing of a <glossterm linkend="glossary-partition">partition</glossterm> that is becoming too full. See the following screenshot for the initial situation before resizing:
	</para>

	<para>
		<screenshot>
			<mediaobject>
				<imageobject><imagedata fileref="resize_howto_1.png" format="PNG"/></imageobject>
				<textobject><phrase>Main window before resizing partitions</phrase></textobject>
			</mediaobject>
		</screenshot>
	</para>

	<para>
		On <glossterm linkend="glossary-device">device</glossterm> <quote>/dev/sdb</quote>, partition <quote>sdb2</quote> has only little free space left while the other partition, <quote>sdb1</quote>, is far from being full. For that reason it seems advisable to make the first partition a little smaller and grow <quote>sdb2</quote> so it has more free space available.
	</para>

	<note>
		<title>Note: You cannot modify mounted partitions.</title>
		<para>In the screenshot above both partitions are not currently mounted. If one or both of them were mounted you would have to unmount them first using <xref linkend="menu-partition-mount"/>.</para>
	</note>

	<para>
		The first step is to make more room for the partition to grow, so start by shrinking <quote>sdb1</quote>. Click on the partition and choose <xref linkend="menu-partition-resize"/>. The following dialog comes up:
	</para>

	<para>
		<screenshot>
			<mediaobject>
				<imageobject><imagedata fileref="resize_howto_2.png" format="PNG"/></imageobject>
				<textobject><phrase>Resize dialog before resizing /dev/sdb1</phrase></textobject>
			</mediaobject>
		</screenshot>
	</para>

	<para>
		The dialog allows you to resize the partition in multiple ways. You can either drag the right handle to the left until the partition has the desired size or simply enter the size in the <guilabel>Size</guilabel> text field. Another possibility would be to adjust the size by clicking on the little arrows next to the text field, but that is a little tedious for larger changes.
	</para>

	<para>
		Whichever way you prefer for setting the new size, the dialog should now look like this:
	</para>

	<para>
		<screenshot>
			<mediaobject>
				<imageobject><imagedata fileref="resize_howto_3.png" format="PNG"/></imageobject>
				<textobject><phrase>Resize dialog after resizing /dev/sdb1</phrase></textobject>
			</mediaobject>
		</screenshot>
	</para>

	<para>
		After you click on <guibutton>OK</guibutton>, a new operation is added to the pending operations list and the graphical view and tree view of the device are updated to reflect the new situation:
	</para>

	<para>
		<screenshot>
			<mediaobject>
				<imageobject><imagedata fileref="resize_howto_4.png" format="PNG"/></imageobject>
				<textobject><phrase>Main window after resizing /dev/sdb1</phrase></textobject>
			</mediaobject>
		</screenshot>
	</para>

	<note>
		<title>Note: Operations are previewed first before applying them.</title>
		<para>Although the main window reflects the device's state how it will be after applying the new operation, the operation has in fact not been applied yet: While operations are pending you can still undo them (one by one using <xref linkend="menu-edit-undo"/> or <xref linkend="menu-edit-clear"/> to undo all of them) or quit &partman;, and nothing will have been modified at all.</para>
	</note>
	
	<para>
		Now that there is some free space between the two partitions you can move and grow partition <quote>sdb2</quote>. First, click on <quote>sdb2</quote> and choose <xref linkend="menu-partition-resize"/> again. The resize dialog comes up once more, this time for the second partition. Drag its left handle to the leftmost end so that the dialog looks like this:
	</para>

	<para>
		<screenshot>
			<mediaobject>
				<imageobject><imagedata fileref="resize_howto_5.png" format="PNG"/></imageobject>
				<textobject><phrase>Resize dialog after resizing /dev/sdb2</phrase></textobject>
			</mediaobject>
		</screenshot>
	</para>

	<para>
		Be careful to make sure that the <guilabel>Free space before</guilabel> text field really does show <quote>0 MiB</quote> because otherwise there will be a little free space left between the partitions that will then be wasted.
	</para>

	<para>
		Now click <guibutton>OK</guibutton> again. In the main window things now look like this:
	</para>

	<para>
		<screenshot>
			<mediaobject>
				<imageobject><imagedata fileref="resize_howto_6.png" format="PNG"/></imageobject>
				<textobject><phrase>Main window after resizing /dev/sdb2</phrase></textobject>
			</mediaobject>
		</screenshot>
	</para>

	<para>
		This already looks like what you wanted, so choose <xref linkend="menu-edit-apply"/>. A dialog box will come up and ask you if you are sure to apply the pending operations. Confirm this dialog box and &partman; will begin executing operations:
	</para>

	<para>
		<screenshot>
			<mediaobject>
				<imageobject><imagedata fileref="resize_howto_7.png" format="PNG"/></imageobject>
				<textobject><phrase>&partman; is applying operations</phrase></textobject>
			</mediaobject>
		</screenshot>
	</para>

	<para>
		While operations are being executed you can click on the plus-sign next to each operation in the list to find out the jobs it is made up of and see which job is currently being run.
	</para>

	<para>
		Resizing a partition in the way you resized <quote>/dev/sdb2</quote> above always means it has to be moved to the left first before it can be grown because partitions can never be grown to the left directly. Unfortunately, moving such a large partition will take quite some time. It is not unusual for an operation like this to take several minutes or even more.
	</para>

	<para>
		Finally, all operations will have been successfully completed:
	</para>

	<para>
		<screenshot>
			<mediaobject>
				<imageobject><imagedata fileref="resize_howto_8.png" format="PNG"/></imageobject>
				<textobject><phrase>Progress dialog after successfully applying operations</phrase></textobject>
			</mediaobject>
		</screenshot>
	</para>

	<para>
		By clicking on <guibutton>OK</guibutton> you can now close the progress dialog and return to the main window. &partman; will rescan your devices at this point so that might take a few seconds.
	</para>

	<para>
		If you are interested in some more details about the operations that were just run click on <guibutton>Details</guibutton>. You will see the detailed report that is always generated (and updated on the fly) while &partman; executes operations:
	</para>

	<para>
		<screenshot>
			<mediaobject>
				<imageobject><imagedata fileref="resize_howto_9.png" format="PNG"/></imageobject>
				<textobject><phrase>Progress dialog details</phrase></textobject>
			</mediaobject>
		</screenshot>
	</para>

	<para>
		This report is particularly of interest if an error occurs while executing operations. A report shows each operation, each job and each external command that is being run and is thus very helpful when trying to track down problems.
	</para>

	<para>
		You can save the report as <acronym>HTML</acronym> or view it in an external web browser.
	</para>

	<tip>
		<para>
			Always save the detailed report as <acronym>HTML</acronym> when executing the operations fails with errors or warnings for later reference. You might also want to include it in a bug report you submit to the &kde; bug tracking system at <ulink url="https://bugs.kde.org">bugs.kde.org</ulink>.
		</para>
	</tip>
	
	<para>
		To hide the details again click on <guibutton>Details</guibutton> and to finally close the progress dialog click on <guibutton>OK</guibutton>.
	</para>
</sect1>
