<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>
<channel>
	<title>G-Loaded Journal &#187; Partimage</title>
	<atom:link href="http://www.g-loaded.eu/tag/partimage/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.g-loaded.eu</link>
	<description>An open-source software and technology related journal</description>
	<lastBuildDate>Mon, 05 Dec 2011 19:55:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
		<item>
		<title>Partition images with Partimage and Partimaged</title>
		<link>http://www.g-loaded.eu/2006/01/06/partition-images-with-partimage-and-partimaged/</link>
		<comments>http://www.g-loaded.eu/2006/01/06/partition-images-with-partimage-and-partimaged/#comments</comments>
		<pubDate>Fri, 06 Jan 2006 11:11:19 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Filesystem]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Partimage]]></category>
		<category><![CDATA[Remote]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[System]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2006/01/06/partition-images-with-partimage-and-partimaged/</guid>
		<description><![CDATA[This is a guide to create or restore images of your partitions using the great open source tool Partimage. It provides information on how to do this locally or across the network, by setting up a Partimaged Server. I guess this info is non distribution specific, since we will work from a Rescue environment.]]></description>
			<content:encoded><![CDATA[<p>This is a guide to create or restore images of your partitions using the great open source tool <a href="http://www.partimage.org/" title="Partimage Homepage">Partimage</a>. It provides information on how to do this locally or across the network, by setting up a <em>Partimaged Server</em>. I guess this info is non distribution specific, since we will work from a <em>Rescue</em> environment.<br />
<span id="more-147"></span><br />
The same operations can be performed using the <code>dd</code> utility, but the usage of Partimage is recommended as it does not include the partition&#8217;s free space in the image, resulting in images smaller in size and less required time to complete the operation. Partimage is a command line tool with a basic ncurses user interface. For information about the supported filesystems, you can check its <a href="http://www.partimage.org/" title="Partimage Homepage">homepage</a>.</p>
<h4>Prerequisites</h4>
<p>The most important thing when saving/restoring your partitions to/from image files is that <strong>they are not mounted</strong>, so to keep away from trouble. It is also highly recommended that these operations are done from a <em>Rescue</em> environment. Most distributions&#8217; installation media provide such an option in their welcome screen or else one of the various <em>Live CDs</em> can be used.</p>
<p>We will use the <strong>statically built Partimage</strong>, so download this package from its <a href="http://www.partimage.org/">homepage</a>. This version does not have any dependencies, since everything has been built inside it and it can be run from anywhere. I suggest you save the package to a diskette.</p>
<p>Act professionally and keep detailed notes of the partitions you want to save or restore. A simple mistake in the partition names could lead to loss of data. Also read carefully the partition information presented by Partimage. For a list of your partitions, issue the following command:</p>
<pre class="console"># fdisk -l</pre>
<h4>Save/Restore Partitions Locally</h4>
<p>The developers of Partimage have tried to keep the command line options pretty straight forward and provide some usage examples in the utility&#8217;s help message. Change to the directory where you have extracted the partimage package and have a look by typing:</p>
<pre class="console"># ./partimage --help</pre>
<p>You do not have to provide any command line options, as almost all of them are accessible through the program&#8217;s user interface. You can access it by typing:</p>
<pre class="console"># ./partimage</pre>
<p>Some of the keyboard shortcuts are:<br />
<strong>F5</strong> &#8211; Continue<br />
<strong>F6</strong> &#8211; Exit</p>
<p>To quickly <strong>SAVE</strong> a partition to an image file issue the command:</p>
<pre class="console"># ./partimage -z1 -o -d save /dev/hdb7 /mnt/storage/test_hdb7.partimg.gz</pre>
<p>Make sure you substitute the device node (<code>/dev/hdb7</code>) with your partition and the path to the image file (<code>/mnt/storage/test_hdb7.partimg.gz</code>) with your own.<br />
A little explanation of the options:<br />
<strong>-z1</strong>: Use the <code>gzip</code> algorithm to compress the image. <strong>z0</strong> means no compression and <strong>z2</strong> means usage of the <code>bzip2</code> algorithm, but it&#8217;s slower.<br />
<strong>-o</strong>: Overwrite image files without confirmation.<br />
<strong>-d</strong>: Do not ask for a description for the image. You can exclude this one if you want to save some notes about the image file you are going to create.<br />
<strong>save</strong>: This is not an option, but the action that Partimage will perform.</p>
<p>To quickly <strong>RESTORE</strong> an image to a partition, type:</p>
<pre class="console"># ./partimage restore /dev/hdb7 /mnt/storage/test_hdb7.partimg.gz.000</pre>
<p>Partimage adds a numeric extension to the images. This has a meaning only if you had set Partimage to automatically split the image into multiple volumes when you had saved the partition.</p>
<p>To see some <strong>information</strong> about an image file, issue the command:</p>
<pre class="console"># ./partimage imginfo /mnt/storage/test_hdb7.partimg.gz.000</pre>
<p>Partimage saves the MBR of your disks together with your partition. You can avoid this by using the <code>-M</code> option when saving a partition, but I guess it does not hurt having backups of the MBR. The MBR is not automatically restored when you restore a partition. </p>
<p>To restore the <strong>MBR</strong> from an image file issue the command:</p>
<pre class="console"># ./partimage restmbr /mnt/storage/test_hdb7.partimg.gz.000</pre>
<p>That will be it. One thing to keep in mind is to <strong>unmount</strong> the partitions before saving or restoring them.</p>
<h4>Save/Restore Partitions Remotely</h4>
<p>You can use Partimage to save/restore partitions remotely. To use this feature, you have to setup the <code>Partimaged Server</code>. The machine on which Partimaged is running will be the place where the partition images are saved to or read from. You run Partimage on the client machines and connect to the server in order to save or read the image files you want.</p>
<h5>Configuring the Partimaged Server</h5>
<p>The following operations must be performed on the server machine by root.</p>
<p>First of all, you need to create a new user, named <code>partimag</code>. When Partimaged is run as root, it soon drops priviledges and the <code>partimag</code> user is used to run the server for security. So, this user must exist. Create the user with the following command:</p>
<pre class="console"># useradd -c "Partimaged User" -s /sbin/nologin -r -M partimag</pre>
<p>This creates a system account (<code>-r</code>) for the <code>partimag</code> user and does not create a home directory for it (<code>-M</code>). Also the user cannot login to a shell (<code>-s /sbin/nologin</code>). These <code>useradd</code> options should be the same among the various Linux distributions, but you should check the <code>useradd</code> man page to confirm that.</p>
<p>Next, you have to decide which will be the directory from where the Partimaged Server will run. This directory will also be used as a depot for the image files which will be saved or read by the client machines. For this article, a <code>/var/partimaged_storage/</code> directory will be used. Create this directory:</p>
<pre class="console"># mkdir /var/partimaged_storage</pre>
<p>Copy the <code>partimaged</code> executable file from the package you have downloaded to this directory and set ownership and strict permissions on this directory and its contents:</p>
<pre class="console"># chown -R partimag:partimag /var/partimaged_storage
# chmod -R 0700 /var/partimaged_storage</pre>
<p>That&#8217;s it. Change to the <code>/var/partimaged_storage/</code> directory. The server can be started with the following command:</p>
<pre class="console"># ./partimaged --debug=1</pre>
<p>You can use the <code>--dest</code> and <code>--port</code> options if you intend to use another directory for image file storage or if you want the daemon to listen on a port other than the default <strong>4025</strong> for connections. The debug level is also set to &quot;<strong>1</strong>&quot;, so that log information is written to the default logfile <code>/var/log/partimaged.log</code>. This option can be safely omitted, but this way no log file will be created. The server can accept multiple connections.</p>
<p>The above command starts the Partimaged Server and a monitor screen will be displayed, so you can watch which clients connect and monitor the progress of their operations. If you want to run the server in the background, then you should start the server with the <code>--daemon</code> option.</p>
<p>Finally, make sure you open the <strong>tcp</strong> port you have used (the default is <strong>4025</strong>) in your firewall configuration.</p>
<p>Here follow some notes about security. The version of <code>partimaged</code> that comes in the package you have downloaded is not compiled with SSL or user logins support (at the moment of writing). This is probably for ease of use. This means that if security matters, you should compile the package yourself enabling all the needed options.</p>
<p>Because security does matter, I provide some info on how to connect to the Partimaged Server through encrypted SSH tunnels when you save/restore sensitive data. This way you can control which users can connect to the Partimaged Server by using SSH for access control and you can be sure that data does not travel in the clear across the network. Keep in mind that this <strong>is not</strong> the recommended way because SSH usually uses very strong encryption, so the whole operation could take a lot of time to complete and it will certainly devour your system resources. I suggest you compile partimaged with SSL and user logins support and make use of these features for security.</p>
<h5>Save/Restore Partitions across the Network</h5>
<p>Now that the Partimaged Server is up and running, you can use <code>Partimage</code> on the client machines and save the partition images to the server or read the partition images from the server and restore them on the client machines.</p>
<p>All the options that are used when you perform these operations locally can be used in this case, but you also have to supply the Partimaged Server&#8217;s <strong>IP address</strong> and the <strong>port</strong> it listens on. Furthermore, you <strong>do not</strong> have to supply a <strong>path</strong> for the image file, since the directory from where <code>partimaged</code> runs will be used to write the image files to or read them from.</p>
<p>So, to <strong>SAVE</strong> a partition from a client machine to the Partimaged Server issue the command (from the client machine):</p>
<pre class="console">./partimage --server=192.168.0.1 --port=4025 -z1 -o -d save /dev/hdb7 test_hdb7.partimg.gz</pre>
<p>A path for the image file has not been specified. The above command also assumes that the server is bound on the <code>192.168.0.1</code> IP address.</p>
<p>To <strong>RESTORE</strong> an image file to the client machine issue the command:</p>
<pre class="console">./partimage --server=192.168.0.1 --port=4025 restore /dev/hdb7 test_hdb7.partimg.gz.000</pre>
<p>Again, a path to the image file does not need to be specified.</p>
<p>The following information about connecting to the Partimaged Server through SSH tunnels is provided, but it&#8217;s not really recommended (see previous notes). It assumes that an SSH server is running on the machine where the <code>partimaged</code> daemon runs. Using this way, port 4025 does not need to be open in the server&#8217;s firewall.</p>
<p>To create the SSH tunnel and connect through it to the Partimaged Server to <strong>SAVE</strong> a partition from a client machine, issue the following command (from the client):</p>
<pre class="console">ssh -f -L 24025:127.0.0.1:4025 user@remote sleep 10; ./partimage --server=127.0.0.1 --port=24025 -z1 -o -d save /dev/hdb7 test_hdb7.partimg.gz</pre>
<p>The same goes when you <strong>RESTORE</strong> partitions to client machines:</p>
<pre class="console">ssh -f -L 24025:127.0.0.1:4025 user@remote sleep 10; ./partimage --server=127.0.0.1 --port=24025 restore /dev/hdb7 test_hdb7.partimg.gz.000</pre>
<p>For more information about this way of starting SSH tunnels, you can read a <a href="http://www.g-loaded.eu/2005/11/10/configure-vnc-server-in-fedora/#comment-34">comment</a> of mine on another page.</p>
<h4>Final Notes</h4>
<p>I have used Partimage numerous times to save and restore <code>ext3</code> partitions and it has worked just fine. I also have some <code>xfs</code> partitions, but I never had the need to save or restore them, so I cannot tell. Partimage supports <code>xfs</code>. For information about <code>NTFS</code> or other filesystem support see the <a href="http://www.partimage.org/" title="Partimage Homepage">Partimage</a> homepage and also have a look at <a href="http://www.linux-ntfs.org/">linux-ntfs.org</a>.</p>
<h4>Further Reading</h4>
<p>I consider that the following pages should be read for more information.</p>
<ol>
<li><a href="http://www.partimage.org/">Partimage Homepage</a></li>
<li><a href="http://www.partimage.org/doc/index.html">The PartImage Handbook</a></li>
<li><a href="http://sourceforge.net/docman/display_doc.php?docid=15091&#038;group_id=6212">The Partimage FAQ</a></li>
</ol>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2006/01/06/partition-images-with-partimage-and-partimaged/">Partition images with Partimage and Partimaged</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/09/15/clonezilla-instead-of-partimage/" rel="bookmark">CloneZilla instead of Partimage</a></li>
<li><a href="http://www.g-loaded.eu/2006/04/08/filesystem-backup-again/" rel="bookmark">Filesystem Backup Again</a></li>
<li><a href="http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/" rel="bookmark">Netcat &#8211; a couple of useful examples</a></li>
<li><a href="http://www.g-loaded.eu/2007/11/05/howto-run-vmware-on-a-physical-windows-partition/" rel="bookmark">Howto: Run VMWare on a Physical Windows Partition</a></li>
<li><a href="http://www.g-loaded.eu/2010/03/29/partition-misalignment-slows-4096-byte-sector-hard-drives/" rel="bookmark">Partition Misalignment Slows Down 4096-Byte Sector Hard Disks</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2006/01/06/partition-images-with-partimage-and-partimaged/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

