linux 硬盘分区和挂载详解
来源:互联网 发布:宝宝哭声辨别软件 编辑:程序博客网 时间:2024/04/30 16:04
用户粘性------项目不够吸引人
http://blog.chinaunix.net/uid-22627501-id-126485.html
关于linux 的磁盘挂载
1 linux 下硬盘的命名方法
linux两种硬盘接口IDE和SCSI
对于IDE常用hdx 其中x为a,b,c,d.....
对于SCSI常用sdx 其中x为a,b,c,d....
2 每块硬盘最多有4个主分区(包括扩展分区)用编号1-4命名 然后扩展分区可以划分为很多逻辑分区 只是逻辑分区必须从5开始(不管前面的主分区是不是完全被分配了)
列如 sda1 sda2 sda3 ....hda1 hdb1
注意 上面a,b,c,d 和1,2,3,4的主要区别
a,b,c,d 是不同的硬盘的命名方式而下面1,2,3,4是同一块硬盘下面的不同分区的命名方式
2 常见的命令
fdisk -l查看机器所有硬盘的数目和具体情况(包括没有挂载的)
df 如果需要查看已经挂载了的硬盘
使用fdisk命令
[root@localhost beinan]# fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 9729 55617030 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux
/dev/hda10 7752 9729 15888253+ 83 Linux
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
通过上面的信息,我们知道此机器中挂载两个硬盘(或移动硬盘),其中一个是hda 另一个是sda ;如果我们想查看单个硬盘情况,可以通过 fdisk -l /dev/hda1 或者fdisk -l /dev/sda1 来操作,进行一些单独硬盘的操作;
其中 hda有三个主分区(包括扩展分区),分别是主分区 hda1 hda2 和hda3(扩展分区) ;逻辑分区是 hda5到hda10
其中 sda 有两个主分区(包括扩展分区),分别是 hda1 和hda2 (扩展分区);逻辑分区是 sda5 hda6
硬盘总容量=主分区(包括扩展分区)总容量
扩展分区容量=逻辑分区总容量
通过上面的例子,我们可以得知 hda=hda1+hda2+hda3,其中hda3=hda5+hda6+hda7+hda8+hda9+hda10 …… ……
其他的信息的介绍(用自己的例子分析)
root@iZ238faho1yZ:/# fdisk -l
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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: 0x0002bfb2
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 41940991 20969472 83 Linux
Disk /dev/xvdb: 214.7 GB, 214748364800 bytes
224 heads, 32 sectors/track, 58514 cylinders, total 419430400 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: 0xb9d551e6
Device Boot Start End Blocks Id System
/dev/xvdb1 2048 419430399 209714176 83 Linux
其中的
255 heads: 255个磁头
63 sectors/track:每个磁道63个扇区
2610 cylinders:2610个磁柱
total 419430400 sectors : 一共419430400多扇区
情况1:虚拟设备 (查)
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
情况2:非虚拟设备
Units = cylinders of 16065 * 512 = 8225280 bytes
16065=255*63 因为每一个磁头都是在同一个柱面的,63表示每个磁道上的扇区数量,这两个数的乘积表示一个柱面上的扇区 数量;所以16065*512表示一个柱面的大小是8225280字节
Sector size (logical/physical): 512 bytes / 512 bytes
表示一个扇区的大小是512字节
start:表示分区从这个磁柱开始
end :表示分区在这个磁柱上结束
block:容量(k) 比如
hda1 Blocks=(765-1)x8225.280=6284113.92 K = 6284.113.92M
id和System 表示的是一个意思,id看起来不太直观,我们要在fdisk 一个分区时,通过指定id来确认分区类型;比如 7表示的就NTFS 分区;这个在fdisk 中要通过t功能来指定。
3、估算一个存储设备是否被完全划分
我们估算一个硬盘是否完全被划分,我们只要看 fdisk -l 输出的内容中的 cylinders(柱体) 上一个分区的End 和 下一个分区的Start是不是一个连续的数字,另外要看一下每个硬盘设备的fdisk -l 的开头部份,看一下他的 cylinders(柱体)的值;
比如hda设备,我们看到的是 9729 cylinders ;我们通过 hda的分区表可以看到上一个分区的End的值+1 就是下一个分区的Start 的值;比如 hda2的Start的值是 hda1 的End 的值+1,这证明 hda1 和hda2 中间没有空白分区,是连续的,以此类推;在 hda10,我们看到 End 的值是9729 ,而在fdisk -l头部信息中也有9729 cylinders,证明这个硬盘已经完全划分;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
我们再看看 sda 移动储是不是被完全划分了;sda有 125个cylinders (柱体),有一个主分区和一个扩展分区构成;在扩展分区中,我们看到End的值为125,而这个移动硬盘的cylinder也是125,这能说明这个硬盘不可能再添加任何主分区了;根据我们上面所说的 sda1 sda2 sda5 sda6 之间未有任何未划分空间,但sda6 的cylinders (柱体)的End值却是 76 ,而 sda总的cylinders (柱体)有125个,由此看来sda 在 sda6后面有未划分区域;
至于sda 有多少未划分空间,我们算一下就知道了;扩展分区总容量是 806400 K ,大约是 806.400M左右,而逻辑分区 sda5 和sda6 的大小加起来是 400M左右,所以还仍有400M左右未划分空间,并且只能划分为链逻辑分区;
1、fdisk 的说明;
当我们通过 fdisk 设备,进入相应设备的操作时,会发现有如下的提示;以 fdisk /dev/sda 设备为例,以下同;
[root@localhost beinan]# fdisk /dev/sda
Command (m for help): 在这里按m ,就会输出帮助;
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition 注:这是删除一个分区的动作;
l list known partition types 注:l是列出分区类型,以供我们设置相应分区的类型;
m print this menu 注:m 是列出帮助信息;
n add a new partition 注:添加一个分区;
o create a new empty DOS partition table
p print the partition table 注:p列出分区表;
q quit without saving changes 注:不保存退出;
s create a new empty Sun disklabel
t change a partition's system id 注:t 改变分区类型;
u change display/entry units
v verify the partition table
w write table to disk and exit 注:把分区表写入硬盘并退出;
x extra functionality (experts only) 注:扩展应用,专家功能;
2、列出当前操作硬盘的分区情况,用p
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
3、通过fdisk的d指令来删除一个分区
Command (m for help): p 注:列出分区情况;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
Command (m for help): d 注:执行删除分区指定;
Partition number (1-6): 6 注:我想删除 sda6 ,就在这里输入 6 ;
Command (m for help): p 注:再查看一下硬盘分区情况,看是否删除了?
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help):
警告:删除分区时要小心,请看好分区的序号,如果您删除了扩展分区,扩展分区之下的逻辑分区都会删除;所以操作时一定要小心;如果知道自己操作错了,请不要惊慌,用q不保存退出;切记切记!!!!在分区操作错了之时,千万不要输入w保存退出!!!
4、通过fdisk的n指令增加一个分区
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help): n 注:增加一个分区;
Command action
l logical (5 or over) 注:增加逻辑分区,分区编号要大于5;为什么要大于5,因为已经有sda5了;
p primary partition (1-4) 注:增加一个主分区;编号从 1-4 ;但sda1 和sda2都被占用,所以只能从3开始;
p
Partition number (1-4): 3
No free sectors available 注:失败中,为什么失败?
注:我试图增加一个主分区,看来是失败了,为什么失败?因为我们看到主分区+扩展分区把整个磁盘都用光了,看扩展分区的End的值,再看一下 p输出信息中有125 cylinders;最好还是看前面部份;那里有提到;
所以我们只能增加逻辑分区了
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l 注:在这里输入l,就进入划分逻辑分区阶段了;
First cylinder (51-125, default 51): 注:这个就是分区的Start 值;这里最好直接按回车,如果您输入了一个非默认的数字,会造成空间浪费;
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:这个是定义分区大小的,+200M 就是大小为200M ;当然您也可以根据p提示的单位cylinder的大小来算,然后来指定 End的数值。回头看看是怎么算的;还是用+200M这个办法来添加,这样能直观一点。如果您想添加一个10G左右大小的分区,请输入 +10000M ;
Command (m for help):
5、通过fdisk的t指令指定分区类型
Command (m for help): t 注:通过t来指定分区类型;
Partition number (1-6): 6 注:要改变哪个分区类型呢?我指定了6,其实也就是sda6
Hex code (type L to list codes):L 注:在这里输入L,就可以查看分区类型的id了;
Hex code (type L to list codes): b 注:如果我想让这个分区是 W95 FAT32 类型的,通过L查看得知 b是表示的是,所以输入了b;
Changed system type of partition 6 to b (W95 FAT32) 注:系统信息,改变成功;是否是改变了,请用p查看;
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 75 201568+ b W95 FAT32
6、fdisk 的退出,用q或者 w
其中 q是 不保存退出,w是保存退出
Command (m for help): w
或
Command (m for help): q
五、对分区进行格式化,以及加载
先提示一下;用 mkfs.bfs mkfs.ext2 mkfs.jfs mkfs.msdos mkfs.vfatmkfs.cramfs mkfs.ext3 mkfs.minix mkfs.reiserfs mkfs.xfs 等命令来格式化分区,比如我想格式化 sda6为ext3文件系统,则输入;
[root@localhost beinan]# mkfs.ext3 /dev/sda6
如果我想加载 sda6到目前系统来存取文件,应该有mount 命令,但首先您得建一个挂载目录;比如 /mnt/sda6 ;
[root@localhost beinan]# mkdir /mnt/sda6
[root@localhost beinan]# mount /dev/sda6 /mnt/sda6
[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 8.4G 2.0G 81% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda10 16G 6.9G 8.3G 46% /mnt/hda10
/dev/sda6 191M 5.6M 176M 4% /mnt/sda6
参考文献 http://blog.chinaunix.net/uid-22627501-id-126485.html
http://blog.chinaunix.net/uid-22627501-id-126485.html
关于linux 的磁盘挂载
1 linux 下硬盘的命名方法
linux两种硬盘接口IDE和SCSI
对于IDE常用hdx 其中x为a,b,c,d.....
对于SCSI常用sdx 其中x为a,b,c,d....
2 每块硬盘最多有4个主分区(包括扩展分区)用编号1-4命名 然后扩展分区可以划分为很多逻辑分区 只是逻辑分区必须从5开始(不管前面的主分区是不是完全被分配了)
列如 sda1 sda2 sda3 ....hda1 hdb1
注意 上面a,b,c,d 和1,2,3,4的主要区别
a,b,c,d 是不同的硬盘的命名方式而下面1,2,3,4是同一块硬盘下面的不同分区的命名方式
2 常见的命令
fdisk -l查看机器所有硬盘的数目和具体情况(包括没有挂载的)
df 如果需要查看已经挂载了的硬盘
使用fdisk命令
[root@localhost beinan]# fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 9729 55617030 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux
/dev/hda10 7752 9729 15888253+ 83 Linux
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
通过上面的信息,我们知道此机器中挂载两个硬盘(或移动硬盘),其中一个是hda 另一个是sda ;如果我们想查看单个硬盘情况,可以通过 fdisk -l /dev/hda1 或者fdisk -l /dev/sda1 来操作,进行一些单独硬盘的操作;
其中 hda有三个主分区(包括扩展分区),分别是主分区 hda1 hda2 和hda3(扩展分区) ;逻辑分区是 hda5到hda10
其中 sda 有两个主分区(包括扩展分区),分别是 hda1 和hda2 (扩展分区);逻辑分区是 sda5 hda6
硬盘总容量=主分区(包括扩展分区)总容量
扩展分区容量=逻辑分区总容量
通过上面的例子,我们可以得知 hda=hda1+hda2+hda3,其中hda3=hda5+hda6+hda7+hda8+hda9+hda10 …… ……
其他的信息的介绍(用自己的例子分析)
root@iZ238faho1yZ:/# fdisk -l
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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: 0x0002bfb2
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 41940991 20969472 83 Linux
Disk /dev/xvdb: 214.7 GB, 214748364800 bytes
224 heads, 32 sectors/track, 58514 cylinders, total 419430400 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: 0xb9d551e6
Device Boot Start End Blocks Id System
/dev/xvdb1 2048 419430399 209714176 83 Linux
其中的
255 heads: 255个磁头
63 sectors/track:每个磁道63个扇区
2610 cylinders:2610个磁柱
total 419430400 sectors : 一共419430400多扇区
情况1:虚拟设备 (查)
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
情况2:非虚拟设备
Units = cylinders of 16065 * 512 = 8225280 bytes
16065=255*63 因为每一个磁头都是在同一个柱面的,63表示每个磁道上的扇区数量,这两个数的乘积表示一个柱面上的扇区 数量;所以16065*512表示一个柱面的大小是8225280字节
Sector size (logical/physical): 512 bytes / 512 bytes
表示一个扇区的大小是512字节
start:表示分区从这个磁柱开始
end :表示分区在这个磁柱上结束
block:容量(k) 比如
hda1 Blocks=(765-1)x8225.280=6284113.92 K = 6284.113.92M
id和System 表示的是一个意思,id看起来不太直观,我们要在fdisk 一个分区时,通过指定id来确认分区类型;比如 7表示的就NTFS 分区;这个在fdisk 中要通过t功能来指定。
3、估算一个存储设备是否被完全划分
我们估算一个硬盘是否完全被划分,我们只要看 fdisk -l 输出的内容中的 cylinders(柱体) 上一个分区的End 和 下一个分区的Start是不是一个连续的数字,另外要看一下每个硬盘设备的fdisk -l 的开头部份,看一下他的 cylinders(柱体)的值;
比如hda设备,我们看到的是 9729 cylinders ;我们通过 hda的分区表可以看到上一个分区的End的值+1 就是下一个分区的Start 的值;比如 hda2的Start的值是 hda1 的End 的值+1,这证明 hda1 和hda2 中间没有空白分区,是连续的,以此类推;在 hda10,我们看到 End 的值是9729 ,而在fdisk -l头部信息中也有9729 cylinders,证明这个硬盘已经完全划分;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
我们再看看 sda 移动储是不是被完全划分了;sda有 125个cylinders (柱体),有一个主分区和一个扩展分区构成;在扩展分区中,我们看到End的值为125,而这个移动硬盘的cylinder也是125,这能说明这个硬盘不可能再添加任何主分区了;根据我们上面所说的 sda1 sda2 sda5 sda6 之间未有任何未划分空间,但sda6 的cylinders (柱体)的End值却是 76 ,而 sda总的cylinders (柱体)有125个,由此看来sda 在 sda6后面有未划分区域;
至于sda 有多少未划分空间,我们算一下就知道了;扩展分区总容量是 806400 K ,大约是 806.400M左右,而逻辑分区 sda5 和sda6 的大小加起来是 400M左右,所以还仍有400M左右未划分空间,并且只能划分为链逻辑分区;
1、fdisk 的说明;
当我们通过 fdisk 设备,进入相应设备的操作时,会发现有如下的提示;以 fdisk /dev/sda 设备为例,以下同;
[root@localhost beinan]# fdisk /dev/sda
Command (m for help): 在这里按m ,就会输出帮助;
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition 注:这是删除一个分区的动作;
l list known partition types 注:l是列出分区类型,以供我们设置相应分区的类型;
m print this menu 注:m 是列出帮助信息;
n add a new partition 注:添加一个分区;
o create a new empty DOS partition table
p print the partition table 注:p列出分区表;
q quit without saving changes 注:不保存退出;
s create a new empty Sun disklabel
t change a partition's system id 注:t 改变分区类型;
u change display/entry units
v verify the partition table
w write table to disk and exit 注:把分区表写入硬盘并退出;
x extra functionality (experts only) 注:扩展应用,专家功能;
2、列出当前操作硬盘的分区情况,用p
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
3、通过fdisk的d指令来删除一个分区
Command (m for help): p 注:列出分区情况;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
Command (m for help): d 注:执行删除分区指定;
Partition number (1-6): 6 注:我想删除 sda6 ,就在这里输入 6 ;
Command (m for help): p 注:再查看一下硬盘分区情况,看是否删除了?
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help):
警告:删除分区时要小心,请看好分区的序号,如果您删除了扩展分区,扩展分区之下的逻辑分区都会删除;所以操作时一定要小心;如果知道自己操作错了,请不要惊慌,用q不保存退出;切记切记!!!!在分区操作错了之时,千万不要输入w保存退出!!!
4、通过fdisk的n指令增加一个分区
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help): n 注:增加一个分区;
Command action
l logical (5 or over) 注:增加逻辑分区,分区编号要大于5;为什么要大于5,因为已经有sda5了;
p primary partition (1-4) 注:增加一个主分区;编号从 1-4 ;但sda1 和sda2都被占用,所以只能从3开始;
p
Partition number (1-4): 3
No free sectors available 注:失败中,为什么失败?
注:我试图增加一个主分区,看来是失败了,为什么失败?因为我们看到主分区+扩展分区把整个磁盘都用光了,看扩展分区的End的值,再看一下 p输出信息中有125 cylinders;最好还是看前面部份;那里有提到;
所以我们只能增加逻辑分区了
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l 注:在这里输入l,就进入划分逻辑分区阶段了;
First cylinder (51-125, default 51): 注:这个就是分区的Start 值;这里最好直接按回车,如果您输入了一个非默认的数字,会造成空间浪费;
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:这个是定义分区大小的,+200M 就是大小为200M ;当然您也可以根据p提示的单位cylinder的大小来算,然后来指定 End的数值。回头看看是怎么算的;还是用+200M这个办法来添加,这样能直观一点。如果您想添加一个10G左右大小的分区,请输入 +10000M ;
Command (m for help):
5、通过fdisk的t指令指定分区类型
Command (m for help): t 注:通过t来指定分区类型;
Partition number (1-6): 6 注:要改变哪个分区类型呢?我指定了6,其实也就是sda6
Hex code (type L to list codes):L 注:在这里输入L,就可以查看分区类型的id了;
Hex code (type L to list codes): b 注:如果我想让这个分区是 W95 FAT32 类型的,通过L查看得知 b是表示的是,所以输入了b;
Changed system type of partition 6 to b (W95 FAT32) 注:系统信息,改变成功;是否是改变了,请用p查看;
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 75 201568+ b W95 FAT32
6、fdisk 的退出,用q或者 w
其中 q是 不保存退出,w是保存退出
Command (m for help): w
或
Command (m for help): q
五、对分区进行格式化,以及加载
先提示一下;用 mkfs.bfs mkfs.ext2 mkfs.jfs mkfs.msdos mkfs.vfatmkfs.cramfs mkfs.ext3 mkfs.minix mkfs.reiserfs mkfs.xfs 等命令来格式化分区,比如我想格式化 sda6为ext3文件系统,则输入;
[root@localhost beinan]# mkfs.ext3 /dev/sda6
如果我想加载 sda6到目前系统来存取文件,应该有mount 命令,但首先您得建一个挂载目录;比如 /mnt/sda6 ;
[root@localhost beinan]# mkdir /mnt/sda6
[root@localhost beinan]# mount /dev/sda6 /mnt/sda6
[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 8.4G 2.0G 81% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda10 16G 6.9G 8.3G 46% /mnt/hda10
/dev/sda6 191M 5.6M 176M 4% /mnt/sda6
这样我们就能进入 /mnt/sda6目录,然后存取文件了
增加!!!!!!!!!!!!!!!
df是使用
例1:列出各文件系统的磁盘空间使用情况。
$ df
Filesystem 1 K-blocks Used Available Use% Mounted on
/dev/hda2 1361587 1246406 44823 97% /
linux中df命令的输出清单的第1列是代表文件系统对应的设备文件的路径名(一般是硬盘上的分区);第2列给出分区包含的数据块(1024字节)的数目;第3,4列分别表示已用的和可用的数据块数目。用户也许会感到奇怪的是,第3,4列块数之和不等于第2列中的块数。这是因为缺省的每个分区都留了少量空间供系统管理员使用。即使遇到普通用户空间已满的情况,管理员仍能登录和留有解决问题所需的工作空间。清单中Use% 列表示普通用户空间使用的百分比,即使这一数字达到100%,分区仍然留有系统管理员使用的空间。最后,Mounted on列表示文件系统的安装点。
参考文献 http://blog.chinaunix.net/uid-22627501-id-126485.html
0 0
- linux 硬盘分区和挂载详解
- Linux硬盘分区和挂载
- linux硬盘分区和挂载
- linux硬盘分区和挂载《一》
- linux硬盘分区和挂载命令《二》
- 硬盘分区和挂载
- Linux下硬盘分区详解
- linux自动挂载硬盘分区
- Linux 自动挂载硬盘分区
- Linux 自动挂载硬盘分区
- linux硬盘分区与挂载
- Linux centOS 硬盘分区挂载
- linux中的挂载设备和fdisk命令对硬盘分区
- linux硬盘分区和文件系统
- linux硬盘分区和文件系统
- 硬盘分区和Linux文件系统
- linux硬盘分区和文件系统
- Ubuntu Linux 硬盘分区方案详解
- hdu 4089 Activation(概率dp)
- linux2.6.29 CFS调度详细分析(一)
- Struts 1 配置文件
- unity3d 关于c#命名空间引用问题
- Eclipse出现 you must restart adb and eclipse的解决办法
- linux 硬盘分区和挂载详解
- TCP/IP卷一 ARP协议
- 分享
- Android学习笔记——资源文件
- 一张图看西方哲学史
- 使用场景
- SpringMVC-Day6
- HDU 5104 Primes Problem(数学)
- mac系统配置pcl成功