<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux System Administration and Security &#187; encryption</title>
	<atom:link href="http://www.jasonbrown.us/category/security/encryption/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonbrown.us</link>
	<description></description>
	<lastBuildDate>Tue, 31 Jan 2012 02:58:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>USB encryption with Luks</title>
		<link>http://www.jasonbrown.us/2009/10/usb-encryption-with-luks/</link>
		<comments>http://www.jasonbrown.us/2009/10/usb-encryption-with-luks/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 13:59:59 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[encryption]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cryptsetup]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Luks]]></category>

		<guid isPermaLink="false">http://www.jasonbrown.us/?p=25</guid>
		<description><![CDATA[Here is an easy way of encrypting USB thumb drives with Luks. Examples below assume your thumb drive is/dev/sdb First, check the device for bad blocks: ~]# badblocks -c 10240 -s -w -t random -v /dev/sdb Next create the partition on the drive itself. ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, ]]></description>
			<content:encoded><![CDATA[<p>Here is an easy way of encrypting USB thumb drives with Luks. Examples below assume your thumb drive is/dev/sdb</p>
<p>First, check the device for bad blocks:</p>
<p><strong><em><code>~]# badblocks -c 10240 -s -w -t random -v /dev/sdb</code></em></strong></p>
<p>Next create the partition on the drive itself.</p>
<p><strong><em><code>~]# fdisk /dev/sdb</code></em></strong></p>
<p>Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel<br />
Building a new DOS disklabel with disk identifier 0x99faf680.<br />
Changes will remain in memory only, until you decide to write them.<br />
After that, of course, the previous content won&#8217;t be recoverable.</p>
<p>Warning: invalid flag 0&#215;0000 of partition table 4 will be corrected by w(rite)</p>
<p>Command (m for help): p</p>
<p>Disk /dev/sdb: 4066 MB, 4066377728 bytes<br />
126 heads, 62 sectors/track, 1016 cylinders<br />
Units = cylinders of 7812 * 512 = 3999744 bytes<br />
Disk identifier: 0x99faf680</p>
<p>Device Boot Start End Blocks Id System</p>
<p>Command (m for help): n<br />
Command action<br />
e extended<br />
p primary partition (1-4)<br />
p<br />
Partition number (1-4): 1<br />
First cylinder (1-1016, default 1):<br />
Using default value 1<br />
Last cylinder, +cylinders or +size{K,M,G} (1-1016, default 1016):<br />
Using default value 1016</p>
<p>Command (m for help): p</p>
<p>Disk /dev/sdb: 4066 MB, 4066377728 bytes</p>
<p>126 heads, 62 sectors/track, 1016 cylinders<br />
Units = cylinders of 7812 * 512 = 3999744 bytes<br />
Disk identifier: 0x99faf680</p>
<p>Device Boot Start End Blocks Id System<br />
/dev/sdb1 1 1016 3968465 83 Linux</p>
<p>Command (m for help): w<br />
The partition table has been altered!</p>
<p>Calling ioctl() to re-read partition table.<br />
Syncing disks.</p>
<p>Next, write random data across the partition. This can take a very long time, mine averaged 100GB&#8217;s during a 24 hour period!<br />
<code><em><strong>dd if=/dev/urandom of=/dev/sdb1</strong></em></code></p>
<p>Now create the password and encrypt the device. This will encrypt the device with AES256.<br />
<strong><em><code>~]# cryptsetup luksFormat -v -y -s 256 -c aes /dev/sdb1<br />
WARNING!<br />
========<br />
This will overwrite data on /dev/sdb1 irrevocably.</code></em></strong></p>
<p>Are you sure? (Type uppercase yes): YES<br />
Enter LUKS passphrase:<br />
Verify passphrase:<br />
Command successful.</p>
<p>To open the encrypted drive type:</p>
<p><strong><em><code>cryptsetup luksOpen /dev/sdb1 usbdrive</code></em></strong></p>
<p>It will then prompt for the password.</p>
<p><span style="color: red;">***WARNING*** Do not lose your password, there is no way to recover it!</span></p>
<p>Now format the drive. This example shows how to format the drive with ext4 however ext3 will also work if you are running an older distro.</p>
<p><strong><em><code>~] # mkfs.ext4 /dev/mapper/usbdrive<br />
mke2fs 1.41.4 (27-Jan-2009)<br />
Filesystem label=<br />
OS type: Linux<br />
Block size=4096 (log=2)<br />
Fragment size=4096 (log=2)<br />
248000 inodes, 991859 blocks<br />
49592 blocks (5.00%) reserved for the super user<br />
First data block=0<br />
Maximum filesystem blocks=1019215872</code></em></strong></p>
<p>31 block groups<br />
32768 blocks per group, 32768 fragments per group<br />
8000 inodes per group<br />
Superblock backups stored on blocks:<br />
32768, 98304, 163840, 229376, 294912, 819200, 884736</p>
<p>Writing inode tables: done<br />
Creating journal (16384 blocks): done<br />
Writing superblocks and filesystem accounting information: done</p>
<p>This filesystem will be automatically checked every 31 mounts or<br />
180 days, whichever comes first. Use tune2fs -c or -i to override.</p>
<p>Mount the drive:</p>
<p><strong><em><code>~]# mount /dev/mapper/usbdrive /media/thumbdrive/</code></em></strong></p>
<p>Now your drive is encrypted <img src='http://www.jasonbrown.us/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Gnome should automatically ask the next time you insert your usb drive for the password. However if you are using the cli, here are the steps to mount/unmount the drive.</p>
<p>Mount the device</p>
<p><strong><em><code>~]# cryptsetup luksOpen /dev/sdb1 usbdrive<br />
~]# mount /dev/mapper/usbdrive /media/usbdrive</code></em></strong></p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=USB+encryption+with+Luks+http%3A%2F%2Fjasonbrown.us%2F%3Fp%3D25" title="Post to Twitter"><img class="nothumb" src="http://www.jasonbrown.us/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-big2.png" alt="Post to Twitter" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.jasonbrown.us/2009/10/usb-encryption-with-luks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

