<?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>LinuxByte &#187; DM-Crypt</title>
	<atom:link href="http://www.linuxbyte.org/tag/dm-crypt/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxbyte.org</link>
	<description>一个Linux Blog</description>
	<lastBuildDate>Thu, 26 Jan 2012 08:13:08 +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>用Cryptsetup LUKS 加密目录</title>
		<link>http://www.linuxbyte.org/cryptsetup-luks-jiami.html</link>
		<comments>http://www.linuxbyte.org/cryptsetup-luks-jiami.html#comments</comments>
		<pubDate>Fri, 06 Mar 2009 13:31:19 +0000</pubDate>
		<dc:creator>xiao H</dc:creator>
				<category><![CDATA[系统网络安全]]></category>
		<category><![CDATA[Cryptsetup]]></category>
		<category><![CDATA[DM-Crypt]]></category>
		<category><![CDATA[LUKS]]></category>
		<category><![CDATA[加密]]></category>

		<guid isPermaLink="false">http://www.linuxbyte.org/?p=386</guid>
		<description><![CDATA[系统：Centos 5.x 这里是用了Cryptsetup cryptoloop实现的变通版目录加密。 以下操作都已root 用户操作 dd if=/dev/urandom of=myfile bs=1M count=10 losetup /dev/loop0 myfile 这是创建一个存储空间，并将其关联到 /dev/l... ]]></description>
			<content:encoded><![CDATA[<p>系统：Centos 5.x</p>
<p>这里是用了Cryptsetup cryptoloop实现的变通版目录加密。</p>
<p>以下操作都已root 用户操作</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>urandom <span style="color: #007800;">of</span>=myfile <span style="color: #007800;">bs</span>=1M <span style="color: #007800;">count</span>=<span style="color: #000000;">10</span>
 losetup <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop0 myfile</pre></div></div>

<p>这是创建一个存储空间，并将其关联到 /dev/loop0</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> cryptsetup luksFormat <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop0
<span style="color: #666666; font-style: italic;">#这里会要你YES，然后是密码，注意YES 是全大写的，小写是不行的。</span>
 cryptsetup luksOpen <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop0 myfs
<span style="color: #666666; font-style: italic;">#这里要输入上面的那个密码，为/dev/loop0 创建一个Device-Mapper 文件:/dev/mapper/myfs</span>
mkfs.ext2 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>myfs
<span style="color: #666666; font-style: italic;">#格式化文件系统</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>crypt
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>myfs <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>crypt<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p><span id="more-386"></span><br />
完成上面后，/mnt/crypt/ 就是你的加密目录，而目录的位置和用户权限是可以自己控制的，这个可以自己看看mount 的manpage。</p>
<p>文件写入完成后要卸载就做下面步骤：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>crypt<span style="color: #000000; font-weight: bold;">/</span>
cryptsetup luksClose <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>myfs
losetup <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop0</pre></div></div>

<p>如果要再写入可以就做下面步骤：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">losetup <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop0 myfile
cryptsetup luksOpen <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop0 myfs
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>myfs <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>crypt<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<h2  class="related_post_title">与本文关系暧昧的文字</h2><ul class="related_post"><li><a href="http://www.linuxbyte.org/firegpg-fei-chang-hao-yong-de-gpg-gong-ju.html" title="FireGPG-非常好用的GPG工具">FireGPG-非常好用的GPG工具</a></li><li><a href="http://www.linuxbyte.org/linux-xia-de-wen-jian-jia-mi.html" title="Linux 下的文件加密">Linux 下的文件加密</a></li><li><a href="http://www.linuxbyte.org/wo-de-gnupg-shi-yong-bi-ji.html" title="我的GnuPG 使用笔记">我的GnuPG 使用笔记</a></li><li><a href="http://www.linuxbyte.org/yong-cryptkeeperhe-encfs-wan-cheng-mu-lu-jia-mi.html" title="用Cryptkeeper和EncFS 完成目录加密">用Cryptkeeper和EncFS 完成目录加密</a></li><li><a href="http://www.linuxbyte.org/yong-shc-jiami-shell.html" title="用shc 加密shell">用shc 加密shell</a></li></ul><hr />
<p><small>© xiao H for <a href="http://www.linuxbyte.org">LinuxByte</a>, 2009<br />
Source: <a href="http://www.linuxbyte.org/cryptsetup-luks-jiami.html">用Cryptsetup LUKS 加密目录</a><br />
Post tags: <a href="http://www.linuxbyte.org/tag/cryptsetup" rel="tag">Cryptsetup</a>, <a href="http://www.linuxbyte.org/tag/dm-crypt" rel="tag">DM-Crypt</a>, <a href="http://www.linuxbyte.org/tag/luks" rel="tag">LUKS</a>, <a href="http://www.linuxbyte.org/tag/%e5%8a%a0%e5%af%86" rel="tag">加密</a><br/>
</small></p>
	<p style="margin:3px 0 0 0;">标签：<a href="http://www.linuxbyte.org/tag/cryptsetup" title="Cryptsetup" rel="tag">Cryptsetup</a>, <a href="http://www.linuxbyte.org/tag/dm-crypt" title="DM-Crypt" rel="tag">DM-Crypt</a>, <a href="http://www.linuxbyte.org/tag/luks" title="LUKS" rel="tag">LUKS</a>, <a href="http://www.linuxbyte.org/tag/%e5%8a%a0%e5%af%86" title="加密" rel="tag">加密</a></p>

<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbyte.org/cryptsetup-luks-jiami.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

