<?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>转烛空间mount &#187; </title>
	<atom:link href="http://wangliping.net/tag/mount/feed" rel="self" type="application/rss+xml" />
	<link>http://wangliping.net</link>
	<description>记录生活，学习技术</description>
	<lastBuildDate>Fri, 03 Sep 2010 06:29:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>实例解说 fdisk 使用方法</title>
		<link>http://wangliping.net/how-to-use-fdisk-in-linux</link>
		<comments>http://wangliping.net/how-to-use-fdisk-in-linux#comments</comments>
		<pubDate>Mon, 12 Apr 2010 03:58:36 +0000</pubDate>
		<dc:creator>转烛</dc:creator>
				<category><![CDATA[编程技术]]></category>
		<category><![CDATA[fdisk]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mount]]></category>

		<guid isPermaLink="false">http://wangliping.net/how-to-use-fdisk-in-linux</guid>
		<description><![CDATA[fdisk 是一款功能强大的分区工具，也是目前在Unix类操作系统中最流行的工具之一；分区工具老字号；本篇只介绍其最简单的分区操作功能]]></description>
			<content:encoded><![CDATA[<p><b>提要：</b>fdisk 是一款功能强大的分区工具，也是目前在Unix类操作系统中最流行的工具之一；分区工具老字号；本篇只介绍其最简单的分区操作功能。
<p><b><br />一、fdisk 的介绍；<br /></b>
<p><b>fdisk - Partition table manipulator for Linux</b> ，译成中文的意思是磁盘分区表操作工具；本人译的不太好，也没有看中文文档；其实就是分区工具；
</p>
<p><span id="more-652"></span>
<p>fdsik 能划分磁盘成为若干个区，同时也能为每个分区指定分区的文件系统，比如linux 、fat32、 linux 、linux swap 、fat16 以及其实类Unix类操作系统的文件系统等；当然我们用fdisk 对磁盘操作分区时，并不是一个终点，我们还要对分区进行格式化所需要的文件系统；这样一个分区才能使用；这和DOS中的fdisk 是类似的；
<p><b><br />二、合理规划您的硬盘分区；<br /></b><br />在操作分区之前，我们要明白硬盘分区一点理论，比如硬盘容量和分区大小的计算；对一个硬盘如何规划分区等，请参考如下文档，谢谢；
<p><a href="http://fedora.linuxsir.org/main/?q=node/80">《合理规划您的硬盘分区》</a>
<p><b><br />三、fdisk -l 查看硬盘及分区信息；<br /></b>
<p>通过<a href="http://fedora.linuxsir.org/main/?q=node/80">《合理规划您的硬盘分区》</a> ，我们知道主分区（包括扩展分区）的总个数不能超过四个；也不能把扩展分区包围在主分区之间；根据这个原则，我们划分硬盘分区就比较容易的多；也能为以后减少不必要的麻烦；
<p><b><br />1、通过fdisk -l 查看机器所挂硬盘个数及分区情况；<br /></b>
<p><code>[root@localhost beinan]# fdisk -l<br />Disk /dev/hda: 80.0 GB, 80026361856 bytes<br />255 heads, 63 sectors/track, 9729 cylinders<br />Units = cylinders of 16065 * 512 = 8225280 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/hda1&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 765&nbsp;&nbsp;&nbsp;&nbsp; 6144831&nbsp;&nbsp;&nbsp; 7&nbsp; HPFS/NTFS<br />/dev/hda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 766&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2805&nbsp;&nbsp;&nbsp; 16386300&nbsp;&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<br />/dev/hda3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2806&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9729&nbsp;&nbsp;&nbsp; 55617030&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />/dev/hda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2806&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3825&nbsp;&nbsp;&nbsp;&nbsp; 8193118+&nbsp; 83&nbsp; Linux<br />/dev/hda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3826&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5100&nbsp;&nbsp;&nbsp; 10241406&nbsp;&nbsp; 83&nbsp; Linux<br />/dev/hda7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5198&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 787153+&nbsp; 82&nbsp; Linux swap / Solaris<br />/dev/hda8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5199&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6657&nbsp;&nbsp;&nbsp; 11719386&nbsp;&nbsp; 83&nbsp; Linux<br />/dev/hda9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6658&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7751&nbsp;&nbsp;&nbsp;&nbsp; 8787523+&nbsp; 83&nbsp; Linux<br />/dev/hda10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7752&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9729&nbsp;&nbsp;&nbsp; 15888253+&nbsp; 83&nbsp; Linux<br />Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<br />/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 806400&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 76&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200781&nbsp;&nbsp; 83&nbsp; Linux</code>
<p>通过上面的信息，我们知道此机器中挂载两个硬盘（或移动硬盘），其中一个是hda 另一个是sda ；如果我们想查看单个硬盘情况，可以通过 fdisk -l /dev/hda1 或者fdisk -l /dev/sda1 来操作；以fdisk -l 输出的硬盘标识为准；
<p>其中 hda有三个主分区（包括扩展分区）,分别是主分区 hda1 hda2 和hda3（扩展分区） ；逻辑分区是 hda5到hda10；<br />其中 sda 有两个主分区（包括扩展分区），分别是 hda1 和hda2 (扩展分区）；逻辑分区是 sda5 hda6 ；
<p>硬盘总容量=主分区（包括扩展分区）总容量<br />扩展分区容量=逻辑分区总容量
<p>通过上面的例子，我们可以得知 hda=hda1+hda2+hda3，其中hda3=hda5+hda6+hda7+hda8+hda9+hda10 ... ...<br /><b><br />2、关于fdisk -l 一些数值的说明；<br /></b>
<p><code>Disk /dev/hda: 80.0 GB, 80026361856 bytes<br />255 heads, 63 sectors/track, 9729 cylinders<br />Units = cylinders of 16065 * 512 = 8225280 bytes</code>
<p>这个硬盘是80G的，有255个磁面；63个扇区；9729个磁柱；每个 cylinder（磁柱）的容量是 8225280 bytes=8225.280 K（约为）=8.225280M（约为）；
<p><code>分区序列&nbsp;&nbsp;&nbsp; 引导&nbsp;&nbsp;&nbsp; 开始&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 终止&nbsp;&nbsp;&nbsp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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Linux</code>
<p><b>说明：</b>
<p>硬盘分区的表示：在Linux 是通过hd*x 或 sd*x 表示的，其中 * 表示的是a、b、c ... ... x表示的数字 1、2、3 ... ... hd大多是IDE硬盘；sd大多是SCSI或移动存储；<br />引导（Boot）：表示引导分区，在上面的例子中 hda1 是引导分区；<br />Start （开始）：表示的一个分区从X cylinder（磁柱）开始；<br />End （结束）：表示一个分区到 Y cylinder（磁柱）结束；<br />id和System 表示的是一个意思，id看起来不太直观，我们要在fdisk 一个分区时，通过指定id来确认分区类型；比如 7表示的就NTFS 分区；这个在fdisk 中要通过t功能来指定。下面的部份会提到；<br />Blocks（容量）：这是我翻译的，其实不准确，表示的意思的确是容量的意思，其单位是K；一个分区容量的值是由下面的公式而来的；
<p>Blocks = （相应分区End数值 - 相应分区Start数值）x 单位cylinder（磁柱）的容量
<p>所以我们算一下 hda1的 Blocks 的大小 ：
<p>hda1 Blocks=(765-1)x8225.280=6284113.92 K = 6284.113.92M
<p><b>注：</b>换算单位以硬盘厂家提供的10进位算起，如果以操作系统二进制来算，这个分区容量应该更少一些，得出的这个值和我们通过 fdisk -l 看到的 /dev/hda1的值是大体相当的，因为换算方法不一样，所以也不可能尽可能的精确；再加上分区时的一点损失之类，有时或大或小是存在的；
<p>我们查看分区大小或者文件的时候，还是用十进制来计算比较直观；推算办法是 byte 向前推小数点三位就是K ，K单位的值向前推小数点三位就是M，M向前推小数点三位就是G... ... 一般也差不了多少；这么算就行；
<p><b><br />3、估算一个存储设备是否被完全划分；<br /></b><br />我们估算一个硬盘是否完全被划分，我们只要看 fdisk -l 输出的内容中的 cylinders（柱体） 上一个分区的End 和 下一个分区的Start是不是一个连续的数字，另外要看一下每个硬盘设备的fdisk -l 的开头部份，看一下他的 cylinders（柱体）的值；
<p>比如hda设备，我们看到的是 9729 cylinders ；我们通过 hda的分区表可以看到上一个分区的End的值+1 就是下一个分区的Start 的值；比如 hda2的Start的值是 hda1 的End 的值+1，这证明 hda1 和hda2 中间没有空白分区，是连续的，以此类推；在 hda10，我们看到 End 的值是9729 ，而在fdisk -l头部信息中也有9729 cylinders，证明这个硬盘已经完全划分；
<p><code>Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<br />/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 806400&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 76&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200781&nbsp;&nbsp; 83&nbsp; Linux</code>
<p>我们再看看 sda 移动储是不是被完全划分了；sda有 125个cylinders （柱体），有一个主分区和一个扩展分区构成；在扩展分区中，我们看到End的值为125,而这个移动硬盘的cylinder也是125，这能说明这个硬盘不可能再添加任何主分区了；根据我们上面所说的 sda1 sda2 sda5 sda6 之间未有任何未划分空间，但sda6 的cylinders （柱体）的End值却是 76 ，而 sda总的cylinders （柱体）有125个，由此看来sda 在 sda6后面有未划分区域；
<p>至于sda 有多少未划分空间，我们算一下就知道了；扩展分区总容量是 806400 K ，大约是 806.400M左右，而逻辑分区 sda5 和sda6 的大小加起来是 400M左右，所以还仍有400M左右未划分空间，并且只能划分为链逻辑分区；
<p><b><br />四、fdisk 对硬盘及分区的操作，进入fdisk 对硬盘操作阶段；<br /></b>
<p>我们可以对硬盘进行分区操作，前提是您把fdisk -l 弄明白了；通过fdisk -l ，我们能找出机器中所有硬盘个数及设备名称；比如上面的例子，我们会看到两个设备一个是/dev/hda ，另一个是/dev/sda ；<br /><b><br />fdisk 操作硬盘的命令格式如下：<br /></b>
<p><code>[root@localhost beinan]# fdisk&nbsp;&nbsp;&nbsp; 设备 </code>
<p>比如我们通过 fdisk -l 得知 /dev/hda 或者 /dev/sda设备；我们如果想再添加或者删除一些分区，可以用
<p><code>[root@localhost beinan]# fdisk&nbsp;&nbsp;&nbsp;&nbsp; /dev/hda<br />或<br />[root@localhost beinan]# fdisk&nbsp; /dev/sda </code>
<p><b>注</b> 在以后的例子中，我们要以 /dev/sda设备为例，来讲解如何用fdisk 来操作添加、删除分区等动作；<br /><b><br />1、fdisk 的说明；<br /></b><br />当我们通过 fdisk 设备，进入相应设备的操作时，会发现有如下的提示；以 fdisk /dev/sda 设备为例，以下同；
<p><code>[root@localhost beinan]# fdisk /dev/sda<br />Command (m for help):&nbsp; 在这里按m ，就会输出帮助；<br />Command action<br />&nbsp;&nbsp; a&nbsp;&nbsp; toggle a bootable flag<br />&nbsp;&nbsp; b&nbsp;&nbsp; edit bsd disklabel<br />&nbsp;&nbsp; c&nbsp;&nbsp; toggle the dos compatibility flag<br />&nbsp;&nbsp; d&nbsp;&nbsp; delete a partition&nbsp;&nbsp; 注：这是删除一个分区的动作；<br />&nbsp;&nbsp; l&nbsp;&nbsp; list known partition types&nbsp; 注：l是列出分区类型，以供我们设置相应分区的类型；<br />&nbsp;&nbsp; m&nbsp;&nbsp; print this menu&nbsp; 注：m 是列出帮助信息；<br />&nbsp;&nbsp; n&nbsp;&nbsp; add a new partition 注：添加一个分区；<br />&nbsp;&nbsp; o&nbsp;&nbsp; create a new empty DOS partition table <br />&nbsp;&nbsp; p&nbsp;&nbsp; print the partition table 注：p列出分区表；<br />&nbsp;&nbsp; q&nbsp;&nbsp; quit without saving changes 注：不保存退出；<br />&nbsp;&nbsp; s&nbsp;&nbsp; create a new empty Sun disklabel&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp; t&nbsp;&nbsp; change a partition's system id&nbsp; 注：t 改变分区类型；<br />&nbsp;&nbsp; u&nbsp;&nbsp; change display/entry units&nbsp; <br />&nbsp;&nbsp; v&nbsp;&nbsp; verify the partition table<br />&nbsp;&nbsp; w&nbsp;&nbsp; write table to disk and exit&nbsp; 注：把分区表写入硬盘并退出；<br />&nbsp;&nbsp; x&nbsp;&nbsp; extra functionality (experts only)&nbsp; 注：扩展应用，专家功能；</code>
<p>其实我们常用的只有注有中文的，其它的功能我们不常用（呵，主要是我不会用，否则早会卖弄一下了）；x扩展功能，也不是常用的；一般的情况下只要懂得 d l m p q t w 就行了；
<p>下面以实例操作来详述，没有例子没有办法就，新手也看不懂；<br /><b><br />2、列出当前操作硬盘的分区情况，用p；<br /></b>
<p><code>Command (m for help): p<br />Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<br />/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 806400&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 76&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200781&nbsp;&nbsp; 83&nbsp; Linux</code>
<p><b><br />3、通过fdisk的d指令来删除一个分区；<br /></b>
<p><code>Command (m for help): p&nbsp;&nbsp;&nbsp; 注：列出分区情况；<br />Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<br />/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 806400&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 76&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200781&nbsp;&nbsp; 83&nbsp; Linux<br />Command (m for help): d 注：执行删除分区指定；<br />Partition number (1-6): 6&nbsp; 注：我想删除 sda6 ，就在这里输入 6 ；<br />Command (m for help): p 注：再查看一下硬盘分区情况，看是否删除了？<br />Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<br />/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 806400&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />Command (m for help):</code>
<p><b>警告：</b>删除分区时要小心，请看好分区的序号，如果您删除了扩展分区，扩展分区之下的逻辑分区都会删除；所以操作时一定要小心；如果知道自己操作错了，请不要惊慌，用q不保存退出；切记切记！！！！在分区操作错了之时，千万不要输入w 保存退出！！！<br /><b><br />4、通过fdisk的n指令增加一个分区；<br /></b>
<p><code>Command (m for help): p<br />Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<br />/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 806400&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />Command (m for help): n&nbsp; 注：增加一个分区；<br />Command action<br />&nbsp;&nbsp; l&nbsp;&nbsp; logical (5 or over)&nbsp; 注：增加逻辑分区，分区编号要大于5；为什么要大于5，因为已经有sda5了；<br />&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4) 注：增加一个主分区；编号从 1-4 ；但sda1 和sda2都被占用，所以只能从3开始；<br />p<br />Partition number (1-4): 3<br />No free sectors available&nbsp; 注：失败中，为什么失败？</code>
<p>注：我试图增加一个主分区，看来是失败了，为什么失败？因为我们看到主分区+扩展分区把整个磁盘都用光了，看扩展分区的End的值，再看一下 p输出信息中有125 cylinders；最好还是看前面部份；那里有提到；
<p>所以我们只能增加逻辑分区了；
<p><code>Command (m for help): n<br />Command action<br />&nbsp;&nbsp; l&nbsp;&nbsp; logical (5 or over)<br />&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<br />l&nbsp;&nbsp; 注：在这里输入l，就进入划分逻辑分区阶段了；<br />First cylinder (51-125, default 51):&nbsp;&nbsp; 注：这个就是分区的Start 值；这里最好直接按回车，如果您输入了一个非默认的数字，会造成空间浪费；<br />Using default value 51<br />Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M&nbsp; 注：这个是定义分区大小的，+200M 就是大小为200M ；当然您也可以根据p提示的单位cylinder的大小来算，然后来指定 End的数值。回头看看是怎么算的；还是用+200M这个办法来添加，这样能直观一点。如果您想添加一个10G左右大小的分区，请输入 +10000M ；<br />Command (m for help):</code>
<p><b><br />5、通过fdisk的t指令指定分区类型；<br /></b>
<p><code>Command (m for help): t&nbsp; 注：通过t来指定分区类型；<br />Partition number (1-6): 6 注：要改变哪个分区类型呢？我指定了6，其实也就是sda6<br />Hex code (type L to list codes):L&nbsp; 注：在这里输入L，就可以查看分区类型的id了；<br />Hex code (type L to list codes): b&nbsp; 注：如果我想让这个分区是 W95 FAT32 类型的，通过L查看得知 b是表示的是，所以输入了b；<br />Changed system type of partition 6 to b (W95 FAT32)&nbsp; 注：系统信息，改变成功；是否是改变了，请用p查看；<br />Command (m for help): p<br />Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<br />/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 806400&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 75&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; b&nbsp; W95 FAT32</code>
<p><b><br />6、fdisk 的退出，用q或者 w；<br /></b><br />其中 q是 不保存退出，w是保存退出；
<p><code>Command (m for help): w<br />或 <br />Command (m for help): q</code>
<p><b><br />7、一个添加分区的例子；<br /></b><br />本例中我们会添加两个200M的主分区，其它为扩展分区，在扩展分区中我们添加两个200M大小的逻辑分区；
<p><code>Command (m for help): p 注：列出分区表；<br />Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />Command (m for help): n 注：添加分区；<br />Command action<br />&nbsp;&nbsp; e&nbsp;&nbsp; extended<br />&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<br />p&nbsp; 注：添加主分区；<br />Partition number (1-4): 1&nbsp;&nbsp; 注：添加主分区1；<br />First cylinder (1-125, default 1):&nbsp;&nbsp; 注：直接回车，主分区1的起始位置；默认为1,默认就好；<br />Using default value 1<br />Last cylinder or +size or +sizeM or +sizeK (1-125, default 125): +200M&nbsp;&nbsp; 注：指定分区大小，用+200M来指定大小为200M<br />Command (m for help): n&nbsp; 注：添加新分区；<br />Command action<br />&nbsp;&nbsp; e&nbsp;&nbsp; extended<br />&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<br />p&nbsp; 注：添加主分区<br />Partition number (1-4): 2&nbsp; 注：添加主分区2；<br />First cylinder (26-125, default 26):<br />Using default value 26<br />Last cylinder or +size or +sizeM or +sizeK (26-125, default 125): +200M 注：指定分区大小，用+200M来指定大小为200M<br />Command (m for help): n<br />Command action<br />&nbsp;&nbsp; e&nbsp;&nbsp; extended<br />&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<br />e&nbsp; 注：添加扩展分区；<br />Partition number (1-4): 3&nbsp; 注：指定为3 ，因为主分区已经分了两个了，这个也算主分区，从3开始；<br />First cylinder (51-125, default 51):&nbsp; 注：直接回车；<br />Using default value 51<br />Last cylinder or +size or +sizeM or +sizeK (51-125, default 125):&nbsp;&nbsp; 注：直接回车，把其余的所有空间都给扩展分区；<br />Using default value 125<br />Command (m for help): p<br />Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201600&nbsp;&nbsp; 83&nbsp; Linux<br />/dev/sda3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 604800&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />Command (m for help): n<br />Command action<br />&nbsp;&nbsp; l&nbsp;&nbsp; logical (5 or over)<br />&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<br />l&nbsp; 注：添加逻辑分区；<br />First cylinder (51-125, default 51):<br />Using default value 51<br />Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M&nbsp; 注：添加一个大小为200M大小的分区；<br />Command (m for help): n<br />Command action<br />&nbsp;&nbsp; l&nbsp;&nbsp; logical (5 or over)<br />&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<br />l&nbsp; 注：添加一个逻辑分区；<br />First cylinder (76-125, default 76):<br />Using default value 76<br />Last cylinder or +size or +sizeM or +sizeK (76-125, default 125): +200M 注：添加一个大小为200M大小的分区；<br />Command (m for help): p&nbsp; 列出分区表；<br />Disk /dev/sda: 1035 MB, 1035730944 bytes<br />256 heads, 63 sectors/track, 125 cylinders<br />Units = cylinders of 16128 * 512 = 8257536 bytes<br />&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<br />/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201600&nbsp;&nbsp; 83&nbsp; Linux<br />/dev/sda3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 604800&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<br />/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 75&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<br />/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 76&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux</code>
<p>然后我们根据前面所说通过t指令来改变分区类型；
<p>最后不要忘记w保存退出；
<p><b><br />五、对分区进行格式化，以及加载;<br /></b>
<p>先提示一下；用 mkfs.bfs mkfs.ext2 mkfs.jfs mkfs.msdos mkfs.vfatmkfs.cramfs mkfs.ext3 mkfs.minix mkfs.reiserfs mkfs.xfs 等命令来格式化分区，比如我想格式化 sda6为ext3文件系统，则输入；
<p><code>[root@localhost beinan]# mkfs.ext3 /dev/sda6</code>
<p>如果我想加载 sda6到目前系统来存取文件，应该有mount 命令，但首先您得建一个挂载目录；比如 /mnt/sda6 ；
<p><code>[root@localhost beinan]# mkdir /mnt/sda6<br />[root@localhost beinan]# mount /dev/sda6 /mnt/sda6<br />[root@localhost beinan]# df -lh<br />Filesystem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 容量&nbsp; 已用 可用 已用% 挂载点<br />/dev/hda8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11G&nbsp; 8.4G&nbsp; 2.0G&nbsp; 81% /<br />/dev/shm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 236M&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; 236M&nbsp;&nbsp; 0% /dev/shm<br />/dev/hda10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16G&nbsp; 6.9G&nbsp; 8.3G&nbsp; 46% /mnt/hda10<br />/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 191M&nbsp; 5.6M&nbsp; 176M&nbsp;&nbsp; 4% /mnt/sda6</code>
<p>这样我们就能进入 /mnt/sda6目录，然后存取文件了；
<p>具体的权限方法，以及mount 更详细的用法，在以后我会专门写一个帖子；在一帖中放下所有的内容实在有点为难；
<p><strong>原文</strong>：<a title="http://fedora.linuxsir.org/main/?q=node/81" href="http://fedora.linuxsir.org/main/?q=node/81">http://fedora.linuxsir.org/main/?q=node/81</a>
<p><strong>转烛补充：</strong>
<p>我主要是利用它进行分区合并操作。因为我在安装时分了几个区，现在想把/dev/sda5和/dev/sda6合并，搜了一些资料说用gparted这个工具很不错（后来证实这个工具的确不错），不过如果能用自带的工具而不用另外安装当然是最好的。先是用d命令删除了两个分区，重启，然后用n命令将剩余的空间创建了一个分区，用的都是默认值，即将全部剩余空间放到新的分区，然后再重启。然后利用gparted给新的分区改了个label（此处你也没必要做），再然后仍然利用gparted查看了一下新分区的uuid，在/etc/fstab里将这个挂载到/media/disk下。以上修改label和查看uuid应该可以不用gparted的，但是一时没找到命令，而正好又装了，所以就用上了。然后再重启，OK了。
<p>再补充：ls -al /dev/disk/by-uuid 可以查看uuid</p>
<h3  class="related_post_title">你可能也感兴趣的文章：</h3><ul class="related_post"><li><a href="http://wangliping.net/linux_mount_usb" title="Linux如何mount Usb盘">Linux如何mount Usb盘</a></li><li><a href="http://wangliping.net/c-change-file-permission" title="C语言查看和更改文件的权限">C语言查看和更改文件的权限</a></li><li><a href="http://wangliping.net/source-insight-see-source-code" title="Source-Insight-看大规模大工程源代码">Source-Insight-看大规模大工程源代码</a></li><li><a href="http://wangliping.net/linux-android-x86-test-keyboard-mouse-touch-screen" title="Linux下测试键盘鼠标触摸屏触摸板">Linux下测试键盘鼠标触摸屏触摸板</a></li><li><a href="http://wangliping.net/linux_mem_info_watch" title="Linux内存信息查看相关">Linux内存信息查看相关</a></li><li><a href="http://wangliping.net/how_to_add_swap_method" title="Linux中增加Swap的方法">Linux中增加Swap的方法</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://wangliping.net/how-to-use-fdisk-in-linux/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux如何mount Usb盘</title>
		<link>http://wangliping.net/linux_mount_usb</link>
		<comments>http://wangliping.net/linux_mount_usb#comments</comments>
		<pubDate>Thu, 17 Sep 2009 07:23:00 +0000</pubDate>
		<dc:creator>转烛</dc:creator>
				<category><![CDATA[编程技术]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://blog.wangliping.net/linux%e5%a6%82%e4%bd%95mount-usb%e7%9b%98/</guid>
		<description><![CDATA[<br />]]></description>
			<content:encoded><![CDATA[<p>看看U盘是那个设备，然后mount -t vfat /dev/查到的磁盘 /你的某个目录</p>
<p>一</p>
<p>Linux不像Windows一样，接上新硬件后可以自动识别，在Linux下无法自动识别新硬件的，需要手动去识别。USB移动存储设备通常被识别为sda1，具体可以通过fdisk -l命令查询。</p>
<p>在使用U盘前，我们先要为外挂点新建一个子目录，一般外挂点的子目录都是建立在/mnt里面的，我们也建在那里，当然也可以建在/目录下，名字可以自己定，我们就取名为usb，终端下的命令如下： <span id="more-118"></span></p>
<p>mkdir /mnt/usb</p>
<p>然后我们就可以接上我的U盘了，然后在终端下输入命令并击Enter键即可：</p>
<p>mount /dev/sda1 /mnt/usb</p>
<p>在Windows下当我们用完U盘后，在我们取下U盘前我们先要删除，同样在Linux下我们也要删除挂起点，方法是：</p>
<p>umount /dev/sda1 /mnt/usb 或 umount /dev/sda1</p>
<p>如果不把U盘给umount掉，那样很容易造成数据的丢失。</p>
<p>二</p>
<p>把你的优盘插上去，打开系统终端，先看看有没有认出来<br />
＃lsusb</p>
<p>如果认出来了，你会看到usb什么的设备的</p>
<p>接着进入mnt这个目录<br />
＃cd /mnt</p>
<p>新建一个目录，比如：usbdisk<br />
＃mkdir usbdisk</p>
<p>在运行命令<br />
#mount -t vfat -o iocharset=cp936 /dev/sda1 /mnt/usbdiak<br />
(这个是在一行里的哦，－t 和 －o是两个参数，sda1是你的优盘盘符)</p>
<p>这样在进入/mnt/usbdisk这个目录里去看看有没有东西</p>
<p>要卸载的话<br />
＃umount /dev/sda1<br />
就可以了</p>
<p>三</p>
<p>基本是不用配置.<br />
和windows系统下一样使用.<br />
所不同的是在linux下需要挂载一下.<br />
在这里我们先建立一个目录，用来将U盘挂载到该目录下：mkdir /mnt/usb</p>
<p>四</p>
<p>red hat linux9 GNOME桌面环境下怎样用U盘</p>
<p>方案一：<br />
Linux不像Windows一样，接上新硬件后可以自动识别，在Linux下无法自动识别新硬件的，需要手动去识别。USB移动存储设备通常被识别为sda1，具体可以通过fdisk -l命令查询。</p>
<p>在使用U盘前，我们先要为外挂点新建一个子目录，一般外挂点的子目录都是建立在/mnt里面的，我们也建在那里，当然也可以建在/目录下，名字可以自己定，我们就取名为usb，终端下的命令如下：</p>
<p>mkdir /mnt/usb</p>
<p>然后我们就可以接上我的U盘了，然后在终端下输入命令并击Enter键即可：</p>
<p>mount /dev/sda1 /mnt/usb</p>
<p>在Windows下当我们用完U盘后，在我们取下U盘前我们先要删除，同样在Linux下我们也要删除挂起点，方法是：</p>
<p>umount /dev/sda1 /mnt/usb 或 umount /dev/sda1</p>
<p>如果不把U盘给umount掉，那样很容易造成数据的丢失</p>
<p>方案二：<br />
USB的支持关键在于驱动，没有驱动设备时mount执行是肯定不成的。我在Red Hat里使用U盘的通用方法如下，屡试不爽</p>
<p>1. 先别插U盘，/sbin/lsmod看是否有usb-storage。如果没有的话：</p>
<p>cd /lib/modules/2.4.20-8/kernel/drivers/usb</p>
<p>for v in *.o storage/*.o ; do /sbin/insmod $v ; done</p>
<p>2. 这里再/sbin/lsmod，应该有usbcore、usb-ohci（或usb-uhci，根据主板芯片组而不同）、usb-storage、scsi_mod等。其中usb-storage的状态应该为</p>
<p>（unused）。</p>
<p>3. 插入U盘，不停的/sbin/lsmod，这期间usb-storage的状态应为Initializing，持续时间大约半分钟，其实就相当于Windows在右下角不停的弹汽球:)</p>
<p>4. 初始化结束后, /sbin/fdisk -l，应该能看到/dev/sda1设备。这时，执行</p>
<p>mount /dev/sda1 /mnt/udisk 才能成功。如果是MSDOS格式，又想看到中文，可以</p>
<p>mount -t vfat /dev/sda1 /mnt/udisk -o iocharset=gb2312。</p>
<p>(为方便可以/etc/fstab加一行，以后就可以 mount /mnt/udisk就行了）。</p>
<p>5. 奇怪的是有时候fdisk是看不到sda1，但是也能mount上</p>
<p>使用以上步骤挂U盘基本上可说是“万全”了。台式机、笔记本、VMware都一样。</p>
<p>mkdir /mnt/usb</p>
<p>mount /dev/sda1 /mnt/usb</p>
<p>笔记本上安装linux用法和台式机一样</p>
<p>ps:</p>
<p>首先要检查lsmod|grep usb-storage 这是支持USB的模块。如果没有的话,是无法操作USB接口的设备的。</p>
<p>如没有的话,可以手功modprobe usb-storage,一般查看U盘可以用fdisk -l可以很清楚的看到这个硬件的设备名,比猜测硬件名要准确多了.<br />
这样就在mnt下建立了一个叫做usb的文件夹。<br />
现在应该挂载了：mount -t -vfat /dev/sda1 /mnt/usb<br />
以上语句便将u盘挂载到了usb文件夹中。其中的-t -vfat是您u盘的分区格式。</p>
<p>五</p>
<p>mount是挂载usb的命令，只是后面被挂载的对象没写对。而且挂载对象不存在<br />
正确做法如下：</p>
<p>插好usb之后<br />
先用disk -l命令看一下你的usb设备名称是什么，列出的表格里面有fat格式的就是你的usb设备名字，可能是sda1，或者sda2什么的<br />
假设是sda1的话，就<br />
mount -t vfat /dev/sda1（注意这里是你usb在linux设备名） /mnt/</p>
<p>就可以了。</p>
<p>然后进入mnt目录就是你usb内容了。</p>
<p><span style="color: #ff0000">以下是脚本</span></p>
<p>通常情况下，U盘设备应该是 /dev/sda1， 但是，有时候先后使用两个不同的U盘时，后面插入的一个是 /dev/sdb1，所以，使用了 fdisk -l | grep sd[b-z]1 | awk '{print $1}' 来取得它的设备名。代码只能mount 一个U盘，因为我基本上不会同时插入两个U盘，有这一需求的朋友可以自己修改。</p>
<p>#! /bin/sh<br />
#<br />
# Mount/Unmount a USB disk.<br />
#<br />
# Mount:<br />
#    We try to mount /dev/sda1 first, if failed, search /dev/sdb1, /dev/sdc1 ...,<br />
#    and try to mount the 1st one we found.<br />
#</p>
<p>MOUNT_DIR=/mnt/usb<br />
MOUNT_DEV=/dev/sda1</p>
<p>mount | grep $MOUNT_DIR</p>
<p>if [ "$?" = "0" ]<br />
then</p>
<p>    # Kill all process locked the USB disk<br />
    fuser -m -v -k -i $MOUNT_DIR</p>
<p>    umount $MOUNT_DIR<br />
    if [ "$?" = "0" ]<br />
    then<br />
        echo USB disk at $MOUNT_DIR has been unmounted<br />
    else<br />
        echo Can not unmount $MOUNT_DIR<br />
    fi</p>
<p>else<br />
    mount -t vfat /dev/sda1 $MOUNT_DIR -o codepage=936,iocharset=cp936 2&gt;/dev/null</p>
<p>    if [ "$?" = "0" ]<br />
    then<br />
        echo USB disk $MOUNT_DEV has been mounted at $MOUNT_DIR<br />
    else</p>
<p>        #<br />
        # Search all USB disk devices, and mount the first one<br />
        #<br />
        for MOUNT_DEV in $(fdisk -l | grep sd[b-z]1 | awk '{print $1}')<br />
        do<br />
            if [ "$?" = "0" ]<br />
            then<br />
                mount -t vfat $MOUNT_DEV $MOUNT_DIR -o codepage=936,iocharset=cp936 2&gt;/dev/null<br />
                if [ "$?" = "0" ]<br />
                then<br />
                    echo USB disk $MOUNT_DEV has been mounted at $MOUNT_DIR<br />
                    exit 0<br />
                fi<br />
            fi<br />
        done</p>
<p>        echo Can not mount $MOUNT_DEV to $MOUNT_DIR</p>
<p>    fi</p>
<p>fi</p>
<p>exit 0</p>
<p>注意：如果U盘是在Windows下格式化的，则上面可能没有分区，所以，U盘设备是/dev/sda (而不是/dev/sda1)，则上面的脚本不合适，需要修改。</p>
<h3  class="related_post_title">你可能也感兴趣的文章：</h3><ul class="related_post"><li><a href="http://wangliping.net/how-to-use-fdisk-in-linux" title="实例解说 fdisk 使用方法">实例解说 fdisk 使用方法</a></li><li><a href="http://wangliping.net/c-change-file-permission" title="C语言查看和更改文件的权限">C语言查看和更改文件的权限</a></li><li><a href="http://wangliping.net/source-insight-see-source-code" title="Source-Insight-看大规模大工程源代码">Source-Insight-看大规模大工程源代码</a></li><li><a href="http://wangliping.net/linux-android-x86-test-keyboard-mouse-touch-screen" title="Linux下测试键盘鼠标触摸屏触摸板">Linux下测试键盘鼠标触摸屏触摸板</a></li><li><a href="http://wangliping.net/linux_mem_info_watch" title="Linux内存信息查看相关">Linux内存信息查看相关</a></li><li><a href="http://wangliping.net/how_to_add_swap_method" title="Linux中增加Swap的方法">Linux中增加Swap的方法</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://wangliping.net/linux_mount_usb/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
