<?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/"
	>

<channel>
	<title>The HyRax Macrocosm &#187; Recovery</title>
	<atom:link href="http://www.serenux.com/tag/recovery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.serenux.com</link>
	<description>Life, the Universe and Ubuntu.</description>
	<lastBuildDate>Tue, 10 Jan 2012 06:59:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>HowTo: Configure an APC UPS to communicate with your Ubuntu Desktop or Server</title>
		<link>http://www.serenux.com/2011/01/howto-configure-an-apc-ups-to-communicate-with-your-ubuntu-desktop-or-server/</link>
		<comments>http://www.serenux.com/2011/01/howto-configure-an-apc-ups-to-communicate-with-your-ubuntu-desktop-or-server/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 12:32:27 +0000</pubDate>
		<dc:creator>HyRax</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Lucid]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.serenux.com/?p=749</guid>
		<description><![CDATA[It&#8217;s been a while since I&#8217;ve written something here, so time to break the drought. APC make some great UPS products and they all have the ability to communicate with a host PC to advise of its state, eg: on mains, on battery, fault, etc. The support software is available aplenty for Windows and Mac, [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I&#8217;ve written something here, so time to break the drought.</p>
<p>APC make some great UPS products and they all have the ability to communicate with a host PC to advise of its state, eg: on mains, on battery, fault, etc. The support software is available aplenty for Windows and Mac, but what about Linux?</p>
<p>This guide will show you how to hook up an APC UPS to an Ubuntu-based Desktop or Server PC and allow your UPS to email you when mains power has failed, when mains power has been restored, and also give your PC ample opportunity to shutdown when battery on the UPS gets to a critical low.</p>
<p><span id="more-749"></span><span style="text-decoration: underline;">Pre-requisites:</span></p>
<ul>
<li>Ubuntu-based PC. I am using Ubuntu 10.04 Lucid Lynx in this guide.</li>
<li>An APC UPS. I&#8217;m using a Back-UPS RS 800 in this guide.</li>
<li>Details about your ISP&#8217;s mail server, or your own local mail server.</li>
</ul>
<p><span style="text-decoration: underline;">Configuration:</span></p>
<ol>
<li>Setup your APC UPS as outlined in the instruction manual. Ensure that the USB or serial cable is connected from the UPS to the PC. This is what the UPS uses to communicate with the PC.<br />
.</li>
<li>On your Ubuntu PC, go into a Terminal. If you are using Ubuntu Desktop, you can do this by going to the Applications menu, then Accessories and then Terminal. If you are using Ubuntu Server, simply login to your server by the console or SSH in remotely.<br />
.</li>
<li>The Ubuntu repositories contain a UPS daemon specifically designed with APC UPS units in mind called APCUPSD, so let&#8217;s install it:
<pre><span style="color: #000080;">$ sudo apt-get install apcupsd</span></pre>
</li>
<li>Once installed, we need to configure it to suit your UPS. Bring up the configuration file by typing in:
<pre><span style="color: #000080;">$ sudo nano /etc/apcupsd/apcupsd.conf</span></pre>
</li>
<li>In the editor, scroll down to UPSNAME and give the UPS a name, eg:
<pre><span style="color: #000080;">UPSNAME MyAwesomeUPS</span></pre>
</li>
<li>Scroll down to UPSCABLE and change the parameter to the type of cable you are using to connect to your UPS. In my case, I use a USB cable that came with the UPS, so I changed this line to read:
<pre><span style="color: #000080;">UPSCABLE usb</span></pre>
</li>
<li>The next line to modify is the UPSTYPE line. Again, because I&#8217;m using USB I specify:
<pre><span style="color: #000080;">UPSTYPE usb</span></pre>
<p>If you have a DEVICE /dev/ttyS0 line after the UPSTYPE line, comment it out by adding a hash symbol at the start of the line like so:</p>
<pre><span style="color: #000080;">#DEVICE /dev/ttyS0</span></pre>
</li>
<li>We do not need to modify anything else, so press CTRL+X, then &#8220;Y&#8221; and then Enter to save your changes and exit the Nano text editor.<br />
.</li>
<li>Now we need to tell the system that the UPS daemon has been setup and is essentially ready to go. Type in:
<pre><span style="color: #000080;">$ sudo nano /etc/default/apcupsd</span></pre>
</li>
<li>In the file that appears, modify the ISCONFIGURED line to say Yes&#8221;, ie:
<pre><span style="color: #000080;">ISCONFIGURED=yes</span></pre>
</li>
<li>Press CTRL+X, then &#8220;Y&#8221; and then Enter to save your changes and exit.<br />
.</li>
<li>We&#8217;re pretty much done here. Start the daemon now with the following command:
<pre><span style="color: #000080;">$ sudo service apcupsd restart</span></pre>
<p>&#8230;or simply reboot your PC. Your PC is now monitoring the state of the UPS.<br />
.</li>
<li>Let&#8217;s check the UPS now. Type in the following command:
<pre><span style="color: #000080;">$ apcaccess</span></pre>
<p>&#8230;and you will get output similar to the following:</p>
<pre><span style="color: #000080;">$ apcaccess
APC      : 001,043,1045
DATE     : Tue Feb 01 00:02:36 EST 2011
HOSTNAME : lamaar
VERSION  : 3.14.6 (16 May 2009) debian
UPSNAME  : LAMAAR
CABLE    : USB Cable
MODEL    : Back-UPS BR  800
UPSMODE  : Stand Alone
STARTTIME: Mon Jan 31 23:43:37 EST 2011
STATUS   : ONLINE
LINEV    : 250.0 Volts
LOADPCT  :  40.0 Percent Load Capacity
BCHARGE  : 100.0 Percent
TIMELEFT :  19.9 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
OUTPUTV  : 230.0 Volts
SENSE    : Medium
DWAKE    : 000 Seconds
DSHUTD   : 000 Seconds
LOTRANS  : 194.0 Volts
HITRANS  : 264.0 Volts
RETPCT   : 000.0 Percent
ITEMP    : 29.2 C Internal
ALARMDEL : Always
BATTV    : 27.4 Volts
LINEFREQ : 50.0 Hz
LASTXFER : Low line voltage
NUMXFERS : 0
TONBATT  : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x07000008 Status Flag
SERIALNO : xxxxxxxxxxxx  
BATTDATE : 2001-09-25
NOMOUTV  : 230 Volts
NOMINV   : 230 Volts
NOMBATTV :  24.0 Volts
NOMPOWER : 540 Watts
FIRMWARE : 9.o5 .I USB FW:o5
APCMODEL : Back-UPS BR  800
END APC  : Tue Feb 01 00:02:41 EST 2011
$</span></pre>
</li>
<li>Pat yourself on the back, you&#8217;re basically done.</li>
</ol>
<p>But hang on, what about setting up email notifications? Read on.</p>
<p><span style="color: #0000ff;"><em><strong>Setting up Email Notifications</strong></em></span></p>
<p>By default, APCUPSD is configured to use <em>sendmail</em> to send emails, but sendmail is finicky. There is a better way using a similar application called <em>send<strong>e</strong>mail</em> instead.</p>
<p>Why use sendemail instead of sendmail? Well, sendemail is a simple command-line SMTP client. You construct a simple message with a recipient and off it goes, but the key difference here is that sendemail is a CLIENT, not a SERVER. This means for sendemail to work, you need a third-party mail server to send it through. You may already have a mail server on your network running Postfix or similar. If not, your ISP will most certainly have one that you can use.</p>
<ol>
<li>Let&#8217;s start by installing sendemail:
<pre><span style="color: #000080;">$ sudo apt-get install sendemail</span></pre>
</li>
<li>Now we need to configure apcupsd to use it. If you have a look inside the /etc/apcupsd directory, you will see several important files as follows:
<ul>
<li><span style="color: #0000ff;">changeme</span> &#8211; notifies you if the UPS battery needs changing.</li>
<li><span style="color: #0000ff;">commfailure</span> &#8211; notifies you if the PC loses communication with the UPS.</li>
<li><span style="color: #0000ff;">commok</span> &#8211; notifies you if lost communication is restored with the UPS.</li>
<li><span style="color: #0000ff;">onbattery</span> &#8211; notifies you if the UPS engages battery mode due to mains power failure.</li>
<li><span style="color: #0000ff;">offbattery</span> &#8211; notifies you if the UPS returns to mains mode after a mains power failure.<br />
.</li>
</ul>
</li>
<li>Let&#8217;s modify the onbattery message:
<pre><span style="color: #000080;">$ sudo nano /etc/apcupsd/onbattery</span></pre>
</li>
<li>You will notice there are some lines in this file that define some variables followed by a message and then finally a command that sends an email using the sendmail app. Since we are not using sendmail, we need to modify a number of areas. Replace the content of the entire text file with the following:
<pre><span style="color: #000080;">#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the UPS
# goes on batteries.
#
SYSADMIN=jbloggs@mydomain.com.au
APCUPSD_MAIL="/usr/bin/sendemail"
HOSTNAME=`hostname`
MSG="Ubuntu PC Power Failure !!!"
#
(
echo " "
echo " ====================================="
echo " POWER FAILURE ON $HOSTNAME !!"
echo " ====================================="
echo " "
echo " The UPS on your Ubuntu PC has experienced a power problem that has required the UPS to engage battery mode."
echo " "
echo " Do not panic! Remain calm..."
echo " "
echo "Current UPS status:"
echo " "
/sbin/apcaccess status
) | $APCUPSD_MAIL -u "$MSG" -f MyUbuntuPC@mydomain.com.au -t $SYSADMIN -s mail.myisp.com:25
exit 0</span></pre>
<p>So what have we done here? The first part of the file sets some variables, namely the email address(es) of the people required to be notified. If you need to send to more than one recipient, separate email addresses with a comma, eg:</p>
<pre><span style="color: #000080;">SYSADMIN=jbloggs@mydomain.com.au,fredsmith@thatotherdomain.com</span></pre>
<p>We then define the path to the sendemail app, the hostname of the PC running the UPS daemon, a subject line for the email in question, and then a big email body explaining what&#8217;s going on, in this case that the UPS battery mode has been engaged.</p>
<p>All this is then piped into the sendemail application with a fake sender&#8217;s address to give you an idea where it came from and we also specify the mail server that the email will be sent via. In this case, we are using our ISP&#8217;s mail server that has the address <em>mail.myisp.com</em><br />
.</li>
<li>Save your changes by pressing CTRL+X, then &#8220;Y&#8221; and then Enter.<br />
.</li>
<li>You can now test the script by simply executing it (we don&#8217;t have to disconnect the UPS&#8217; mains cable to trigger this until we&#8217;re ready to test that). Execute the file using the command:
<pre><span style="color: #000080;">$ sh /etc/apcupsd/onbattery</span></pre>
</li>
<li>Check for any errors and then check to see if you got an email in your mailbox advising that the UPS is on battery (the UPS of course is not, we&#8217;re just testing the email).<br />
.</li>
<li>If all is well, continue to change the other four message files to be similar to the above, changing the message as you go of course.<br />
.</li>
<li>Pat yourself on the back &#8211; you now have custom, explicit messages to let you know what&#8217;s going on with the UPS.</li>
</ol>
<p><span style="color: #0000ff;"><em><strong>Setting up your own mail server to use instead</strong></em></span></p>
<p>If, in your testing, you discover that your ISP&#8217;s mail server does not allow you to randomly spam messages to it using fake from addresses, you have two choices &#8211; either specify a valid email address as the sender&#8217;s address, or you can setup a simple email server of your own using Postfix:</p>
<pre><span style="color: #000080;">$ sudo apt-get install postfix</span></pre>
<p>In the case of setting up your own email server, simply go with Postfix and set it up as an &#8220;Internet Site&#8221;. The basic configuration is good enough to deal with our needs, but make sure your basic network security is adequate to prevent outsiders from trying to use your mail server to send unsolicited mails, or spam, through it.</p>
<p>This article will not describe how to setup or secure Postfix as it is beyond the scope of this article, however you do need to modify the outgoing mail server name in all your communication messages to reflect the change of name or internal IP address of your mail server instead of mail.myisp.com.</p>
<p><span style="color: #0000ff;"><em><strong>Testing</strong></em></span></p>
<p>You can test your daemon setup easily enough by doing any of the following:</p>
<ul>
<li>Remove mains power cable from UPS.</li>
<li>Remove the USB cable to the UPS.</li>
<li>Verify that an email is sent for either of the error conditions above.</li>
</ul>
<p>Enjoy! <img src='http://www.serenux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serenux.com/2011/01/howto-configure-an-apc-ups-to-communicate-with-your-ubuntu-desktop-or-server/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>HowTo: Fix a missing eth0 adapter after moving Ubuntu Server from one box to another.</title>
		<link>http://www.serenux.com/2009/11/howto-fix-a-missing-eth0-adapter-after-moving-ubuntu-server-from-one-box-to-another/</link>
		<comments>http://www.serenux.com/2009/11/howto-fix-a-missing-eth0-adapter-after-moving-ubuntu-server-from-one-box-to-another/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 01:49:06 +0000</pubDate>
		<dc:creator>HyRax</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Jaunty]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.serenux.com/?p=642</guid>
		<description><![CDATA[Scenario: You have a box running Ubuntu Server. Something happens to the box and you decide to move the hard-drive to another physical machine to get the server back up and running. The hardware is identical on the other machine, so there shouldn&#8217;t be any issues at all, right? The machine starts up fine, but [...]]]></description>
			<content:encoded><![CDATA[<p>Scenario: You have a box running Ubuntu Server. Something happens to the box and you decide to move the hard-drive to another physical machine to get the server back up and running. The hardware is identical on the other machine, so there shouldn&#8217;t be any issues at all, right?</p>
<p>The machine starts up fine, but when you try and hit the network, you can&#8217;t. Closer inspection using the <em>ifconfig</em> command reveals that there is no &#8220;eth0&#8243; adapter configured. Why?</p>
<p>Here&#8217;s how to fix it.</p>
<p><span id="more-642"></span></p>
<p><img title="More..." src="http://www.serenux.com/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif" alt="" />Ubuntu Server keeps tabs on the MAC address of the configured ethernet adapter. Unlike Ubuntu Desktop, you can&#8217;t simply change network cards willy nilly &#8211; while Ubuntu Server does detect and automatically setup new cards, it won&#8217;t automatically replace any adapter already configured as eth0 with another one, so you need to tell Ubuntu Server that you no longer need the old adapter.</p>
<p>This problem can also appear if you have a virtual machine such as one from Virtualbox, and you move or copy it from one host to another without ensuring that the MAC address configured for that VM&#8217;s ethernet adapter is 100% identical to the previous one.</p>
<p>These instructions were done with Ubuntu Server 9.04 Jaunty Jackalope in mind, but should apply to just about any release.</p>
<ol>
<li>Since you can&#8217;t SSH in, you will need to login directly on the Ubuntu Server console as an appropriate user with sudo rights.<br />
.</li>
<li>Once logged in, type in the following and hit Enter:
<pre><span style="color: #000080;">$ sudo nano /etc/udev/rules.d/70-persistent-net.rules</span></pre>
</li>
<li>You are now presented with the Nano text editor and some info that looks similar to the following:
<pre><span style="color: #000080;"># This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x1004 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="0a:03:27:c2:b4:eb", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"</span></pre>
</li>
<li>Delete the last two lines or simply comment out the SUBSYSTEM line on the end. This is a rule defining what MAC address should be explicitly assigned to &#8220;eth0&#8243;. Since you no longer have an ethernet card with the specified MAC address in this machine (it&#8217;s on the old PC, remember), Ubuntu Server effectively ignores your new ethernet adapter because its MAC address does not match the defined rule for &#8220;eth0&#8243;.<br />
.</li>
<li>Once you&#8217;ve made your changes, press CTRL + X and then Y and then Enter to save your changes.<br />
.</li>
<li>Now reboot your box with:
<pre><span style="color: #000080;">$ sudo reboot</span></pre>
</li>
<li>Upon reboot, Ubuntu Server will detect the &#8220;new&#8221; ethernet adapter in your PC and will automatically write a new rule into the <em>/etc/udev/rules.d/70-persistent-net.rules</em> file, thus enabling networking over eth0 for your server.<br />
.</li>
<li>To verify that the new adapter is working, type in:
<pre><span style="color: #000080;">$ ifconfig</span></pre>
<p>&#8230;and you should see eth0 now listed with your defined IP address.<br />
.</li>
<li>Test remote connectivity to the server and if all is well, then pat yourself on the back. You&#8217;re done.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.serenux.com/2009/11/howto-fix-a-missing-eth0-adapter-after-moving-ubuntu-server-from-one-box-to-another/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>HowTo: Restore the Windows Master Boot Record (without using a Windows CD) using Ubuntu Karmic.</title>
		<link>http://www.serenux.com/2009/10/howto-restore-the-windows-master-boot-record-mbr-without-using-a-windows-cd-using-ubuntu-karmic/</link>
		<comments>http://www.serenux.com/2009/10/howto-restore-the-windows-master-boot-record-mbr-without-using-a-windows-cd-using-ubuntu-karmic/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 12:41:05 +0000</pubDate>
		<dc:creator>HyRax</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Apt]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.serenux.com/?p=634</guid>
		<description><![CDATA[You know how it is &#8211; you take a client&#8217;s Windows based machine, do a dual-boot installation of Ubuntu (which replaces the Windows Master Boot Record, or MBR, with GRUB and sets up an option to boot Ubuntu or Windows) so the client can evaluate Ubuntu, but then later on for whatever reason, Ubuntu is [...]]]></description>
			<content:encoded><![CDATA[<p>You know how it is &#8211; you take a client&#8217;s Windows based machine, do a dual-boot installation of Ubuntu (which replaces the Windows Master Boot Record, or MBR, with GRUB and sets up an option to boot Ubuntu or Windows) so the client can evaluate Ubuntu, but then later on for whatever reason, Ubuntu is no longer wanted. It&#8217;s removed and you need to restore the system&#8217;s ability to natively boot Windows directly without a GRUB menu.</p>
<p>You&#8217;re probably thinking &#8220;why the hell would anyone want to do that?!&#8221;&#8230; well, the fact of the matter is you sometimes come across a client who is just too mind-set and refuses to use anything but Windows, so yes &#8211; sometimes you need to restore the Windows MBR, but how do you do that when you don&#8217;t have a Windows CD handy?</p>
<p>Well, here&#8217;s how to do it using nothing but an Ubuntu 9.10 (or later) LiveCD.</p>
<p><span id="more-634"></span>It&#8217;s a little known fact that the Windows bootloader is nothing special. In fact it contains nothing proprietary to Windows at all. All the Windows bootloader does is simply look for the partition marked as &#8220;bootable&#8221; or &#8220;active&#8221; and transfer control of the boot process to it.</p>
<p>And would you know it? The Ubuntu LiveCD has a binary image of a generic open source bootloader that does just that!</p>
<ol>
<li>Boot your soon-to-be-Windows-only machine using the Ubuntu 9.10 (or later) LiveCD. Doesn&#8217;t matter if it&#8217;s the 32-bit or 64-bit version.<br />
.</li>
<li>Once booted on the LiveCD, open a terminal by going to the Applications menu and then choose Accessories and then Terminal.<br />
.</li>
<li>Find out what the designation of the Windows drive is (generally it will be the first drive, eg: /dev/sda or /dev/hda). If you are not sure, issue the command:
<pre><span style="color: #000080;">$ sudo fdisk -l </span></pre>
<p>&#8230;and review the output, looking for your NTFS Windows partition. Make note of the <em>drive</em> that partition resides on (not the partition itself), eg: &#8220;/dev/sda&#8221;, <span style="text-decoration: underline;">not</span> &#8220;/dev/sda1&#8243;.</p>
<p>&nbsp;</li>
<li>Now type in the following (remembering to substitute the correct drive device name for your setup in place of &#8220;/dev/sda&#8221;):
<pre><span style="color: #000080;">$ sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda</span></pre>
<p>&#8230;which will write the image of a standard MBR contained in the /usr/lib/syslinux directory of the LiveCD environment to the first hard-drive, overwriting GRUB. <span style="color: #ff0000;"><strong><em>WARNING: Do NOT use a partition designation, eg: &#8220;sda1&#8243; or &#8220;sda2&#8243;, etc. This will overwrite the start of that partition which will effectively destroy data. The MBR exists at the start of the drive only, so only specify &#8220;sda&#8221; with no number on the end.</em></strong></span></p>
<p>&nbsp;</li>
<li>Shutdown and reboot. Windows should now start &#8220;natively&#8221; without GRUB appearing at all.<br />
.</li>
<li>Normally I&#8217;d say &#8220;pat yourself on the back&#8221; here, but it&#8217;s Windows&#8230; <img src='http://www.serenux.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.serenux.com/2009/10/howto-restore-the-windows-master-boot-record-mbr-without-using-a-windows-cd-using-ubuntu-karmic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Reclaim reserved disk space on non-system drives taken by the Ext3 filesystem.</title>
		<link>http://www.serenux.com/2009/04/howto-reclaim-reserved-disk-space-on-non-system-drives-taken-by-the-ext3-filesystem/</link>
		<comments>http://www.serenux.com/2009/04/howto-reclaim-reserved-disk-space-on-non-system-drives-taken-by-the-ext3-filesystem/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 14:53:49 +0000</pubDate>
		<dc:creator>HyRax</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Hard-Drive]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[Storage]]></category>

		<guid isPermaLink="false">http://www.serenux.com/?p=471</guid>
		<description><![CDATA[I made a rather alarming discovery today, quite by accident. Like most people, I use an external hard-drive to backup data to, or to shift things around if I&#8217;m low on space on my PC&#8217;s internal drive. Well, today that external drive reported that it was full. Damn. So I fire up Ubuntu&#8217;s Disk Usage [...]]]></description>
			<content:encoded><![CDATA[<p>I made a rather alarming discovery today, quite by accident.</p>
<p>Like most people, I use an external hard-drive to backup data to, or to shift things around if I&#8217;m low on space on my PC&#8217;s internal drive. Well, today that external drive reported that it was full. Damn.</p>
<p>So I fire up Ubuntu&#8217;s Disk Usage Analyser, aka Boabab, to find out what&#8217;s consuming the most space. I use a 1TB external drive and it&#8217;s formatted total is about 916GB, which is about right, however Boabab reported that the total consumption of data on the drive only added up to about 860GB &#8211; wtf? Even Nautilus&#8217;s Volume Properties window was reporting that the drive still had 50GB-odd free, so why is the system telling me it&#8217;s full?</p>
<p>I use Ext3 on my drives and, being a journalled filesystem, some space on the drive is reserved to record these journals among other functions which is expected, but 50GB worth? I did some research and found out that the Ext3 filesystem reserves 5% of disk space by default for itself! In this day and age of large drives, that&#8217;s a huge chunk of lost space!!</p>
<p>Thankfully there is a way to tell Linux not to reserve so much space. Read on&#8230;</p>
<p><span id="more-471"></span></p>
<ol>
<li>First up, unmount your drive. You can do that by either right-clicking on the drive icon on the desktop and choosing &#8220;Unmount volume&#8221; or by clicking on the Eject icon next to it in the Places pane of any Nautilus window.<br />
.</li>
<li>Next, open up a terminal and type the following:
<pre><span style="color: #000080;">$ sudo fdisk -l
</span></pre>
<p>This will list all your available drives. Identify which one is your external drive and take note of the device name, eg: in my case my external drive appears as /dev/sdb with one partition on it, sdb1.<br />
.</li>
<li>Now type in the following:
<pre><span style="color: #000080;">$ sudo tune2fs -m 1 /dev/sdb1
</span></pre>
<p>This will modify the filesystem on that drive, on that one partition, to only reserve 1% instead of the default 5%.<br />
.</li>
<li>Now re-mount your drive by clicking on its name in the Places pane in a Naultilus window.<br />
.</li>
<li>The Nautilus Device Properties window will still show the same free space as before, because it reports the true total free space, but any Nautilus File Manager window only reports <em>usable</em> free space, which in the case of my external drive had now freed up a very sizable 37GB!<br />
.</li>
<li>Lather, rinse, repeat on any other non-system drive partitions on the same or different drive you want to reclaim space back for.</li>
</ol>
<p>You learn something new everyday. <img src='http://www.serenux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serenux.com/2009/04/howto-reclaim-reserved-disk-space-on-non-system-drives-taken-by-the-ext3-filesystem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Image your hard-drive for transfer or backup using dd</title>
		<link>http://www.serenux.com/2008/11/howto-image-your-hard-drive-for-transfer-or-backup-using-dd/</link>
		<comments>http://www.serenux.com/2008/11/howto-image-your-hard-drive-for-transfer-or-backup-using-dd/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 10:47:38 +0000</pubDate>
		<dc:creator>HyRax</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Imaging]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.serenux.com/?p=111</guid>
		<description><![CDATA[Imaging, also known as Ghosting in the Windows world, is the act of creating a sector-by-sector copy of a hard-drive and saving it to a file, or transferring it to another hard-drive. Such uses for imaging include: Backup to an image file Clone to another hard-drive (eg: building multiple identical workstations) either directly or via [...]]]></description>
			<content:encoded><![CDATA[<p>Imaging, also known as Ghosting in the Windows world, is the act of creating a sector-by-sector copy of a hard-drive and saving it to a file, or transferring it to another hard-drive. Such uses for imaging include:</p>
<ul>
<li>Backup to an image file</li>
<li>Clone to another hard-drive (eg: building multiple identical workstations) either directly or via an image file</li>
<li>Data recovery (it&#8217;s safer and easier to examine an image file than risk further damage to the hard-drive itself)</li>
</ul>
<p>Linux has a neat little command that can do this for us called simply &#8220;dd&#8221;. It is completely filesystem independent, so you can backup any hard-drive regardless of whether it was Linux formatted, Mac formatted or Windows formatted. It copies the drive bit by bit, sector by sector, not file by file.</p>
<p><span id="more-111"></span></p>
<p><span style="color: #ff0000;"><em><strong>WARNING:</strong> The following article describes commands that can destroy the information on your hard-drive with next-to-no-chance of being able to rescue what&#8217;s left. Make sure that you have full backups of your data prior to using these commands. You use these commands at your own risk!</em></span></p>
<p>First up, your drive/partition being backed up or written to should be unmounted before you begin. If you were trying to backup the partition containing your system&#8217;s root filesystem, you should boot up your system on a LiveCD so you can access your root partition unmounted.</p>
<p>You then need to determine which drive or partition you want to backup. Easiest way to do this is to fire up a terminal session and type in:</p>
<pre><span style="color: #000080;">$ sudo fdisk -l</span></pre>
<p>&#8230;which will list all your drives, their partitions and sizes. Note down the device name of the drive or partition you wish to backup, eg: /dev/sda for the whole of your first drive or /dev/sda1 for just the first partition of that drive, and you&#8217;re ready to begin backup.</p>
<p>At its simplest, backing up a drive takes two basic parameters &#8211; input device and output device or file as follows:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/sda1 of=/dev/sdb1</span></pre>
<p>&#8230;will copy the content of the first partition on drive sda to the first partition of drive sdb (destroying whatever was in /dev/sdb1 previously).</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/sda1 of=~/mybackup.img</span></pre>
<p>&#8230;will copy the content of the first partition on drive sda to a file called mybackup.img in your Home directory.</p>
<p>If you wish to backup an entire drive rather than just a partition, drop the number on the drive name, ie: /dev/sda1 becomes /dev/sda instead.</p>
<p>To restore the image to a drive, simply reverse the parameters:</p>
<pre><span style="color: #000080;">$ sudo dd if=~/mybackup.img of=/dev/sda1</span></pre>
<p>How simple is that? The only issue with this method of backup, though, is that if you were to backup a 10GB partition containing only 5GB of actual data, the resulting image file will still be 10GB as dd does not simply copy active data from the drive, it copies <em>everything</em>.</p>
<p>So with that in mind, let&#8217;s compress the image, so any empty space on the drive doesn&#8217;t take up unnecessary space in the image file. We can do this by piping the data from dd into gzip before writing it to a file:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/sda1 | gzip -9 &gt; ~/mybackup.img.gz</span></pre>
<p>&#8230;and to restore, we simply pipe the decompressed data into dd again for writing to the drive:</p>
<pre><span style="color: #000080;">$ gunzip -c ~/mybackup.img.gz | sudo dd of=/dev/sda1</span></pre>
<h3>But wait! There&#8217;s more!</h3>
<p>This just scratches the surface of what you can do with dd. For example, you can also use dd to destroy a drive&#8217;s content before you dispose of, or sell the drive by using the following:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/random of=/dev/sda1</span></pre>
<p>&#8230;which will write random data to the partition sda1 using the virtual random device, completely obliterating it.</p>
<p>Or, if you want a more uniform destruction, try:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/zero of=/dev/sda1</span></pre>
<p>&#8230;which will &#8211; no surprises here &#8211; write zeros across the entire partition.</p>
<p>Or perhaps you have a drive that isn&#8217;t playing nice, for example Microsoft Windows can get stroppy when working with, or removing partitions created by a foreign OS. The easiest way to fix this is to simply destroy the Master Boor Record (MBR). You can achieve this by specifying a blocksize parameter. The MBR is inside the first 512 bytes of the drive, so all we have to do is blank those 512 bytes out using:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/zero of=/dev/sda bs=512 count=1</span></pre>
<p>The bs parameter specifies the block size in bytes (in this case 512) and the count parameter specifies how many blocks of 512 bytes we&#8217;re doing (only one in this case, the first 512 bytes of the drive where the MBR resides).</p>
<p>Any PC will now view this hard-drive as a brand new, never partitioned drive.</p>
<h3>Rescuing a dying hard-drive</h3>
<p>The dd command is particularly useful for recovering data on a drive that&#8217;s about to become a paperweight. As long as it can power up and identify itself to the system, you can attempt data recovery by taking an image of the drive and then try to recover the files from that image.</p>
<p>Since dying hard-drives are typically sown with errors, we need to tell dd to ignore them and keep pulling as much data off as possible. Taking our first imaging example, we add a couple of parameters to the command as follows:</p>
<pre><span style="color: #000080;">$ sudo dd if=/dev/sda of=~/mybackup.img conv=noerror,sync</span></pre>
<p>This will make a full backup of all partitions on drive /dev/sda to a file called mybackup.img in your Home directory, and the conv parameter tells dd to ignore any errors found during the read by skipping over them. The sync parameter tells dd to replace the errors with null values &#8211; blanks &#8211; so that the resulting image file is the same data length as the drive.</p>
<p>Once the backup is complete, you can then mount the image to view its content. As long as the MBR (the first 512 bytes of the hard-drive) were not damaged, you will be able to now recover most, if not all your files, without worrying about further failure to the drive or odd behaviour due to the physical errors on the drive itself.</p>
<p>To mount the image file, you do the following. First we need a mountpoint &#8211; a place to reference the mounted image volume:</p>
<pre><span style="color: #000080;">$ mkdir /dev/shm/myrecoveryimage</span></pre>
<p>This creates a directory called &#8220;myrecoverytimage&#8221; in your system&#8217;s RAM drive. Before you point out that you have less physical RAM than the capacity of your hard-drive, don&#8217;t worry &#8211; this is just a mount-point. The image will still be physically read from wherever you put it on another drive.</p>
<p>Now we mount the image. Let&#8217;s say we backed up a standard Linux ext3-formatted drive:</p>
<pre><span style="color: #000080;">$ sudo mount -t ext3 -o loop ~/.mybackup.img /dev/shm/myrecoveryimage</span></pre>
<p>&#8230;or for a Windows NTFS formatted backup image:</p>
<pre><span style="color: #000080;">$ sudo mount -t ntfs -o loop ~/.mybackup.img /dev/shm/myrecoveryimage</span></pre>
<p>We have told the system to mount an image file of filesystem type Ext3 (or NTFS). We have to specify the loopback device because an image file is not a block device like a hard-drive is. We then specify the filename of the image we are wanting to mount, and finally where we are mounting it to.</p>
<p>You can now simply switch over to the mountpoint directory and see the content of the image file as though it were any normally mounted hard-drive.</p>
<pre><span style="color: #000080;">$ cd /dev/shm/myrecoveryimage
$ ls -l</span></pre>
<p>There are a plethora of filesystems that the mount command can manage including FAT, NTFS network filesystems etc. Refer to the man page for the mount command for more details.</p>
<p>When you have finished with the image, you can unmount it with:</p>
<pre><span style="color: #000080;">$ sudo umount /dev/shm/myrecoveryimage</span></pre>
<p>&#8230;and that will make the /dev/shm/myrecoverimage directory revert back to an ordinary empty directory again (which, being in the RAM disk, will be lost when you reboot).</p>
<p>Happy dd&#8217;ing! <img src='http://www.serenux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.serenux.com/2008/11/howto-image-your-hard-drive-for-transfer-or-backup-using-dd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

