<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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"><channel><title>softwarebakery.com</title><atom:link href="http://softwarebakery.com/feed.xml" rel="self" type="application/rss+xml"></atom:link><link /><description>Softwarebakery</description><pubDate>Sun, 11 Sep 2022 21:11:45 +0000</pubDate><generator>http://github.com/creationix/wheat</generator><language>en</language><item><title>Persistent Kali Linux in DriveDroid</title><link /><comments>http://softwarebakery.com/persistent-kalilinux-in-drivedroid#disqus_thread</comments><pubDate>Fri, 06 Mar 2015 11:31:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/persistent-kalilinux-in-drivedroid</guid><description>&lt;p&gt;Using Linux Live ISO images is convenient. Easy to install and always have the same environment each time you use it. However, it doesn't save your changes between uses. Sometimes you want to install additional applications and use it each time your boot. This is called a persistent live USB.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.kali.org/&quot;&gt;Kali Linux&lt;/a&gt; is a Linux distribution used primarily for penetration testing. It comes with various tools that are useful to test your networks and applications for vulnerabilities. It also has good support for persistence.&lt;/p&gt;
&lt;p&gt;In this tutorial we will show how set up persistence for Kali Linux that is running from an Android phone using DriveDroid.&lt;/p&gt;
&lt;h1&gt;Requirements&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;A Linux installation with gparted&lt;/li&gt;
&lt;li&gt;A paid version of DriveDroid (for resizing images)&lt;/li&gt;
&lt;li&gt;An USB cable&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Downloading Kali Linux&lt;/h1&gt;
&lt;p&gt;First go to DriveDroid on your Android phone. Press the + button in the bottom of the screen and choose 'Download image...'. In the list of distributions choose 'Kali Linux' and choose a non-mini Kali Linux image that fits your needs. The mini images are not suitable for live environments and are just to run the installer. For this example we used &lt;code&gt;kali-linux-1.1.0-amd64.iso&lt;/code&gt;. Wait for the download to complete.&lt;/p&gt;
&lt;h1&gt;Resizing the image&lt;/h1&gt;
&lt;p&gt;The image that we just downloaded barely fits the basic installation of Kali Linux. To install extra software we need some additional space. This is why we need to resize the image.&lt;/p&gt;
&lt;p&gt;Go back to DriveDroid and long-press &lt;code&gt;kali-linux-1.1.0-amd64.iso&lt;/code&gt;. Choose 'Resize image...' and enter a bigger size for the image. For this example we used 3GB. Wait until the image has been resized.&lt;/p&gt;
&lt;h1&gt;Creating the persistence partition&lt;/h1&gt;
&lt;p&gt;The image now has some free space where we can create a partition that will be used for persistence.&lt;/p&gt;
&lt;p&gt;In DriveDroid press &lt;code&gt;kali-linux-1.1.0-amd64.iso&lt;/code&gt; and choose to host the image as an writable USB drive. Connect your phone to your PC and start gparted (&lt;code&gt;sudo gparted&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;In gparted find the disk that your phone is hosting. In this example it should show up as a 3GB disk. Do note the name of the disk, since we need it later. In this example it is named &lt;code&gt;/dev/sdX&lt;/code&gt;. After selecting &lt;code&gt;/dev/sdX&lt;/code&gt;, you should see that the disk has a bunch of unallocated space; the space we created by resizing the image.&lt;/p&gt;
&lt;p&gt;Next add a new partition. Use 'ext4' as the file system and 'persistence' as the label. Press 'Ok' and see if the partition indeed fills the unallocated space. After that press 'Apply' and close gparted.&lt;/p&gt;
&lt;h1&gt;Configuring Kali Linux&lt;/h1&gt;
&lt;p&gt;Now that we have a partition where Kali Linux can store extra applications and files, we need to configure Kali Linux to actually use that partition.&lt;/p&gt;
&lt;p&gt;First make sure you're root:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo su
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We will make a temporary directory where we can mount the configuration partition of Kali Linux:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mkdir -p /tmp/kalilinux
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next, we mount the partition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mount /dev/sdX3 /tmp/kalilinux
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We add the persistence configuration file that Kali Linux will use when booting:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo &amp;quot;/ union&amp;quot; &amp;gt; /tmp/kalilinux/persistence.conf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Lastly we unmount the partition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;umount /tmp/kalilinux
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The image should now be good to go. Reboot your PC and boot from your phone to check the results.&lt;/p&gt;
&lt;h1&gt;Increase the persistent space&lt;/h1&gt;
&lt;p&gt;If you ever find out that you run out of space in Kali Linux, you can still increase the size of the persistence partition.&lt;/p&gt;
&lt;p&gt;Go to DriveDroid and long-press &lt;code&gt;kali-linux-1.1.0-amd64.iso&lt;/code&gt;. Choose 'Resize image...' and enter a bigger size for the image.&lt;/p&gt;
&lt;p&gt;Now host the image by pressing &lt;code&gt;kali-linux-1.1.0-amd64.iso&lt;/code&gt; and choosing a writable USB drive. Open up gparted and choose the disk like before.&lt;/p&gt;
&lt;p&gt;Instead of adding a partition like we did before, we will change the size of the already existing persistence partition. Right click on the persistence partition and choose 'Resize/Move'. Increase the new size so that there is no free space left. Press 'Resize/Move', hit 'Apply' and close gparted.&lt;/p&gt;
&lt;p&gt;Your image should again be ready to go with more space for your applications.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Building the Android kernel on Linux</title><link /><comments>http://softwarebakery.com/building-the-android-kernel-on-linux#disqus_thread</comments><pubDate>Fri, 19 Dec 2014 14:30:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/building-the-android-kernel-on-linux</guid><description>&lt;p&gt;When you want to add extra functionality to your kernel, you want to develop your own functionality or just want to have your own version of the kernel, you will want to build kernel code.&lt;/p&gt;
&lt;p&gt;In this tutorial we will go through the whole process of retrieving, compiling, (optionally) patching and flashing kernels that are based on AOSP. As an example we will use the kernel of the Nexus 5 (hammerhead). We'll presume this is all done on a Debian or Ubuntu machine, since that is most popular while still practical.&lt;/p&gt;
&lt;h1&gt;Requirements&lt;/h1&gt;
&lt;p&gt;On Debian/Ubuntu you need the following packages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;git&lt;/li&gt;
&lt;li&gt;build-essential&lt;/li&gt;
&lt;li&gt;abootimg&lt;/li&gt;
&lt;li&gt;adb and fastboot&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Install these using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo apt-get install git build-essential abootimg
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And install the Android SDK as described &lt;a href=&quot;https://developer.android.com/sdk/installing/index.html?pkg=tools&quot;&gt;here&lt;/a&gt; to get adb and fastboot.&lt;/p&gt;
&lt;h1&gt;Retrieving the kernel&lt;/h1&gt;
&lt;p&gt;Check what kernel your phone needs on &lt;a href=&quot;https://source.android.com/source/building-kernels.html&quot;&gt;https://source.android.com/source/building-kernels.html&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this example we'll build the kernel for the Nexus 5. The code-name of the Nexus 5 is &lt;code&gt;hammerhead&lt;/code&gt;, which is listed in the table under 'Figuring out which kernel to build'. Take note of the 'Build configuration' (in this example: &lt;code&gt;hammerhead_defconfig&lt;/code&gt;) and 'Source location' (in this example: &lt;code&gt;kernel/msm&lt;/code&gt;). We see these coming back in later steps.&lt;/p&gt;
&lt;p&gt;Next we look up what exact version of the kernel we want to retrieve. We open up Google's git repository of your device online by going to the following URL:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://android.googlesource.com/kernel/msm&quot;&gt;https://android.googlesource.com/kernel/msm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that you need to replace &lt;code&gt;kernel/msm&lt;/code&gt; with the 'Source location' of your device.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;On that page you can look under 'Branches' to see the different versions available. In this example we will be using &lt;code&gt;android-msm-hammerhead-3.4-lollipop-release&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Next we retrieve the kernel from Google by using the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone https://android.googlesource.com/kernel/msm --branch android-msm-hammerhead-3.4-lollipop-release linux
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;Note that you need to replace &lt;code&gt;kernel/msm&lt;/code&gt; with the 'Source location' of your device and replace &lt;code&gt;android-msm-hammerhead-3.4-lollipop-release&lt;/code&gt; with the branch of your device.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This retrieves all source code (and its history) from Google and places it all under a new directory called &lt;code&gt;linux&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;Patching the kernel&lt;/h1&gt;
&lt;p&gt;This step isn't needed if you just want to build your own kernel. Continue with [Compiling the kernel](#Compiling the kernel) if that's the case.&lt;/p&gt;
&lt;p&gt;A note on patches: patches come in all kinds of forms. There are files (&lt;code&gt;.patch&lt;/code&gt; or &lt;code&gt;.diff&lt;/code&gt;) that simply contain changes to certain lines in certain files. Patches are also embedded in version control systems, like Git. There are different ways to retrieve them and different ways to apply them.&lt;/p&gt;
&lt;p&gt;Secondly, patches won't always fit perfectly onto your current code. When a patch cannot be applied to your kernel means that there have been changes made in sections that the patch also touches. These are called conflicts. These conflicts must be solved by the user. We will not cover conflicts in this tutorial, but you can find &lt;a href=&quot;https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line/&quot;&gt;more information on conflicts on Github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this example we will apply a patch that was submitted to CyanogenMod to add CD-rom functionality to DriveDroid on Nexus 5 devices/kernels. The patch can be found on CyanogenMods code reviewing system: http://review.cyanogenmod.org/#/c/57792/&lt;/p&gt;
&lt;p&gt;First change the current directory to the kernel:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd linux
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can apply &lt;code&gt;git&lt;/code&gt; commands on the source code of Linux.&lt;/p&gt;
&lt;p&gt;On the &lt;a href=&quot;http://review.cyanogenmod.org/#/c/57792/&quot;&gt;page of the patch on CyanogenMods code reviewing system&lt;/a&gt; you'll find a few options to download the patch: checkout, pull, cherry-pick and patch. We will use the cherry-pick option, since it is most straight-forward for our purpose. Click cherry-pick and copy the command that shows up under it. In this example the command is the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git fetch http://review.cyanogenmod.org/CyanogenMod/android_kernel_lge_hammerhead refs/changes/92/57792/2 &amp;amp;&amp;amp; git cherry-pick FETCH_HEAD
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Execute this command. It results in the following output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;From http://review.cyanogenmod.org/CyanogenMod/android_kernel_lge_hammerhead
 * branch            refs/changes/92/57792/2 -&amp;gt; FETCH_HEAD
[android-msm-hammerhead-3.4-lollipop-release 3f1a563] usb: gadget: mass_storage: added sysfs entry for cdrom to LUNs
 Date: Thu Jul 4 12:36:57 2013 +0200
 2 files changed, 42 insertions(+)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This means the patch has been applied. Change the current directory back to the parent to continue the tutorial:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd ..
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Compiling the kernel&lt;/h1&gt;
&lt;p&gt;Since most phones and tablets run on an ARM processor, we need a compiler that targets ARM. It's best to use the exact same compiler Google uses, so we'll retrieve that using the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6 arm-eabi-4.6
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next we need to instruct the build process to use the compiler:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;export PATH=$PWD/arm-eabi-4.6/bin:$PATH
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we need to configure Linux, like what modules it should include. In this case we want just the default configuration for the Nexus 5 (hammerhead):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;make -C linux hammerhead_defconfig
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally we can compile the kernel:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;make -C linux
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will take a while. When compilation has finished, the kernel is available under &lt;code&gt;linux/arch/arm/boot/zImage-dtb&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;Preparing a boot image&lt;/h1&gt;
&lt;p&gt;We have the kernel. Next we need to package it up into a bootloader image. A bootloader image usually consists of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A kernel image&lt;/li&gt;
&lt;li&gt;A ramdisk image&lt;/li&gt;
&lt;li&gt;A kernel command-line&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We already have the kernel image, but the ramdisk and kernel commandline are also required. These are dependent on the rom you're using. So, we use the same bootloader image from your rom and replace the kernel.&lt;/p&gt;
&lt;p&gt;First retrieve the factory image from: &lt;a href=&quot;https://developers.google.com/android/nexus/images&quot;&gt;https://developers.google.com/android/nexus/images&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can use your own methods to download and extract the image. In this example we use command-line tools to do this.&lt;/p&gt;
&lt;p&gt;In this example we'll presume you're using &lt;code&gt;hammerhead-lrx21o-factory-01315e08.tgz&lt;/code&gt;. To download it use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;wget https://dl.google.com/dl/android/aosp/hammerhead-lrx21o-factory-01315e08.tgz
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next extract &lt;code&gt;image-hammerhead-lrx21o.zip&lt;/code&gt; from &lt;code&gt;hammerhead-lrx21o-factory-01315e08.tgz&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;tar xfz hammerhead-lrx21o-factory-01315e08.tgz image-hammerhead-lrx21o.zip
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And now extract &lt;code&gt;boot.img&lt;/code&gt; from &lt;code&gt;image-hammerhead-lrx21o.zip&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;unzip image-hammerhead-lrx21o.zip boot.img
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We have an Android boot image which contains a stock kernel, ramdisk and command-line. We extract all of these using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;abootimg -x boot.img
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This results in the following files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;bootimg.cfg&lt;/code&gt;: configuration with addresses, sizes and the kernel commandline.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;zImage&lt;/code&gt;: the stock kernel&lt;/li&gt;
&lt;li&gt;&lt;code&gt;initrd.img&lt;/code&gt;: the stock ramdisk&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will use the same configuration file and ramdisk.&lt;/p&gt;
&lt;p&gt;We do need to make a small change to the configuration though. I found that my compiled kernel image was bigger than the stock kernel. The size of the kernel is set in the configuration file (&lt;code&gt;bootimg.cfg&lt;/code&gt;) to the size of the stock kernel, so this needs to change. Since &lt;code&gt;aboot&lt;/code&gt; can determine the size itself when it's packing everything up, we can just remove the bootsize from the configuration. Open &lt;code&gt;bootimg.cfg&lt;/code&gt; with your favorite editor and remove the line with &lt;code&gt;bootsize =&lt;/code&gt;. Alternatively use the following line to do the same:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sed -i '/bootsize =/d' bootimg.cfg
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can create our custom boot image. We name it &lt;code&gt;newboot.img&lt;/code&gt; using the following line:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;abootimg --create newboot.img -f bootimg.cfg -k linux/arch/arm/boot/zImage-dtb -r initrd.img
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Yay, we now have an image that we can flash onto the phone/tablet.&lt;/p&gt;
&lt;h1&gt;Boot using boot image&lt;/h1&gt;
&lt;p&gt;To try the boot image and kernel you need to reboot into your bootloader on your phone/tablet (aka fastboot mode). You can usually do this by shutting down your phone and holding down Volume Down and the power button. Alternatively you can use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;adb reboot bootloader
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You should see some lines of text starting with &lt;code&gt;FASTBOOT MODE&lt;/code&gt;. Now you can boot your phone with your new boot image:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;fastboot boot newboot.img
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try whether things work correctly. If it does, you can make the boot image permanent by flashing it onto your phone.&lt;/p&gt;
&lt;h1&gt;Flash boot image&lt;/h1&gt;
&lt;p&gt;To make the boot image permanent you can again reboot to your bootloader:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;adb reboot bootloader
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And flash the boot image:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;fastboot flash boot newboot.img
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The next time you reboot your phone it'll start using your own compiled kernel. Have fun!&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Boot Windows 8 from DriveDroid</title><link /><comments>http://softwarebakery.com/boot-windows-from-drivedroid#disqus_thread</comments><pubDate>Fri, 21 Nov 2014 11:31:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/boot-windows-from-drivedroid</guid><description>&lt;p&gt;In &lt;a href=&quot;/using-rufus-to-create-bootable-usb-images&quot;&gt;previous&lt;/a&gt; &lt;a href=&quot;windows-install-on-drivedroid&quot;&gt;tutorials&lt;/a&gt; we've seen how to write a Windows installation ISO to an USB drive. This allowed you to start the Windows installer from your phone. What if you could run Windows itself from your phone instead of just the installer? That would make it possible to have an installation of Windows always with you. This is what we'll show in this tutorial.&lt;/p&gt;
&lt;p&gt;First off, many thanks to &lt;a href=&quot;http://forum.xda-developers.com/showpost.php?p=56795760&amp;amp;postcount=883&quot;&gt;xyancompgeek&lt;/a&gt; for his post on XDA-developers. It is what I'm basing this tutorial on.&lt;/p&gt;
&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/cuInQ55FcX4&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;br/&gt;
&lt;h1&gt;Requirements&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid&quot;&gt;DriveDroid&lt;/a&gt; v0.7.0+&lt;/li&gt;
&lt;li&gt;5.5GB free space on your Android phone&lt;/li&gt;
&lt;li&gt;A phone that supports files greater than 4GB (most Android 4.1+ phones)&lt;/li&gt;
&lt;li&gt;A PC with Windows 7 or 8&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://sourceforge.net/projects/wimlib/&quot;&gt;WimLib&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A Windows 8 installation ISO&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that at this moment Windows 8.1 installation ISOs will not work. This is because your phone is recognized as a removable drive (like an USB stick) whereas Windows 8.1 requires its drive to be non-removable (like a harddisk). Windows 8 does allow removable drives. If you have a Windows 8.1 ISO, you might want to get a kernel that supports emulation of non-removable drives.&lt;/p&gt;
&lt;h1&gt;Image creation&lt;/h1&gt;
&lt;p&gt;First hook up your phone to your PC using a USB cable.&lt;/p&gt;
&lt;p&gt;Next we'll have to create a blank image on your phone. On this image we will eventually store the installation disk. In DriveDroid we go to the + button and choose 'Create blank image...'.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/drivedroid-01.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Choose a filename like 'windows8.img' and choose 5500MB as the size for the image. You can uncheck 'Partition table (MBR)' and choose 'None' for the filesystem. Now hit the 'Create' button on the top-right.&lt;/p&gt;
&lt;p&gt;As a side-note, we choose to not create a partition table and filesystem here because DriveDroid does not support formatting NTFS filesystems. NTFS is required and Windows does a good job creating a partition table and formatting the NTFS filesystem, but we'll get to that.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/drivedroid-02.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;This will create the image file in the background. Open the notification-bar to see when the image creation is finished.&lt;/p&gt;
&lt;p&gt;Your phone probably has a hard time while it's allocating the file, so it's best not to do anything else while it's working.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/drivedroid-03.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Once the image is created go to DriveDroid.&lt;/p&gt;
&lt;h1&gt;Partitioning and formatting&lt;/h1&gt;
&lt;p&gt;Select the image in DriveDroid and click the option that says 'Writable USB'. As soon as we have done that, Windows will find a new USB drive.&lt;/p&gt;
&lt;p&gt;Go to start and type &lt;code&gt;cmd.exe&lt;/code&gt;. Right-click 'Command Prompt' and choose 'Run as Administrator'.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-01.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Start diskpart by typing &lt;code&gt;diskpart&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-02.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Show the connected disks by typing &lt;code&gt;list disk&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-03.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;You will see that the image you just created in DriveDroid is listed here as a disk of 5500MB. In this example it is listed as Disk 3.&lt;/p&gt;
&lt;p&gt;To work on disk 3, we need to select it by typing &lt;code&gt;select disk 3&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-04.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;First we remove anything that's already on the disk (if any), by typing &lt;code&gt;clean&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-05.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Now we can create a partition by typing &lt;code&gt;create partition primary&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-06.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;The partition doesn't have a filesystem yet. For the Windows 8 disk we need a NTFS filesystem. We can format a NTFS filesystem on the partition by typing &lt;code&gt;format fs=ntfs quick&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-07.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Now we have a partition table, partition and filesystem. We only have to mark the partition as 'bootable' to be able to boot from it. We do this by typing &lt;code&gt;active&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-08.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Finally we leave diskpart by typing &lt;code&gt;exit&lt;/code&gt;. You can close the window after that.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-09.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Now we have a disk that has a filesystem. We should be able to see the empty disk in Windows Explorer. In this example it is disk F:.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/partition-10.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Remember the drive letter 'F:'. We need it later.&lt;/p&gt;
&lt;p&gt;Optionally we can make sure the disk compresses all files. This will potentially make some more room for files.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/compress-01.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Right-click the drive in Windows Explorer and choose 'Properties'.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/compress-02.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next check 'Compress this drive to save disk space' and hit 'OK'.&lt;/p&gt;
&lt;h1&gt;Copying files&lt;/h1&gt;
&lt;p&gt;The necessary files are on the ISO in a file called 'install.wim'. We will use WimLib to extract this file to the new filesystem.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/copy-01.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;First go to your ISO and double-click it in Windows Explorer. It should open up the ISO and show the contents.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/copy-02.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Notice that it also created a drive letter for the ISO. In this example it is 'G:'. Remember this drive letter.&lt;/p&gt;
&lt;p&gt;Next we need &lt;a href=&quot;http://sourceforge.net/projects/wimlib/&quot;&gt;WimLib&lt;/a&gt;. Download and extract it to a location that you can easily access. For this example we extracted it in 'C:\WimLib'.&lt;/p&gt;
&lt;p&gt;Use the same Command Prompt as before to navigate to the WimLib directory.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/copy-03.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next we extract the contents from 'install.wim', which is on the ISO, to the disk. Here we need to use the drive letter of your phone (F: in this example) and the drive letter of the ISO (G: in this example). We instruct WimLib using &lt;code&gt;wimapply G:\sources\install.wim F:\ --strict-acls&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/copy-04.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;After quite a while it has placed all the necessary files onto the drive.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/copy-05.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next we will make sure we can boot from the drive using &lt;code&gt;bootsect /nt60 F:&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/copy-06.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;And make sure the necessary files for booting are also there &lt;code&gt;bcdboot F:\Windows /s F: /f ALL&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;All done! Now do make sure you safely remove the USB drive from Windows and unplug the USB cable.&lt;/p&gt;
&lt;h1&gt;Booting Windows&lt;/h1&gt;
&lt;p&gt;Plug in the USB cable into the PC where you want to boot. Start the PC and make sure your phone is used as the boot device.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/boot-01.jpg&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next Windows 8 will load and will do some initial setting up. After it has done this, it'll reboot. Make sure you are again booting from the phone.&lt;/p&gt;
&lt;img src=&quot;boot-windows-from-drivedroid/boot-02.jpg&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Booting a second time will actually bring you to Windows and you can configure it to your liking. Have fun!&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Custom repositories in DriveDroid</title><link /><comments>http://softwarebakery.com/custom-repositories-in-drivedroid#disqus_thread</comments><pubDate>Sun, 31 Aug 2014 09:00:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/custom-repositories-in-drivedroid</guid><description>&lt;p&gt;In recent versions of &lt;a href=&quot;http://softwarebakery.com/projects/drivedroid&quot;&gt;DriveDroid&lt;/a&gt;, custom download repositories were added. This means that, in addition to &lt;a href=&quot;http://softwarebakery.com/apps/drivedroid/distributions.html&quot;&gt;the standard set of freely available images that are already downloadable through in DriveDroid&lt;/a&gt;, you can add your own. Basically this is a way to add images to the download list and share them. This can be useful for organizations to share images in their team. In particular images that aren't freely available or images that has very specific custom tools or applications. Examples include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Windows installation disks&lt;/li&gt;
&lt;li&gt;Non-free recovery and backup tools&lt;/li&gt;
&lt;li&gt;Bios flashing utilities&lt;/li&gt;
&lt;li&gt;Custom built images&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Requirements&lt;/h2&gt;
&lt;p&gt;DriveDroid needs two parts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The images you want to share&lt;/li&gt;
&lt;li&gt;The repository file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both of these need to be hosted on a HTTP(S) webserver. However, you may host them on separate webservers.&lt;/p&gt;
&lt;p&gt;If the images are already hosted on a HTTP(S) server (and directly linkable), you only need the repository file to direct DriveDroid to them.&lt;/p&gt;
&lt;p&gt;If you have small images that you want to share with a set number of people you can use easy hosting solutions like &lt;a href=&quot;https://www.dropbox.com/help/16&quot;&gt;Dropboxs public folder&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, large images or ones that are going to be downloaded often will need your own webserver. That said, no special settings are required for this to work.&lt;/p&gt;
&lt;p&gt;In this article we will assume you have an image called &lt;code&gt;mycustomimage.iso&lt;/code&gt; and you've placed it on your webserver.&lt;/p&gt;
&lt;h2&gt;Repository file&lt;/h2&gt;
&lt;p&gt;The repository file is a JSON formatted file that links to the various images that you want to see in DriveDroid. The structure is as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[{
    &amp;quot;id&amp;quot;: &amp;quot;mycustomimages&amp;quot;,
    &amp;quot;name&amp;quot;: &amp;quot;My Custom Images&amp;quot;,
    &amp;quot;url&amp;quot;: &amp;quot;http://www.my-custom-images.org/&amp;quot;,
    &amp;quot;imageUrl&amp;quot;: &amp;quot;logos/mycustomimages.png&amp;quot;,
    &amp;quot;releases&amp;quot;: [{
        &amp;quot;version&amp;quot;: &amp;quot;1.0&amp;quot;,
        &amp;quot;url&amp;quot;: &amp;quot;images/mycustomimage.iso&amp;quot;,
        &amp;quot;size&amp;quot;: 4194304,
        &amp;quot;arch&amp;quot;: &amp;quot;amd64&amp;quot;
    }]
}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This represents a list of distributions. Each distribution has the following properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;id&lt;/code&gt; (&lt;em&gt;required&lt;/em&gt;): a unique lower-case alphanumeric identifier of the distribution&lt;/li&gt;
&lt;li&gt;&lt;code&gt;name&lt;/code&gt; (&lt;em&gt;required&lt;/em&gt;): the name (or title) of the distribution&lt;/li&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt; (&lt;em&gt;required&lt;/em&gt;): a URL to the website of the distrution. This is will show a website-button in the actionbar when the distribution is selected.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;imageUrl&lt;/code&gt; (&lt;em&gt;optional&lt;/em&gt;): a relative or absolute URL to a logo for the distribution. The file should be a 48 x 48 PNG.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;releases&lt;/code&gt; (&lt;em&gt;required&lt;/em&gt;): a list of the releases that the distribution has.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A release is essentially an image with some metadata. Each release has the following properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;url&lt;/code&gt; (&lt;em&gt;required&lt;/em&gt;): the relative or absolute url where the image is located.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;size&lt;/code&gt; (&lt;em&gt;required&lt;/em&gt;): the size of the image in bytes. This is shown as KB/MB/GB/TB in the image download list.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;version&lt;/code&gt; (&lt;em&gt;optional&lt;/em&gt;): the version of the release.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;arch&lt;/code&gt; (&lt;em&gt;optional&lt;/em&gt;): the architecture of the release.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that &lt;code&gt;version&lt;/code&gt; and &lt;code&gt;arch&lt;/code&gt; aren't shown anywhere in the GUI. At the moment they are only used for sorting (first by version, then by architecture).&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;imageUrl&lt;/code&gt; of the distribution and the &lt;code&gt;url&lt;/code&gt; of a release can both be relative as well as absolute. That means you can conveniently refer to &lt;code&gt;logos/mycustomimages.png&lt;/code&gt;, which is be relative to the repository file, instead of using the full URL.&lt;/p&gt;
&lt;p&gt;If no &lt;code&gt;imageUrl&lt;/code&gt; is given, DriveDroid will take &lt;code&gt;logos/{id}.png&lt;/code&gt; as the &lt;code&gt;imageUrl&lt;/code&gt; by default. So in the example above, leaving &lt;code&gt;imageUrl&lt;/code&gt; out would've had the same effect.&lt;/p&gt;
&lt;h2&gt;Directory structure&lt;/h2&gt;
&lt;p&gt;Although you're free to use any structure, the example above assumes a structure like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;myrepository.json&lt;/code&gt;: the repository file as described above&lt;/li&gt;
&lt;li&gt;&lt;code&gt;logos/mycustomimages.png&lt;/code&gt;: the logo for &amp;quot;My Custom Images&amp;quot;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;images/mycustomimage.iso&lt;/code&gt;: the image&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let's say you're hosting this on &lt;code&gt;http://www.my-custom-images.org/&lt;/code&gt;, then the URL for the repository would be &lt;code&gt;http://www.my-custom-images.org/myrepository.json&lt;/code&gt;. This is what you'll configure DriveDroid with.&lt;/p&gt;
&lt;h2&gt;Configure DriveDroid&lt;/h2&gt;
&lt;p&gt;To add the new repository to DriveDroid, you would do the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to Preferences&lt;/li&gt;
&lt;li&gt;Go to Image repositories&lt;/li&gt;
&lt;li&gt;Press +&lt;/li&gt;
&lt;li&gt;Enter a name of your choice, for example &amp;quot;My Custom Repository&amp;quot;&lt;/li&gt;
&lt;li&gt;Enter the URL of your repository, for example &lt;code&gt;http://www.my-custom-images.org/myrepository.json&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Press ✓ (Save)&lt;/li&gt;
&lt;li&gt;For demonstration purposes disable &amp;quot;DriveDroid main&amp;quot; and &amp;quot;DriveDroid syslinux&amp;quot;&lt;/li&gt;
&lt;li&gt;Done&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To view your new repository:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to DriveDroids main screen&lt;/li&gt;
&lt;li&gt;Press +&lt;/li&gt;
&lt;li&gt;Press &amp;quot;Download images...&amp;quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now you should see &amp;quot;My Custom Images&amp;quot; listed.&lt;/p&gt;
&lt;h2&gt;Examples&lt;/h2&gt;
&lt;p&gt;The example above is also available at &lt;code&gt;http://softwarebakery.com/apps/drivedroid/repositories/mycustomrepository.json&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For bigger examples, you can have a look at the official repositories that DriveDroids ships with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://softwarebakery.com/apps/drivedroid/repositories/main.json&quot;&gt;main.json&lt;/a&gt; (&lt;a href=&quot;http://jsonformatter.curiousconcept.com/#http://softwarebakery.com/apps/drivedroid/repositories/main.json&quot;&gt;formatted nicely&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://softwarebakery.com/apps/drivedroid/repositories/syslinux.json&quot;&gt;syslinux.json&lt;/a&gt;  (&lt;a href=&quot;http://jsonformatter.curiousconcept.com/#http://softwarebakery.com/apps/drivedroid/repositories/syslinux.json&quot;&gt;formatted nicely&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These files were generated using &lt;a href=&quot;https://github.com/FrozenCow/distscraper&quot;&gt;distscraper&lt;/a&gt;, a tool that runs periodically to scrape the various distributions for new images.&lt;/p&gt;
&lt;p&gt;The logos for these repositories are in the &lt;code&gt;logos&lt;/code&gt; subdirectory, for instance &lt;a href=&quot;http://softwarebakery.com/apps/drivedroid/repositories/logos/debian.png&quot;&gt;logos/debian.png&lt;/a&gt;.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Using Rufus to create bootable USB images</title><link /><comments>http://softwarebakery.com/using-rufus-to-create-bootable-usb-images#disqus_thread</comments><pubDate>Fri, 05 Jul 2013 18:10:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/using-rufus-to-create-bootable-usb-images</guid><description>&lt;p&gt;&lt;a href=&quot;http://rufus.akeo.ie/&quot;&gt;Rufus&lt;/a&gt; is a seemingly simple, but very excellent tool for Windows that handles a lot of work formatting USB drives and making them bootable. Most notably it can burn most ISO files to USB very efficiently. This makes it a very valuable tool for &lt;a href=&quot;http://softwarebakery.com/projects/drivedroid&quot;&gt;DriveDroid&lt;/a&gt; users.&lt;/p&gt;
&lt;p&gt;The features of Rufus I liked most:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Burns any Windows ISO (XP, 7 or 8)&lt;/li&gt;
&lt;li&gt;Burns any Linux-based ISO (ArchLinux, Ubuntu, Knoppix, etc)&lt;/li&gt;
&lt;li&gt;Burns a number of handy ISOs (Hiren's Boot CD, FreeDOS, BartPE, Ultimate Boot CD)&lt;/li&gt;
&lt;li&gt;Handles UEFI as well as legacy booting&lt;/li&gt;
&lt;li&gt;Handles GPT as well as MBR partition tables&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/pbatard/rufus&quot;&gt;Open source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This post will go through the steps of creating an image in DriveDroid and burning an ISO to that image using Rufus.&lt;/p&gt;
&lt;h2&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://rufus.akeo.ie/&quot;&gt;Rufus 1.4.9 or higher&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Android phone with &lt;a href=&quot;http://softwarebakery.com/projects/drivedroid&quot;&gt;DriveDroid&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;USB cable&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Creating a blank image in DriveDroid&lt;/h2&gt;
&lt;p&gt;The first step is creating a blank image in DriveDroid where we will burn our ISO of choice on. You will find the option 'Create blank image...' under the + menu in DriveDroid:&lt;/p&gt;
&lt;img src=&quot;using-rufus-to-create-bootable-usb-images/01-createimagemenu.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next choose a filename and a size for the image that is appropriate for the ISO you're burning. Also uncheck 'Partition Table (MBR)' and set filesystem to 'None', since Rufus will handle this for us later:&lt;/p&gt;
&lt;img src=&quot;using-rufus-to-create-bootable-usb-images/02-createimage.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;In this example we have used 1000MB to burn Windows XP. Generally you should choose a tad bit more than the side of the ISO you want to burn.&lt;/p&gt;
&lt;p&gt;Once image creation has finished you can select the image in DriveDroid.&lt;/p&gt;
&lt;img src=&quot;using-rufus-to-create-bootable-usb-images/03-selectimage.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;DriveDroid will pop up a dialog asking how to host the image. Choose the first option to host the image as a writable USB drive:&lt;/p&gt;
&lt;img src=&quot;using-rufus-to-create-bootable-usb-images/04-selectusbrw.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Now plug in your phone into your PC and start Rufus.&lt;/p&gt;
&lt;img src=&quot;using-rufus-to-create-bootable-usb-images/05-rufus.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Choose the USB device that corresponds to your phone. This is shown as NO_LABEL in Rufus.&lt;/p&gt;
&lt;p&gt;Note that when the USB device is not showing up in Rufus, click on the white triangle next to 'Format Options' and check 'List USB Hard Drives'.&lt;/p&gt;
&lt;p&gt;Check 'Create a bootable disk using:', choose 'ISO Image' from the dropdown box and click the CD-rom icon to choose the ISO you want to burn. Once the ISO is scanned by Rufus, it will fill in other options automatically.&lt;/p&gt;
&lt;p&gt;Press 'Start' to let Rufus burn the ISO to your phone and make it bootable.&lt;/p&gt;
&lt;p&gt;Once Rufus is finished you can reboot your PC and choose your phone from your bios to boot off of your newly burned ISO. Enjoy!&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Copy running Linux systems to other machines over network</title><link /><comments>http://softwarebakery.com/copy-linux-systems-over-network#disqus_thread</comments><pubDate>Thu, 20 Jun 2013 14:30:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/copy-linux-systems-over-network</guid><description>&lt;p&gt;Sometimes you want to upgrade your system to a new machine. The new machine has a new (bigger) disk, different hardware, maybe you even want a different partition layout. For these purposes it isn't sufficient to make a byte-for-byte backup, since the disk has a different size. A file-based copy is needed.&lt;/p&gt;
&lt;p&gt;In this tutorial we will do the copy over network where both the source and destination machines are connected to. We do this while the source machine is still running. That way existing processes, like apache/nginx/samba, will not get interrupted. With gigabit network cards this should also be more efficient and less time-consuming than copying disks on the same machine.&lt;/p&gt;
&lt;h2&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;A recent ArchLinux LiveCD (tested on &lt;code&gt;archlinux-2013.05.01-dual.iso&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;A running Linux system (source)&lt;/li&gt;
&lt;li&gt;Another machine that has nothing installed (destination)&lt;/li&gt;
&lt;li&gt;rsync installed on the source machine&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This tutorial will also presume the destination machine will have a basic partition layout with one disk and one ext4 partition and no swap partitions. For other partition layouts you will need to deviate from this tutorial.&lt;/p&gt;
&lt;h2&gt;General process&lt;/h2&gt;
&lt;p&gt;We will use the ArchLinux LiveCD on the destination machine to have a capable Linux system where we can setup partitions, setup ssh, login to from the source system and copy files from the source system to the destination system. Lastly we will configure the system using the tools like arch-chroot and genfstab. This may seem ArchLinux-focused, but the tools can be used to copy any other distribution as well.&lt;/p&gt;
&lt;h2&gt;Boot from LiveCD&lt;/h2&gt;
&lt;p&gt;First boot the destination machine from the ArchLinux LiveCD. Choose the architecture of your destination machine.&lt;/p&gt;
&lt;h2&gt;Setup partitions&lt;/h2&gt;
&lt;p&gt;Once booted, we'll setup the partitions on the destination system using &lt;code&gt;cfdisk&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# cfdisk /dev/sda
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Create one partition, make it bootable, write your changes and exit.&lt;/p&gt;
&lt;p&gt;Now we'll format the new partition with ext4:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# mkfs.ext4 /dev/sda1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next we'll mount the new partition so that we can later write files to it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# mount /dev/sda1 /mnt
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Setup SSH&lt;/h2&gt;
&lt;p&gt;First we want the target system to be accessible through the Live environment so that we can copy files over from the source system. We need ssh and some way to login as root.&lt;/p&gt;
&lt;p&gt;First we set a password for root using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# passwd
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next we enable sshd&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# systemctl start sshd
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We should now be able to connect through SSH from the source system to the destination machine.&lt;/p&gt;
&lt;p&gt;Check the IP address of the destination machine using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# ip addr show
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We'll presume in the rest of the tutorial the IP address of the destination machine is &lt;code&gt;192.168.1.101&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Copying files&lt;/h2&gt;
&lt;p&gt;Go to the source machine and make sure you're logged in as root.&lt;/p&gt;
&lt;p&gt;Next we will copy all files of root &lt;code&gt;/&lt;/code&gt; from the source machine over to the new partition on the destination machine &lt;code&gt;192.168.1.101&lt;/code&gt; mounted at &lt;code&gt;/mnt&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Before copying files you might want to set the root partition to be read-only. That way files will not be changed while we're copying files. This step is optional, in my experience it does not matter much, however it's still recommended to do:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# mount -o remount,ro /
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We use &lt;code&gt;rsync&lt;/code&gt; since it includes a lot of nice features to do such a copy operation easily and fast:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# rsync -xa / root@192.168.1.101:/mnt/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Accept the key of the destination PC when asked by typing &lt;code&gt;yes&lt;/code&gt;.
Type in the password you chose when using &lt;code&gt;passwd&lt;/code&gt; before.
&lt;code&gt;rsync&lt;/code&gt; will now copy all files, directories, permissions and owners over to the destination machine. It also skips all files and directories that are not on the root filesystem, like &lt;code&gt;/dev/&lt;/code&gt;, &lt;code&gt;/sys/&lt;/code&gt;. If there are filesystems that are mounted separately on the source machine and your want those copied too, use rsync again on those mountpoints too.&lt;/p&gt;
&lt;p&gt;After a while rsync will finish and the files are be copied.&lt;/p&gt;
&lt;p&gt;As a rudimentary check to see whether rsync copied everything you can use &lt;code&gt;df -h&lt;/code&gt; to see how much space is used on the root partition. Use the same command on the destination machine and the used space should be the same as the source machine. Be sure to not confuse &lt;code&gt;/&lt;/code&gt; on the source machine and &lt;code&gt;/mnt&lt;/code&gt; on the destination machine.&lt;/p&gt;
&lt;p&gt;Now you can make the root partition writable again, so normal processes can continue again:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# mount -o remount,rw /
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Setup booting&lt;/h2&gt;
&lt;p&gt;Go back to the destination machine.&lt;/p&gt;
&lt;p&gt;Since the destination machine presumably has a different disk and maybe even a different disk controller we will need fix a few things before we're able to boot on the destination machine. These are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GRUB&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/etc/fstab&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Installing and configuring GRUB&lt;/h3&gt;
&lt;p&gt;First we will install GRUB and regenerate GRUBs configuration. We do this using system we just copied over by chrooting. ArchLinux has a convenient tool that handles chroot safely:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# arch-chroot /mnt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From here we can use the tools just like we would use them on the source system. First we will regenerate GRUBs configuration:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# grub-mkconfig | tee /boot/grub/grub.cfg
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next we will install GRUB to the boot sector:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# grub-install /dev/sda
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now leave chroot by pressing Ctrl+D or typing &lt;code&gt;exit&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Generate fstab&lt;/h3&gt;
&lt;p&gt;The ArchLinux liveCD also comes with a handy tool called &lt;code&gt;genfstab&lt;/code&gt; that can generate &lt;code&gt;/etc/fstab&lt;/code&gt; for you. It'll detect what partitions are mounted and will lookup their UUID. This step should be easy:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# genfstab /mnt | tee /mnt/etc/fstab
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now everything should be setup correctly.&lt;/p&gt;
&lt;p&gt;Unmount the &lt;code&gt;/mnt&lt;/code&gt; partition using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# umount /mnt
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Booting&lt;/h2&gt;
&lt;p&gt;Before rebooting the destination machine a few notes of precaution:&lt;/p&gt;
&lt;p&gt;If you used a static IP address for the source machine, this same address will be used for the destination machine. Shut down the source machine just to be sure or change the IP address of the source or destination machine.&lt;/p&gt;
&lt;p&gt;Now reboot your destination machine and remove the ArchLinux LiveCD.&lt;/p&gt;
&lt;h3&gt;Differing disk controller&lt;/h3&gt;
&lt;p&gt;If the destination system cannot find the root partition upon booting, you will likely have a (very) different disk controller compared to the source system. Most often you will not find problems with this, so only follow this part of the guide if this is indeed the case.&lt;/p&gt;
&lt;p&gt;Support for the specific disk controller of the system is baked into initramfs: the part of the boot process that, among others, finds and mounts the root partition. The initramfs needs additional modules baked in, so we need to regenerate initramfs. This will detect what modules are needed and place those into the new initramfs.&lt;/p&gt;
&lt;p&gt;To do this we need to start with the ArchLinux LiveCD again. Mount the root partition and use chroot to get into the system:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# mount /dev/sda1 /mnt
# arch-chroot /mnt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can use the utilities of the source system again. Which utility we need to regenerate initramfs depends on the distribution that was copied.&lt;/p&gt;
&lt;p&gt;For Debian-like systems you can use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# update-initramfs -u
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For ArchLinux-like systems you can use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# mkinitcpio -p linux
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Exit chroot again using Ctrl+D or by typing &lt;code&gt;exit&lt;/code&gt;. Unmount &lt;code&gt;/mnt&lt;/code&gt; again:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# umount /mnt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And reboot the machine. It should now be able to find the root partition again.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Install Hirens Boot CD on DriveDroid</title><link /><comments>http://softwarebakery.com/install-hirensbootcd-on-drivedroid#disqus_thread</comments><pubDate>Mon, 22 Apr 2013 20:30:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/install-hirensbootcd-on-drivedroid</guid><description>&lt;p&gt;In this tutorial we will go through the process of installing Hirens Boot CD on a DriveDroid image. This is very similar to the process of installing other systems. The steps are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create a blank image in DriveDroid of reasonable size.&lt;/li&gt;
&lt;li&gt;Select the image in DriveDroid, so that it becomes available on your PC as an USB drive.&lt;/li&gt;
&lt;li&gt;Follow the instructions at &lt;a href=&quot;http://www.hiren.info/pages/bootcd-on-usb-disk&quot;&gt;Hirens Boot CDs page on how to install Hirens on a USB drive&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This also applies to other systems, but for those systems the instructions on how to install them to a USB drive will, of course, differ. In this article we will focus on install Hirens Boot CD.&lt;/p&gt;
&lt;h2&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;A phone with &lt;a href=&quot;/projects/drivedroid&quot;&gt;DriveDroid&lt;/a&gt; installed&lt;/li&gt;
&lt;li&gt;An USB cable&lt;/li&gt;
&lt;li&gt;A PC with Windows installed&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.7-zip.org/&quot;&gt;7-Zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Hirens.BootCD.15.2.zip&lt;/code&gt; from &lt;a href=&quot;http://www.hirensbootcd.org/download/&quot;&gt;hirensbootcd.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;USBFormat.zip&lt;/code&gt; from &lt;a href=&quot;http://www.hiren.info/pages/bootcd-on-usb-disk&quot;&gt;hiren.info&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;grub4dos.zip&lt;/code&gt; from &lt;a href=&quot;http://www.hiren.info/pages/bootcd-on-usb-disk&quot;&gt;hiren.info&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Creating a blank image in DriveDroid&lt;/h2&gt;
&lt;p&gt;The first step is creating a blank image in DriveDroid where we will install Hirens Boot CD on. You will find the option 'Create blank image...' under the + menu in DriveDroid:&lt;/p&gt;
&lt;img src=&quot;install-hirensbootcd-on-drivedroid/01-createimage.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next choose a filename, set the size to 650MB, uncheck 'Partition Table (MBR)' and set filesystem to 'None'. It should look like:&lt;/p&gt;
&lt;img src=&quot;install-hirensbootcd-on-drivedroid/02-createimage.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next hit create and wait for the creation process to complete. This usally takes at least a minute.&lt;/p&gt;
&lt;p&gt;Now we have a blank image. It is time to use it. You should be able to see the image in DriveDroids image list. Tap the newly created image:&lt;/p&gt;
&lt;img src=&quot;install-hirensbootcd-on-drivedroid/03-useimage.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;A dialog will popup where you can select in what mode to host the image. Your dialog might differ, but the options are from left to right:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Writable USB-disk&lt;/li&gt;
&lt;li&gt;Read-only USB-disk&lt;/li&gt;
&lt;li&gt;CD-rom disk&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On my device I have two host-devices, so I see two rows. For our purposes we want to create a USB-disk and we need the PC to be able to write to it, so we choose the first option:&lt;/p&gt;
&lt;img src=&quot;install-hirensbootcd-on-drivedroid/04-useusb.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;A USB-disk should now popup on your PC. From here on we can loosely follow the tutorial on how to install Hirens Boot CD to an USB-drive that is found on &lt;a href=&quot;http://www.hiren.info/pages/bootcd-on-usb-disk&quot;&gt;their site&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Installing Hirens Boot CD&lt;/h2&gt;
&lt;p&gt;From their tutorial we can see that we first need USBFormat. Download and extract the zip and run USBFormat as an administrator. Next look for the USB-disk in USBFormat. For me it shows up as 'Linux File-CD', but that may differ on your phone/rom/kernel. Once you have the USB-drive selected use the following settings to format the disk:&lt;/p&gt;
&lt;img src=&quot;install-hirensbootcd-on-drivedroid/05-formatusb.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Once USBFormat has finished, you'll notice that the disk now becomes available on Windows and allows you to put files on it.&lt;/p&gt;
&lt;p&gt;For the next step we need to use grub4dos. Download and extract the zip and run &lt;code&gt;grubinst_gui.exe&lt;/code&gt; as administrator. Look for the USB-disk by looking for the correct size (around 650MB) and use the following settings to install Grub4Dos onto the USB-disk:&lt;/p&gt;
&lt;img src=&quot;install-hirensbootcd-on-drivedroid/06-installgrub.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next, copy &lt;code&gt;grldr&lt;/code&gt; and &lt;code&gt;menu.lst&lt;/code&gt; from &lt;code&gt;grub4dos.zip&lt;/code&gt; to the USB-drive.&lt;/p&gt;
&lt;p&gt;Now it's time to put the rest of the files of Hirens Boot CD onto the USB-drive. First download and extract the file &lt;code&gt;Hirens.BootCD.15.2.zip&lt;/code&gt; from &lt;a href=&quot;http://www.hirensbootcd.org/download/&quot;&gt;their download page&lt;/a&gt;. You should see an ISO file named &lt;code&gt;Hiren's.BootCD.15.2.iso&lt;/code&gt;. We will use 7-zip to extract the files from the ISO to the USB-disk. Click with right mouse on the ISO, choose 7-Zip and 'Extract files...':&lt;/p&gt;
&lt;img src=&quot;install-hirensbootcd-on-drivedroid/07-extractiso.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next enter the location of the USB-disk (use Browse if you aren't sure). Extraction will take several minutes.&lt;/p&gt;
&lt;p&gt;When the extaction process is finished you should have the following files on your USB-disk:&lt;/p&gt;
&lt;img src=&quot;install-hirensbootcd-on-drivedroid/08-usbcontent.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Finally, make sure to safely remove the USB-disk from Windows. This is to ensure all data is being written to the disk (which is usually cached by Windows for a while). After doing so, open up DriveDroid on your phone and tap the image again. Now instead of using the first option, choose the USB-disk in read-only mode (the padlocked USB icon). This will ensure the USB-disk cannot change whenever the image is hosted in this mode. If you ever want to write some files onto the disk, choose writable USB-disk-mode.&lt;/p&gt;
&lt;p&gt;Now reboot your PC. It should now be able to boot Hirens Boot CD from your phone. Enjoy!&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Shrinking images on Linux</title><link /><comments>http://softwarebakery.com/shrinking-images-on-linux#disqus_thread</comments><pubDate>Thu, 21 Feb 2013 14:53:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/shrinking-images-on-linux</guid><description>&lt;p&gt;When creating images from existing ISOs you often need to allocate a number of MB for the image to &lt;em&gt;at least&lt;/em&gt; fit the files that are in the ISO. Predicting the exact size of the image is hard, even for a program. In this case you will create an image that is larger than actually needed: the image is much larger than the files on the image are combined.&lt;/p&gt;
&lt;p&gt;This post will show how to shrink an existing image to a more optimal size. We will do this on Linux, since all required tools are available there: GParted, &lt;code&gt;fdisk&lt;/code&gt; and &lt;code&gt;truncate&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;Requirements&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;A Linux PC&lt;/li&gt;
&lt;li&gt;Some knowledge how the terminal works will helps&lt;/li&gt;
&lt;li&gt;The unoptimal image (&lt;code&gt;myimage.img&lt;/code&gt; in this example)&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Creating loopback device&lt;/h1&gt;
&lt;p&gt;GParted is a great application that can handle partition tables and filesystems quite well. In this tutorial we will use GParted to shrink the filesystem (and its accompaning partition in the partition table).&lt;/p&gt;
&lt;p&gt;GParted operates on devices, not simple files like images. This is why we first need to create a device for the image. We do this using the loopback-functionality of Linux.&lt;/p&gt;
&lt;p&gt;First we will enable loopback if it wasn't already enabled:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sudo modprobe loop
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can request a new (free) loopback device:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sudo losetup -f
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will return the path to a free loopback device. In this example this is &lt;code&gt;/dev/loop0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Next we create a device of the image:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sudo losetup /dev/loop0 myimage.img
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we have a device &lt;code&gt;/dev/loop0&lt;/code&gt; that represents &lt;code&gt;myimage.img&lt;/code&gt;. We want to access the partitions that are on the image, so we need to ask the kernel to load those too:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sudo partprobe /dev/loop0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This should give us the device &lt;code&gt;/dev/loop0p1&lt;/code&gt;, which represents the first partition in &lt;code&gt;myimage.img&lt;/code&gt;. We do not need this device directly, but GParted requires it.&lt;/p&gt;
&lt;h1&gt;Resize partition using GParted&lt;/h1&gt;
&lt;p&gt;Next we can load the device using GParted:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sudo gparted /dev/loop0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This should show a window similar to the following:&lt;/p&gt;
&lt;img src=&quot;shrinking-images-on-linux/gparted-01.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Now notice a few things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;There is one partition.&lt;/li&gt;
&lt;li&gt;The partition allocates the entire disk/device/image.&lt;/li&gt;
&lt;li&gt;The partition is filled partly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We want to resize this partition so that is fits it content, but not more than that.&lt;/p&gt;
&lt;p&gt;Select the partition and click Resize/Move. A window similar to the following will popup:&lt;/p&gt;
&lt;img src=&quot;shrinking-images-on-linux/gparted-02.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Drag the right bar to the left as much as possible.&lt;/p&gt;
&lt;p&gt;Note that sometimes GParted will need a few MB extra to place some filesystem-related data. You can press the up-arrow at the &lt;em&gt;New size&lt;/em&gt;-box a few times to do so. For example, I pressed it 10 times (=10MiB) for FAT32 to work. For NTFS you might not need to at all.&lt;/p&gt;
&lt;p&gt;Finally press &lt;em&gt;Resize/Move&lt;/em&gt;. You will return to the GParted window. This time it will look similar to the following:&lt;/p&gt;
&lt;img src=&quot;shrinking-images-on-linux/gparted-03.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Notice that there is a part of the disk &lt;em&gt;unallocated&lt;/em&gt;. This part of the disk will not be used by the partition, so we can shave this part off of the image later. GParted is a tool for disks, so it doesn't shrink images, only partitions, we have to do the shrinking of the image ourselves.&lt;/p&gt;
&lt;p&gt;Press &lt;em&gt;Apply&lt;/em&gt; in GParted. It will now move files and finally shrink the partition, so it can take a minute or two, most of the time it finishes quickly. Afterwards close GParted.&lt;/p&gt;
&lt;p&gt;Now we don't need the loopback-device anymore, so unload it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ sudo losetup -d /dev/loop0
&lt;/code&gt;&lt;/pre&gt;
&lt;h1&gt;Shaving the image&lt;/h1&gt;
&lt;p&gt;Now that we have all the important data at the beginning of the image it is time to shave of that unallocated part. We will first need to know where our partition ends and where the unallocated part begins. We do this using &lt;code&gt;fdisk&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ fdisk -l myimage.img
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we will see an output similar to the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Disk myimage.img: 6144 MB, 6144000000 bytes, 12000000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ea37d

      Device Boot      Start         End      Blocks   Id  System
myimage.img1            2048     9181183     4589568    b  W95 FAT32
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note two things in the output:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The partition ends on block 9181183 (shown under &lt;code&gt;End&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The block-size is 512 bytes (shown as &lt;code&gt;sectors of 1 * 512&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will use these numbers in the rest of the example. The block-size (512) is often the same, but the ending block (9181183) will differ for you. The numbers mean that the parition ends on byte 9181183*512 of the file. After that byte comes the unallocated-part. Only the first 9181183*512 bytes will be useful for our image.&lt;/p&gt;
&lt;p&gt;Next we shrink the image-file to a size that can just contain the partition. For this we will use the &lt;code&gt;truncate&lt;/code&gt; command (thanks uggla!). With the truncate command need to supply the size of the file in bytes. The last block was 9181183 and block-numbers start at 0. That means we need (9181183+1)*512 bytes. This is important, else the partition will not fit the image. So now we use truncate with the calculations:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ truncate --size=$[(9181183+1)*512] myimage.img
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now copy the new image over to your phone, where it should act exactly the same as the old/big image.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Windows installation on DriveDroid</title><link /><comments>http://softwarebakery.com/windows-install-on-drivedroid#disqus_thread</comments><pubDate>Fri, 25 Jan 2013 11:31:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/windows-install-on-drivedroid</guid><description>&lt;p&gt;&lt;em&gt;Update&lt;/em&gt;: Rufus is now the recommended to write Windows installation ISOs to DriveDroid and other USB drives. Please refer to &lt;a href=&quot;/using-rufus-to-create-bootable-usb-images&quot;&gt;Using Rufus to create bootable USB images&lt;/a&gt;. The tutorial below still explains in more detailed steps how the same thing is done using more low-level tools.&lt;/p&gt;
&lt;p&gt;In version v0.7.0 of &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid&quot;&gt;DriveDroid (Free)&lt;/a&gt; and &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid.paid&quot;&gt;DriveDroid (Paid)&lt;/a&gt; a feature has been added to create blank images that look like normal USB disks. This allows you to use tools on your PC to fill the blank USB disk with whatever you want.&lt;/p&gt;
&lt;p&gt;In this post I will show how to create a Windows 7 installation disk that can be booted from your phone with DriveDroid. The disk will be made using files of the official Windows 7 ISO.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/laptopmobile.jpg&quot; class=&quot;box&quot; /&gt;
&lt;h1&gt;Requirements&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;DriveDroid v0.7.0+&lt;/li&gt;
&lt;li&gt;4GB free space on your Android phone&lt;/li&gt;
&lt;li&gt;A PC with Windows 7 and 7-zip installed&lt;/li&gt;
&lt;li&gt;Diskpart utility (installed by default on Windows 7)&lt;/li&gt;
&lt;li&gt;A Windows 7 installation disk or ISO&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note that on some systems &lt;a href=&quot;http://support.microsoft.com/kb/300415&quot;&gt;diskpart&lt;/a&gt; is not installed. I installed it seperately &lt;a href=&quot;http://download.microsoft.com/download/win2000platform/DiskPart/1.00.0.1/NT5/EN-US/diskpart_setup.exe&quot;&gt;using the diskpart setup&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;Image creation&lt;/h1&gt;
&lt;p&gt;First hook up your phone to your PC using a USB cable.&lt;/p&gt;
&lt;p&gt;Next we'll have to create a blank image on your phone. On this image we will eventually store the installation disk. In DriveDroid we go to the + button and choose 'Create blank image...'.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/drivedroid01.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Choose a filename like 'windows7.img' and choose 3500MB as the size for the image. You can uncheck 'Partition table (MBR)' and choose 'None' for the filesystem. Now hit the 'Create' button on the top-right.&lt;/p&gt;
&lt;p&gt;As a side-note, we choose to not create a partition table and filesystem here because DriveDroid does not support formatting NTFS filesystems. NTFS is required for the Windows 7 installer to work. We will partition and format the image from your PC in Windows, but we'll get to that.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/drivedroid02.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;This will create the image file in the background. Open the notification-bar to see when the image creation is finished. Most time will be used by 'Allocating file...', which creates a 3500MB file. This can take half an hour or so on most devices that have a FAT-32 filesystem on their SD-card, other filesystems do not seem to have this problem and will finish almost instantly.&lt;/p&gt;
&lt;p&gt;It is recommended not to do anything else on your phone while the image is being created. At the moment the image creation process can be killed by Android when there isn't enough memory available on the device to launch other applications. I still need to figure out how to avoid this.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/drivedroid03.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Once the image is created go to DriveDroid.&lt;/p&gt;
&lt;h1&gt;Partitioning and formatting&lt;/h1&gt;
&lt;p&gt;Select the image in DriveDroid and click the option that says '(read-write)'. As soon as we have done that, Windows will find a new USB drive. A window will popup in Windows asking to format the drive.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/01.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Choose 'Cancel': this method of formatting is not compatible with a Windows 7 install disk, since it'll not create a partition table and bootsector. Thus it will not boot using this option. We will partition and format the disk properly using diskpart.&lt;/p&gt;
&lt;p&gt;Go to start and type &lt;code&gt;cmd.exe&lt;/code&gt;. Command prompt will open.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/02.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Start diskpart by typing &lt;code&gt;diskpart&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/03.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Show the connected disks by typing &lt;code&gt;list disk&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/04.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;You will see that the image you just created in DriveDroid is listed here as a disk of 3500MB. In this example it is listed as Disk 3.&lt;/p&gt;
&lt;p&gt;To work on disk 3, we need to select it by typing &lt;code&gt;select disk 3&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/05.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next we create a partition table and fill the bootsector by typing &lt;code&gt;clean&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/06.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Now we can create a partition by typing &lt;code&gt;create partition primary&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/07.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;The partition hasn't got a filesystem yet. For the Windows 7 install disk we need a NTFS filesystem. We can format a NTFS filesystem on the partition by typing &lt;code&gt;format fs=ntfs quick&lt;/code&gt;. This will take a few seconds to a minute or so.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/08.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Now we have a bootsector, partition table, partition and filesystem. We only have to mark the partition as 'bootable' to be able to boot from it. We do this by typing &lt;code&gt;active&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/09.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Finally we leave diskpart by typing &lt;code&gt;exit&lt;/code&gt;. You can close the window after that.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/10.png&quot; class=&quot;box&quot; /&gt;
&lt;h1&gt;Copying files&lt;/h1&gt;
&lt;p&gt;Now we have a disk that has a filesystem and can be booted from. We should be able to  see the empty disk in 'My Computer'. In this example it is disk G:.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/11.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Next we need to copy files from the official Windows 7 installation CD to the USB drive. If you have the CD at hand, you can just copy those files over.&lt;/p&gt;
&lt;p&gt;However, since I only have an ISO file I need to extract the ISO to the USB drive. We can do this using 7-zip. Go to the Windows 7 ISO using Windows Explorer. Right click the ISO file, choose &lt;code&gt;7-Zip&lt;/code&gt; and choose &lt;code&gt;Extract files...&lt;/code&gt;.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/12.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Choose G:\ as the destination to extract the files to and hit OK.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/13.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Extracting the files will take a while.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/14.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Once the files are extracted the contents of your disk should look similar to this.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/15.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;We are finished. The disk should be usable and is stored in &lt;code&gt;windows7.img&lt;/code&gt; on your Android phone. If you want to try it on another PC, first safely remove the disk by left clicking the icon in your system tray.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/16.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;And choosing your phone from the menu. In my case it is GT-I9000 (Samsung Galaxy S).&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/17.png&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Unplug your USB cable and plug it in a PC where you want to install Windows 7. Make sure you still have &lt;code&gt;windows7.img&lt;/code&gt; selected in DriveDroid.&lt;/p&gt;
&lt;p&gt;Boot the other PC, go to the bios and put your phone as the first boot device.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/18.jpg&quot; class=&quot;box&quot; /&gt;
&lt;p&gt;Save the changes and reboot. The PC should now boot the Windows 7 installer from your phone.&lt;/p&gt;
&lt;img src=&quot;windows-install-on-drivedroid/19.jpg&quot; class=&quot;box&quot; /&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>DriveDroid 0.7.0 released</title><link /><comments>http://softwarebakery.com/drivedroid-0-7-0-released#disqus_thread</comments><pubDate>Sun, 20 Jan 2013 21:01:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/drivedroid-0-7-0-released</guid><description>&lt;p&gt;Version 0.7.0 of &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid&quot;&gt;DriveDroid (Free)&lt;/a&gt; and &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid.paid&quot;&gt;DriveDroid (Paid)&lt;/a&gt; is just released. This version comes with quite a few changes. Here is the changelog:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Added 'Create blank image' to create an empty/FAT32 disk-image&lt;/li&gt;
&lt;li&gt;Improved USB Mass Storage option&lt;/li&gt;
&lt;li&gt;Improved support emails&lt;/li&gt;
&lt;li&gt;Option to check for USB Mass Storage&lt;/li&gt;
&lt;li&gt;Changed menu structure for creating/adding/downloading images&lt;/li&gt;
&lt;li&gt;Added support for HTC Sensation, Samsung GT-S5360 and HDC i9300&lt;/li&gt;
&lt;li&gt;Fixed crash when going to preferences without root&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Create blank image&lt;/h2&gt;
&lt;p&gt;The biggest feature is the ability to create blank images from within DriveDroid. You can specify the size that you want the USB-disk to have and DriveDroid can format a FAT-32 filesystem on it (big thanks to &lt;a href=&quot;http://code.google.com/p/fat32-lib/&quot;&gt;fat32-lib&lt;/a&gt;). Once you select the image you'll see an empty USB-disk on your PC where you can store files.&lt;/p&gt;
&lt;p&gt;One advantage of this system is not just being able to store files, but to be able to use any tool on your PC to create bootable USB drives. In the past a number of ISOs were not loadable by DriveDroid, because those weren't USB compatible. Now you can use tools like &lt;a href=&quot;http://www.microsoftstore.com/store/msstore/html/pbPage.Help_Win7_usbdvd_dwnTool&quot;&gt;Windows 7 USB/DVD download tool&lt;/a&gt;, &lt;a href=&quot;http://unetbootin.sourceforge.net/&quot;&gt;UNetBootin&lt;/a&gt;, &lt;a href=&quot;https://launchpad.net/win32-image-writer&quot;&gt;Image Writer&lt;/a&gt; or just &lt;a href=&quot;http://linux.die.net/man/1/dd&quot;&gt;dd&lt;/a&gt; to write images or ISOs to a disk you created+hosted using DriveDroid.&lt;/p&gt;
&lt;h2&gt;Compatiblity&lt;/h2&gt;
&lt;p&gt;I've also tried to support devices that do not have USB Mass Storage by default. Use the 'USB Mass Storage (UMS)'-option in the preferences of DriveDroid to enable UMS. It will use the normal way of enabling UMS, but will try to detect whether this does not work and use other methods to enable it. Hopefully this will work for some devices.&lt;/p&gt;
&lt;p&gt;For anyone who still has trouble, please send me a support email through the preferences of DriveDroid. Support emails now contain more information, so it should have a better chance of solving the problem.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>DriveDroid 0.6.2 released</title><link /><comments>http://softwarebakery.com/drivedroid-0-6-2-released#disqus_thread</comments><pubDate>Sun, 09 Dec 2012 21:13:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/drivedroid-0-6-2-released</guid><description>&lt;p&gt;Since the first release of DriveDroid (version 0.5) much has changed. This post summarizes the changes from 0.5 till 0.6.2.&lt;/p&gt;
&lt;h2&gt;Distributions&lt;/h2&gt;
&lt;p&gt;A number of new distributions are now available in the downloadlist:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Arch Linux&lt;/li&gt;
&lt;li&gt;Crunchbang&lt;/li&gt;
&lt;li&gt;Debian&lt;/li&gt;
&lt;li&gt;Fedora&lt;/li&gt;
&lt;li&gt;FreeBSD&lt;/li&gt;
&lt;li&gt;GeeXboX&lt;/li&gt;
&lt;li&gt;Gentoo&lt;/li&gt;
&lt;li&gt;Grml&lt;/li&gt;
&lt;li&gt;OpenSUSE&lt;/li&gt;
&lt;li&gt;SliTaz&lt;/li&gt;
&lt;li&gt;Tails&lt;/li&gt;
&lt;li&gt;Ubuntu&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For &lt;a href=&quot;https://github.com/FrozenCow/distscraper/tree/master/scrapers&quot;&gt;a recent list of distributions&lt;/a&gt; take a look &lt;a href=&quot;https://github.com/FrozenCow/distscraper&quot;&gt;distscraper&lt;/a&gt;, which retrieves the different downloadable image-urls.&lt;/p&gt;
&lt;p&gt;The downloadlist now also includes logos of the distributions. The logos are retrieved and slightly altered using &lt;a href=&quot;https://github.com/FrozenCow/distscraper/blob/master/retrievelogos.sh&quot;&gt;a script in distscraper&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Compatiblity&lt;/h2&gt;
&lt;p&gt;Support for the different devices has been improved greately by adding support for hosting iso/img files for 5 new devices/ROMs. There were also a lot of different little incompatiblities between the different Android versions, which now show appropriate messages when a particular feature is not supported on the device.&lt;/p&gt;
&lt;h2&gt;Paid version&lt;/h2&gt;
&lt;p&gt;Last but not least, there is now a paid (no-ads) version available &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.softwarebakery.drivedroid.paid&quot;&gt;on the Play Store&lt;/a&gt;. No extra features are added to the paid version at the moment, though it always helps development.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>DriveDroid 0.5 released!</title><link /><comments>http://softwarebakery.com/drivedroid-released#disqus_thread</comments><pubDate>Mon, 12 Nov 2012 19:13:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/drivedroid-released</guid><description>&lt;p&gt;DriveDroid allows you to boot your PC from ISO/IMG files stored on your phone. This is ideal for trying Linux distributions or always having a rescue-system on the go... without the need to burn CDs or USB pendrives.&lt;/p&gt;
&lt;p&gt;DriveDroid also includes a convenient download menu where you can select a popular distibution to download and use.&lt;/p&gt;
&lt;h2&gt;How do you make this work?&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Connect your phone to your PC using an USB cable&lt;/li&gt;
&lt;li&gt;Download an image file (.iso or .img) through DriveDroid or download them manually&lt;/li&gt;
&lt;li&gt;Select the image file in DriveDroid to let your phone 'host' the file over USB&lt;/li&gt;
&lt;li&gt;(Re)start your PC and make sure the correct boot priority is set in the bios&lt;/li&gt;
&lt;li&gt;The image should now be booted on your PC&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Root&lt;/li&gt;
&lt;li&gt;USB cable (from phone to PC)&lt;/li&gt;
&lt;li&gt;USB Mass Storage-support should be enabled on your ROM (being able to mount SD card)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Notes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Some .iso files do not support being booted over USB, but most popular distibutions are. All images that are downloadable through DriveDroid are supported.&lt;/li&gt;
&lt;li&gt;All .img files should work fine.&lt;/li&gt;
&lt;li&gt;It is recommended to download distributions over wifi: those files are big!&lt;/li&gt;
&lt;li&gt;Do NOT use DriveDroid while your SD card is mounted (being used on your PC). This can cause loss of data.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The downloads that DriveDroid provides are gathered using &lt;a href=&quot;http://github.com/FrozenCow/distscraper&quot;&gt;distscraper&lt;/a&gt;. If you want other distributions to be includes in the list, please &lt;a href=&quot;https://github.com/FrozenCow/distscraper/issues&quot;&gt;open up an issue&lt;/a&gt; or do a pull request.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Recovering commits with Git</title><link /><comments>http://softwarebakery.com/recovering-commits-with-git#disqus_thread</comments><pubDate>Fri, 13 Jan 2012 20:42:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/recovering-commits-with-git</guid><description>&lt;p&gt;Git is pretty powerful. With this power it allows you to do amazing things. Recently I've come to realize that you can hurt yourself pretty badly with its powers. Operations like resetting and fast-forwarding are dangarous and should be used with care.&lt;/p&gt;
&lt;p&gt;Today I did not handle them with care and commits seemed to be lost. Luckily I found that Git does not delete commits. My lost commits were just not referenced by any branch or tag, but were 'dangling'. The problem is finding these commits back.&lt;/p&gt;
&lt;p&gt;I found two possible commands that helped me find my lost commits: &lt;code&gt;git reflog&lt;/code&gt; and &lt;code&gt;git fsck --lost-found&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Reflog&lt;/h3&gt;
&lt;p&gt;This command shows the history of operations you have done on your repository. Each operation is shown with the hash of the commit that it results in. As an example we will create a repository, commit a change, 'lose' the commit and find it back using &lt;code&gt;git reflog&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;First we create a test repository:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ mkdir myrepo
$ cd myrepo
$ git init
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Next we'll commit a file with some text:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ echo some text in a file &amp;gt; file
$ git add file
$ git commit -m &amp;quot;My first change&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we'll make a change to the file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ echo other text in a file &amp;gt; file
$ git commit file -m &amp;quot;Another change to file&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can see the current commits in the log:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git log --oneline
fd9e098 Another change to file
98b88cc My first change
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we make our mistake and reset to the first commit:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git reset --hard HEAD~1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Our second commit is now 'lost'. We can see that the file does not match the latest change we made and the log does not show our latest commit anymore:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ cat file
some text in a file
$ git log --oneline
98b88cc My first change
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Presume we haven't done the previous logs and don't know the hash of the latest commit that we have done. We can see the operations we did using reflog:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git reflog
98b88cc HEAD@{0}: reset: moving to HEAD~1
fd9e098 HEAD@{1}: commit: Another change to file
98b88cc HEAD@{2}: commit (initial): My first change
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Two commits and a reset, that seems to fit with what we did. Commit 'fd9e098' seems to be the one we're missing. We can take a look at the history of that commit to get a better understanding whether it really is the right one:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git log fd9e098 --oneline
fd9e098 Another change to file
98b88cc My first change
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This seems to be in line with what we previously saw, so now we want to get back that last commit. We have the option to just reset our history to that commit by using &lt;code&gt;git reset --hard&lt;/code&gt;:.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git reset --hard fd9e098
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The history is now the same as before:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git log
fd9e098 Another change to file
98b88cc My first change
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you weren't sure it was the right commit yet, you can do a checkout of the commit before resetting to look at its files more easily:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git checkout fd9e098
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Though do remember to checkout to your previous branch when you're done going through its files:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git checkout master
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Lost and found&lt;/h3&gt;
&lt;p&gt;Instead of using &lt;code&gt;git reflog&lt;/code&gt; to find your lost commits, you can also use Git's fsck to find 'dangling' commits for you. If we go back to our example we can do a reset again to 'lose' our latest commit:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git reset --hard 98b88cc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now if we issue the lost and found command. It'll return the dangling commit(s) that were lost:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git fsck --lost-found
dangling commit fd9e0982eaf3d8589aac26f0c6a52be5741ee8f7
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can do the same as before and reset to that commit:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git reset --hard fd9e0982eaf3d8589aac26f0c6a52be5741ee8f7
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now the history is restored and the files are of the latest commit.&lt;/p&gt;
&lt;h3&gt;Garbage collection&lt;/h3&gt;
&lt;p&gt;Even though the dangling commits exist at this time, they will be removed after a garbage collection. Git automatically does this for files that are 2 weeks old. Garbage collection can also be disabled by using the configuration value &lt;code&gt;gc.auto&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git config --global gc.auto 0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To do garbage collections manually you could use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ git gc
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;More information on this can be found on &lt;a href=&quot;http://linux.die.net/man/1/git-gc&quot;&gt;git-gc manual page&lt;/a&gt;.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Setting up an infinote server with PAM</title><link /><comments>http://softwarebakery.com/infinote-server-with-pam#disqus_thread</comments><pubDate>Tue, 12 Jul 2011 20:42:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/infinote-server-with-pam</guid><description>&lt;p&gt;&lt;a href=&quot;http://gobby.0x539.de/&quot;&gt;Gobby&lt;/a&gt; is a multi-user text editor. It allows editing text files by multiple persons, while all of them can see and edit in real-time. It is a great tool for online collaboration, like making todos or even coding a program collaboratively.&lt;/p&gt;
&lt;p&gt;Gobby connects to an &lt;a href=&quot;http://gobby.0x539.de/trac/wiki/Infinote/Infinoted&quot;&gt;infinote&lt;/a&gt; server. The server keeps track of the different users and documents.&lt;/p&gt;
&lt;p&gt;On Ubuntu 10.04 infinoted 0.4.1-1 is already in the repository and it is easy to set up. However, such a setup does not include username and password authentication, an automatic startup using a init-script and a separate user under which the process should run. Authentication using PAM, and thus username and password, is only available since 0.5.0.&lt;/p&gt;
&lt;p&gt;This post contains all of the steps required to run infinoted 0.5.0 on Ubuntu 10.04. This includes compiling, creating the user, init-script and configuration necessary to run infinoted in a proper way.&lt;/p&gt;
&lt;h3&gt;Compiling infinoted with PAM support&lt;/h3&gt;
&lt;p&gt;Since PAM is an optional dependency for infinoted you should make sure that &lt;code&gt;libpam-dev&lt;/code&gt; is installed before compiling. The configure script does not provide you with any notification of its absence (this will be fixed in a &lt;a href=&quot;http://git.0x539.de/?p=infinote.git;a=commit;h=42e314a4af31126342aac8d5e9e3fd633630f0d4&quot;&gt;later version&lt;/a&gt;). You should also make sure &lt;code&gt;libdaemon-dev&lt;/code&gt; is installed, otherwise the initscript will not work properly. After that, compilation is rather straightforward:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ apt-get install libxml2-dev gnutls-dev libgsasl7-dev libglib2.0-dev libpam-dev libdaemon-dev
$ wget http://releases.0x539.de/libinfinity/libinfinity-0.5.0.tar.gz
$ tar xfvz libinfinity-0.5.0.tar.gz
$ cd libinfinity-0.5.0
$ ./configure --prefix=/usr
$ make
$ make install
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you are on Ubuntu and want to make a deb package, you can replace the last command (&lt;code&gt;make install&lt;/code&gt;) by &lt;code&gt;checkinstall&lt;/code&gt; and answer the questions that follow. Make sure you install checkinstall first:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ apt-get install checkinstall
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you've created the package, you can install it using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ dpkg -i infinoted-0.5.0-1.deb
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Configuring infinoted&lt;/h3&gt;
&lt;p&gt;We'll run the server as a seperate (less privileged) user instead of as root, so we start by creating a new user. The user's home directory will be &lt;strong&gt;/var/infinote&lt;/strong&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ useradd --home-dir /var/infinote --user-group --shell /bin/false infinote
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Before we can start the server we have to create a home directory, a place to store the documents and its configuration. The server looks for the configuration file &lt;code&gt;$HOME/.config/infinoted.conf&lt;/code&gt;. We create the directories and set the appropriate permissions on them using the following commands:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ mkdir /var/infinote/{,root,sync,.config}
$ touch /var/infinote/.config/infinoted.conf
$ chown -R infinote: /var/infinote
$ chmod -R 0700 /var/infinote
$ chmod 0600 /var/infinote/.config/infinoted.conf
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can fill &lt;em&gt;infinoted.conf&lt;/em&gt; with the following configuration:&lt;/p&gt;
&lt;p&gt;&lt;h5 class='code-link'&gt;/var/infinote/.config/infinoted.conf&lt;/h5&gt;
[infinoted]
security-policy=require-tls
root-directory=/var/infinote/root/
certificate-file=/var/infinote/cert.pem
key-file=/var/infinote/key.pem
sync-directory=/var/infinote/sync/
sync-interval=60
pam-service=infinote&lt;/p&gt;
&lt;h4&gt;Generating a certificate&lt;/h4&gt;
&lt;p&gt;You might have noticed a reference to the &lt;strong&gt;cert.pem&lt;/strong&gt; and &lt;strong&gt;key.pem&lt;/strong&gt; files. These allow the connection to be encrypted. We haven't created them yet, so we'll do that now. The creation of the certificate requires quite a lot of &lt;a href=&quot;http://en.wikipedia.org/wiki/Entropy_(computing)&quot;&gt;entropy&lt;/a&gt;. If your machine runs out of entropy this can make the entire process take a very long time. To solve this you could try to generate more entropy by moving your mouse or typing on the keyboard. On a server which has no such peripherals this will obviously not work, so you might have to create the certificate somewhere else and copy it over to the server. Another thing to look out for is the fact that the certificate (cert.pem) will be bound to a domain name. This is determined by the hostname of the computer generating the certificate, so you might have to change it temporarily.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ hostname your_temporary_hostname # optional, don't forget to restore afterwards
$ cd /var/infinote
$ sudo -u infinote infinoted-0.5 -k key.pem -c cert.pem --create-key --create-certificate
$ chown 0600 key.pem cert.pem
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Authentication using PAM&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;http://gobby.0x539.de/trac/wiki/Infinote/Infinoted&quot;&gt;documentation of infinoted&lt;/a&gt; shows the option to setup PAM but gives no hints on how to do it. There are multiple ways to setup PAM authentication with infinoted. We chose to use the &lt;a href=&quot;http://cpbotha.net/software/pam_pwdfile/&quot;&gt;pam_pwdfile&lt;/a&gt; authentication module. This allows you to define users and passwords in a flat text file, so that you do not need to create full system users for them. So you need to &lt;code&gt;apt-get install libpam-pwdfile&lt;/code&gt;. Since all users that are in this file are solely created for use with infinote we will use the module &lt;a href=&quot;http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/sag-pam_permit.html&quot;&gt;pam_permit&lt;/a&gt; to forgo account management.&lt;/p&gt;
&lt;p&gt;We start by creating a new PAM service in the &lt;code&gt;/etc/pam.d/&lt;/code&gt; directory called &lt;code&gt;infinote&lt;/code&gt; and use the following as its contents:
&lt;h5 class='code-link'&gt;/etc/pam.d/infinote&lt;/h5&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#%PAM-1.0
auth      required    pam_pwdfile.so pwdfile /etc/infinoted.passwd
account   required    pam_permit.so
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we have to create the file that defines users and their passwords, we have chose to place it at &lt;code&gt;/etc/infinoted.passwd&lt;/code&gt;. The file should contain username:password_hash pairs. The password hashes can be generated using any of the following commands:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ openssl passwd -1 &amp;lt;password&amp;gt;
$ openssl passwd -crypt &amp;lt;password&amp;gt;
$ htpasswd -nbd &amp;lt;username&amp;gt; &amp;lt;password&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that both of the available hashing methods are rather weak, so don't count on these hashes to provide you with any security. After having created the hashes for your passwords, your password file should look something like this:&lt;/p&gt;
&lt;p&gt;&lt;h5 class='code-link'&gt;/etc/infinoted.passwd&lt;/h5&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;maato:$1$yII45doY$ZSH/biluHy12zp9KOuEQ9/
frozencow:SiN2d/00c/ubI
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Creating an init script&lt;/h3&gt;
&lt;p&gt;To automatically (and easily) start and stop the infinote daemon, we will need an init-script. We placed the code below in &lt;code&gt;/etc/init.d/infinoted&lt;/code&gt;. Make sure to also run &lt;code&gt;chmod +x /etc/init.d/infinoted&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;h5 class='code-link'&gt;/etc/init.d/infinoted&lt;/h5&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#! /bin/sh
### BEGIN INIT INFO
# Provides:          infinoted
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts infinoted
# Description:       starts infinoted using start-stop-daemon
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/infinoted-0.5
USER=infinote
NAME=infinoted
PIDFILE=/var/infinote/.infinoted/infinoted-0.5.pid
DESC=&amp;quot;Infinote Daemon&amp;quot;

test -x $DAEMON || exit 0

if [ -f /etc/default/infinoted ] ; then
        . /etc/default/infinoted
fi

set -e

. /lib/lsb/init-functions

# Function that starts the daemon
d_start() {
        log_daemon_msg &amp;quot;Starting $DESC&amp;quot; &amp;quot;$NAME&amp;quot;
        start-stop-daemon --quiet -c $USER -p $PIDFILE -x $DAEMON --start -- -d
        log_end_msg $?
}

# Function that stops the daemon
d_stop() {
        log_daemon_msg &amp;quot;Stopping $DESC&amp;quot; &amp;quot;$NAME&amp;quot;
        start-stop-daemon --quiet -c $USER -p $PIDFILE -x $DAEMON --stop -- -D
        log_end_msg $?
}

case &amp;quot;$1&amp;quot; in
  start)
        d_start
        ;;
  stop)
        d_stop
        ;;
  restart)
        log_daemon_msg &amp;quot;Restarting $DESC&amp;quot; &amp;quot;$NAME&amp;quot;
        d_stop || true
        sleep 1
        d_start
        log_daemon_msg &amp;quot;Done&amp;quot;
        ;;
  status)
        status_of_proc -p $PIDFILE &amp;quot;$DAEMON&amp;quot; infinoted &amp;amp;&amp;amp; exit 0 || exit $?
        ;;
  *)
        log_daemon_msg &amp;quot;Usage: $NAME {start|stop|restart|status}&amp;quot; &amp;gt;&amp;amp;2
        exit 1
        ;;
esac

exit 0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;###Additional information###&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;pam-pwdfile &lt;a href=&quot;http://code.google.com/p/pam-pwdfile/source/browse/trunk/README&quot;&gt;README&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description><author>maato@softwarebakery.com (Maato)</author></item><item><title>Wii Device Library v1.2 released</title><link /><comments>http://softwarebakery.com/wii-device-library-v1-2-released#disqus_thread</comments><pubDate>Fri, 01 May 2009 22:00:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/wii-device-library-v1-2-released</guid><description>&lt;p&gt;Here is another release of &lt;a href=&quot;/project/wiidevicelibrary&quot;&gt;Wii Device Library&lt;/a&gt;. This version fixes even more bugs and adds some more stablity. The major changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Balanceboards are now also supported under Windows.&lt;/li&gt;
&lt;li&gt;All stacks are more stable (*).&lt;/li&gt;
&lt;li&gt;Fixed support for Bluez v3.2.1 on x64 machines.&lt;/li&gt;
&lt;li&gt;Fixed some issues for the Windows and Linux GUIs.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;(*) You can now (un)plug your bluetooth dongle when running without problems.&lt;/p&gt;
&lt;p&gt;You can get the full changelog at &lt;a href=&quot;http://code.google.com/p/wiidevicelibrary/source/list&quot;&gt;Google Code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The download is available at the &lt;a href=&quot;/project/wiidevicelibrary&quot;&gt;project page&lt;/a&gt;&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Wii Device Library v1.1 released</title><link /><comments>http://softwarebakery.com/wii-device-library-v1-1-released#disqus_thread</comments><pubDate>Sat, 18 Apr 2009 22:00:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/wii-device-library-v1-1-released</guid><description>&lt;p&gt;We have finally found the time and resources to release a new version of &lt;a href=&quot;/project/wiidevicelibrary&quot;&gt;Wii Device Library&lt;/a&gt;. This version fixes a lot of the reported bugs and more. Here is a short list of the changes in this version:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Connecting using BlueZ has improved.&lt;/li&gt;
&lt;li&gt;Connecting using MsBluetooth has become more stable and faster.&lt;/li&gt;
&lt;li&gt;Fixed freeze when connecting to a Wiimote with plugged extension under Windows.&lt;/li&gt;
&lt;li&gt;Fixed incorrect behaviour with multiple Wiimotes under Windows.&lt;/li&gt;
&lt;li&gt;Fixed a rare bug that occured on some Vista machines.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Several other fixes and changes have been made. You can get the full changelog at &lt;a href=&quot;http://code.google.com/p/wiidevicelibrary/source/list&quot;&gt;Google Code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The download is available at the &lt;a href=&quot;/project/wiidevicelibrary&quot;&gt;project page&lt;/a&gt;.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item><item><title>Wii Device Library released</title><link /><comments>http://softwarebakery.com/wii-device-library-released#disqus_thread</comments><pubDate>Mon, 22 Dec 2008 22:00:00 +0000</pubDate><guid isPermaLink="true">http://softwarebakery.com/wii-device-library-released</guid><description>&lt;p&gt;After working on &lt;a href=&quot;/project/wiidevicelibrary&quot;&gt;Wii Device Library&lt;/a&gt; on and off for several months we have decided to release our work to the public. This is not the first project we have worked on together, but it is the first project we have actually decided to release. Because of this we wanted to do it right, so we came up with a couple of requirements for the release of the library.
In this post we will describe what decisions we made to share this knowledge with others and for ourselfs to look back upon.&lt;/p&gt;
&lt;h2&gt;Project hosting&lt;/h2&gt;
&lt;p&gt;As it’s likely we want to release more of our projects in the future, it will be helpful to have a centralized place where we can publish all these projects. That’s why we first started looking into project hosting websites such as &lt;a href=&quot;http://www.sourceforge.net/&quot;&gt;SourceForge&lt;/a&gt;, &lt;a href=&quot;http://www.sourceforge.net/&quot;&gt;Google Code&lt;/a&gt; and others. We felt that the projects we would be hosting there would be unrelated to each other and we wanted more control over our content. So, we wanted our own website. But since we were taking as long as we did to publish one project, we also wanted to start as soon as possible with the content. Developing our own website would take too much time. That’s why we chose a CMS, which in our case is &lt;a href=&quot;http://wordpress.org/&quot;&gt;WordPress&lt;/a&gt;. We chose WordPress because we could test it out on WordPress.com. There we found that it was possible to not only blog, but also create pages. And since we didn’t want to spend a lot of time making a theme, we could easily choose our theme from different theme-galleries. From here, things finally started to get rolling. We quickly found a good webhost and registered our domainname. Here we set up our own WordPress site, added a few plugins and we were ready for the next step.&lt;/p&gt;
&lt;h2&gt;Version control&lt;/h2&gt;
&lt;p&gt;We wanted our code to be easily accessable to everyone. For this we wanted a svn repository and an one-click download system. Choosing which svn repository to use was hard at first. There were tons of providers for this, all with different features. We thought about what features we really needed, in the end we just wanted an easily accessable code repository. We have also considered different version control systems. &lt;a href=&quot;http://subversion.tigris.org/&quot;&gt;Subversion&lt;/a&gt; was more widely used than some of the others (&lt;a href=&quot;http://www.nongnu.org/cvs/&quot;&gt;Cvs&lt;/a&gt;, &lt;a href=&quot;http://msdn.microsoft.com/en-us/vstudio/aa700907.aspx&quot;&gt;SourceSafe&lt;/a&gt; and &lt;a href=&quot;http://bazaar-vcs.org/&quot;&gt;Bazaar&lt;/a&gt;), so that was in line with our requirement of keeping everything easily accessable to everyone. Google Code gave us a Subversion repository, was fast and it also allowed people to browse the code online, which was just what we needed.&lt;/p&gt;
&lt;h2&gt;Download package&lt;/h2&gt;
&lt;p&gt;The repository was finished, but we still needed a download package, which included the binaries, sourcecode and examples, that had to be a breeze to find, download and extract. For this we have put a large download-button on the project page where a zip file can be downloaded. Other archive formats aren’t that well supported accros platforms, so zip was the only right format for this. We chose to not use external download systems, because this required more searching for mirrors that would like to host our files. Handling our own downloads would result in a fast and reliable user-experience. We only need to be aware of our monthly usage.&lt;/p&gt;
&lt;h2&gt;Examples&lt;/h2&gt;
&lt;p&gt;We wanted to make it easy to get started with the library. We found in other libraries and frameworks that the examples are a major factor in choosing the library or not. So we thought about what examples we needed to include. We divided the library in different ascpects. For each aspect we created an example that could be used as a program on its own. This makes it very easy to look into one aspect of the library without getting confused by the previous or next examples.&lt;/p&gt;
&lt;p&gt;Go check out the &lt;a href=&quot;/project/wiidevicelibrary&quot;&gt;Wii Device Library&lt;/a&gt;, and let us know what you think.&lt;/p&gt;
</description><author>frozencow@gmail.com (FrozenCow)</author></item></channel></rss>