1、            通过Fdisk查看系统分区详细信息:

Fdisk –l   详解:

[root@jetsenLin ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

注释:这个硬盘的大小是10.7GB,有255个磁面,63个扇区,1305磁柱(cylinders)

每个cylinder(磁柱)的容量是 8225280 bytes=8225.280 K(约为)=8.225280M(约为);

Device Boot      Start         End      Blocks  Id  System

/dev/sda1  *           1          13      104391  83  Linux

/dev/sda2              14        1305   10377990   8e  Linux LVM

id和System 表示的是一个意思,id看起来不太直观,我们要在fdisk 一个分区时,通过指定id来确认分区类型;比如 7表示的就NTFS 分区;这个在fdisk 中要通过t功能来指定。下面的部分会提到;

Disk /dev/sdb: 21.4 GB,21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Disk /dev/sdb doesn't contain a validpartition table

说明:硬盘分区的表示:在Linux 是通过hd*x 或 sd*x 表示的:

其中* 表示的是a、b、c ... ...

另外x 表示的数字 1、2、3 ... ...

hd大多是IDE硬盘;sd大多是SCSI或移动存储;引导(Boot):表示引导分区,在上面的例子中sda1 是引导分区;

Start (开始):表示的一个分区从Xcylinder(磁柱)开始;

End (结束):表示一个分区到 Ycylinder(磁柱)结束;

2、            学会使用fdisk帮助功能:

[root@jetsenLin~]# fdisk /dev/sda

Thenumber of cylinders for this disk is set to 1305.

There isnothing wrong with that, but this is larger than 1024,

and couldin certain setups cause problems with:

1) softwarethat runs at boot time (e.g., old versions of LILO)

2)booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command(m for help): m      ---输出帮助信息

Commandaction

a  toggle a bootable flag  ---设置启动分区

b  edit bsd disklabel      ---编辑分区标签

c  toggle the dos compatibility flag

d  delete a partition        --删除一个分区

l  list known partition types  --列出分区类型

m  print this menu         --帮助

n  add a new partition      --建立一个新的分区

o  create a new empty DOS partition table  --创建一个新的空白DOS分区表

p  print the partition table               ---打印分区表

q  quit without saving changes           ---退出不保存设置

s   createa new empty Sun disklabel        ---

t   changea partition's system id          ---改变分区的ID

u   changedisplay/entry units            ---改变显示的单位

v   verifythe partition table              ---检查验证分区表

w  write table to disk and exit            ---保存分区表

x  extra functionality (experts only)

Command (m for help):

3、            通过Fdisk对磁盘分区进行操作:

Fdisk 创建分区:

[root@jetsenLin ~]#fdisk /dev/sdb

Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes willremain in memory only,

until you decide to write them. After that,of course, the previous

content won't be recoverable.

The number of cylinders for this disk isset to 2610.

There is nothing wrong with that, but thisis larger than 1024,

and could in certain setups cause problemswith:

1) software that runs at boot time (e.g.,old versions of LILO)

2) booting and partitioning software fromother OSs

(e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite)

Command (m for help): n          ---输入m会有帮助信息出来,输入n不打印帮助信息

Command action

e   extended

p   primary partition (1-4)      ---指定分区类型  e为扩展分区   p为主分区

p

Partition number (1-4): 1           ---定义分区数量   --主分区最多只能有四个

First cylinder (1-2610, default 1): 1   ---设定起始分区的位置

Last cylinder or +size or +sizeM or +sizeK(1-2610, default 2610):

Using default value 2610            ---设定结束分区的位置

Command (m for help): w           ---保存刚才的配置信息。

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@jetsenLin ~]#

 Fdisk 删除分区:

[root@jetsenLin ~]# fdisk /dev/sdb

The number of cylinders for this disk isset to 2610.

There is nothing wrong with that, but thisis larger than 1024,

and could in certain setups cause problemswith:

1) software that runs at boot time (e.g.,old versions of LILO)

2) booting and partitioning software fromother OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): d      ---d 是代表删除,并且会列出当前磁盘的分区数。

Selected partition 1

Command (m for help): p      ----p 是代表删除后,显示磁盘还有几个剩余的分区。

Disk /dev/sdb: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Device Boot      Start         End      Blocks  Id  System    ----已经没有分区了

Command (m for help): w                  ----保存刚才的操作并且生效

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.

The kernel still uses the old table.

The new table will be used at the nextreboot.

这里报了一错误,分区表正在使用,删除再下次启动生效

Syncing disks.        ---同步新的磁盘信息

[root@jetsenLin ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Device Boot      Start         End      Blocks  Id  System

通过fdisk 命令来创建一指定大小的分区并增加一个分区

Fdisk n

创建分区:

[root@jetsenLin ~]# fdisk /dev/sdb

The number of cylinders for this disk isset to 2610.

There is nothing wrong with that, but thisis larger than 1024,

and could in certain setups cause problemswith:

1) software that runs at boot time (e.g.,old versions of LILO)

2) booting and partitioning software fromother OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n            ---创建分区

Command action

e   extended

p   primary partition (1-4)      --指定分区类型为主分区

p

Partition number (1-4): 1           --指定其实分区号

First cylinder (1-2610, default 1): 1   --指定起始柱面号

Last cylinder or +size or +sizeM or +sizeK(1-2610, default 2610): 1024 ---指定终止柱面号

Command (m for help): w            ---保存分区配置信息

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.

The kernel still uses the old table.

The new table will be used at the nextreboot.

Syncing disks.

增加分区:

[root@jetsenLin ~]# fdisk /dev/sdb      -----增加分区

The number of cylinders for this disk isset to 2610.

There is nothing wrong with that, but thisis larger than 1024,

and could in certain setups cause problemswith:

1) software that runs at boot time (e.g.,old versions of LILO)

2) booting and partitioning software fromother OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n       ---分区类型

Command action

e   extended

p   primary partition (1-4)    ---还是指定主分区

p

Partition number (1-4): 1          ---分区号,我指定1。

Partition 1is already defined.  Delete it beforere-adding it.

–提示分区号1已经存在,删除后操作

Command (m for help): n          --我们重新创建分区

Command action

e   extended

p   primary partition (1-4)     --指定分区类型

p

Partition number (1-4): 2          ---因为分区1已经存在,所以我们指定分区2,可通过。

First cylinder (1025-2610, default 1025):       ---指定起始礠柱号,默认是上一分区后一号。

Using default value 1025

Last cylinder or +size or +sizeM or +sizeK(1025-2610, default 2610): 2000   --指定终止礠柱号。

Command (m for help): w                   ---保存分区配置

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.

The kernel still uses the old table.

The new table will be used at the nextreboot.

Syncing disks.

[root@jetsenLin ~]#

通过fdisk命令来来修改现有分区类型

Fdisk 通过t参数来指定

查看分区类型

[root@jetsenLin ~]# fdisk -l /dev/sdb   查看分区信息,类型是Linux,id是83

Disk /dev/sdb: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1        1024    8225248+  83  Linux

/dev/sdb2            1025        2000    7839720   83  Linux

修改分区类型

[root@jetsenLin ~]# fdisk /dev/sdb

The number of cylinders for this disk isset to 2610.

There is nothing wrong with that, but thisis larger than 1024,

and could in certain setups cause problemswith:

1) software that runs at boot time (e.g.,old versions of LILO)

2) booting and partitioning software fromother OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): t                              ---进入修改分区类型

Partition number (1-4): 1                              ---指定需要修改的分区号

Hex code (type L tolist codes): 6                        ---指定分区号为6,也就是FAT16

注意:查看分区类型的代码,在这里可以输入L查看就可以了

Changed system type of partition 1 to 6(FAT16)

Command (m for help): w                              ---保存

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.

The kernel still uses the old table.

The new table will be used at the nextreboot.

WARNING: If you have created or modifiedany DOS 6.x

partitions, please see the fdisk manualpage for additional

information.

Syncing disks.

[root@jetsenLin ~]# fdisk -l /dev/sdb        ---我们看到已经FAT16,并且ID也改成6了。

Disk /dev/sdb: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1        1024    8225248+   6  FAT16

/dev/sdb2            1025        2000    7839720   83  Linux

[root@jetsenLin ~]#

4、            对分区进行格式化及加载:

对分区进行格式化的命令如下等,mkfs后面所接的代表的是将要格式化成的文件系统类型:

mkfs.bfs

mkfs.ext2

mkfs.ext3

mkfs.jfs

mkfs.msdos

mkfs.vfat

mkfs.cramfs

mkfs.minix

mkfs.reiserfs

mkfs.xfs

格式化分区:

[root@jetsenLin ~]# mkfs.ext4 /dev/sdb1          ---格式化分区类型为ext4

mke4fs 1.41.5(23-Apr-2009)

Filesystem label=                  ---我们没有指定卷标,就没有

OS type: Linux                    ---操作系统类型

Block size=4096 (log=2)             --单个块的大小

Fragment size=4096 (log=2)          --片大小

1310720 inodes, 5241198blocks

262059 blocks (5.00%)reserved for the super user

First data block=0

Maximum filesystem blocks=0

160 block groups

32768 blocks per group, 32768fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632, 2654208,

4096000

Writing inode tables:done

Creating journal (32768blocks): done

Writing superblocks andfilesystem accounting information: done

This filesystem will beautomatically checked every 27 mounts or

180 days, whichever comesfirst.  Use tune4fs -c or -i to override.

挂载磁盘:(临时挂载)

[root@jetsenLin ~]# mkdir/data             --创建挂载目录点

[root@jetsenLin ~]#mount  /dev/sdb1 /data  --将/dev/sdb1 挂载到/data

验证是否成功挂载

[root@jetsenLin ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

7.7G  3.1G 4.2G  43% /

/dev/sda1              99M   12M  82M  13% /boot

tmpfs                 506M    0  506M   0% /dev/shm

/dev/sdb1              20G   16K  20G   1% /data     --我们看到已经成功挂载了。

[root@jetsenLin ~]#

挂载磁盘:(永久挂载)

   通过vi编辑器编辑/etc/fstab文件,内容如下,(红色部分是刚添加上去的):

挂载路径              挂载的分区          文件系统  挂载参数     是否要备份   自检顺序

/dev/VolGroup00/LogVol00/                       ext3    defaults        1 1

LABEL=/boot             /boot                   ext3    defaults        1 2

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

/dev/VolGroup00/LogVol01swap                    swap    defaults        0 0

/data                   /dev/sdb1                ext4    default         0 0

第四列挂载参数:通过查看man mount 来查看

第五列是否要备份:(0为不备份,1为要备份,一般情况下不用做备份)

第六列自检程序  (0为不自检,1或2为要自检,如果是根分区要设置1,其它分区只能是2)

fdisk添加磁盘的更多相关文章

  1. 在线添加磁盘,扩展LVM卷案例

    一.添加硬盘,在线扫描出来 首先到虚拟机那里添加一块硬盘,注意必须是SCSI类型的硬盘. 扫描硬盘,不用重启操作系统的. echo "- - -" > /sys/class/ ...

  2. VMware虚拟机下为Ubuntu添加磁盘

    20G的磁盘还是不够用啊,正好复习下磁盘分区和逻辑卷. 关闭虚拟机,打开VMware,右键虚拟机点击设置,点下下方的添加,就可以添加磁盘了. 进入虚拟机,查看: root@ubuntu:/# fdis ...

  3. LINUX下添加磁盘空间的方法详解

    给Linux系统添加磁盘空间在工作会经常遇到. 在添加第二块磁盘一般系统默认为hdb(IDE硬盘)sdb(SCSI 硬盘),以hdb为例. linux-isep:~ # fdisk /dev/hdb ...

  4. Oracle管理监控之为11g asm磁盘组添加磁盘

    1.物理机挂在要添加的磁盘,虚拟机格式化虚拟硬盘 略 2.登录服务器:fdisk -l [root@node2 ~]# fdisk -l Disk /dev/sda: 107.3 GB, 107374 ...

  5. 如何为Linux服务器添加磁盘

    Linux服务器如果磁盘不够用了,就需要增加新的磁盘,磁盘添加到使用通常有4个步骤.其中第一个步骤虚拟机和实体服务器有差别,后面三个步骤都是相同的,这里以VMWare虚拟机来进行演示如何添加磁盘. ( ...

  6. linux进阶之远程免密登录,动态添加磁盘及个别基础命令

    一. 免密登录(远程连接ssh) ssh IP   #连接登录到其它机 ssh 192.168.10.102 ssh IP "CMD"   #在其它机器上执行命令 yum -y i ...

  7. linux添加磁盘及分区挂载

    磁盘管理 1.为什么要添加磁盘 随着系统的使用,磁盘的内容会越来越少,所以这时要添加磁盘增加空间 Linux系统中磁盘管理就是将硬盘通过挂载的方式挂载到linux文件系统中. 2.系统添加磁盘并分区 ...

  8. fdisk添加分区引起的Linux Error: 22: Invalid argument

    在Linux服务器(虚拟机)上使用fdisk添加分区.格式化分区后,遇到了Linux Error: 22: Invalid argument错误,操作步骤如下所示 [root@oracle-serve ...

  9. exsi中的虚拟机添加磁盘后虚拟机中磁盘不出现

    exsi中的虚拟机添加磁盘后虚拟机中磁盘不出现解决: 计算机---> 管理: 这里可以选择磁盘,格式,分区, 改盘符等操作

随机推荐

  1. Sun jdk, Openjdk, Icedtea jdk关系

    转自: http://blog.chinaunix.net/uid-20648944-id-3204527.html Sun jdk与Openjdk版本发展历史如下图所示: 1.    Openjdk ...

  2. 第五、六章:图像&链接

    图像有很多存储格式:JPEG.png.gif等,它们的文件大小也不同,使用的图片类型对于页面响应速度有不同的要求.下面就会简单阐述不同的格式的图片的特点. 1.JPEG格式 JPEG格式适用于彩色照片 ...

  3. vs2013+opencv2.4.11+Qt5.5.1配置

    注意本教程配置环境:win7 32位 如果只配置vs2013+opencv2.4.11,参考http://jingyan.baidu.com/article/ff411625b1311a12e4823 ...

  4. Mac OS终端提示符前缀”bogon”

    像往常一样新打开一个终端,却发现一个很有意思的现象,以前的提示符的组成为: [机器名]:~[用户名] 以前:YangGavin's MacBook Pro:~ yanggavin$ 现在:bogon: ...

  5. HDU 2514 Another Eight Puzzle(DFS)

    题目链接 Problem Description Fill the following 8 circles with digits 1~8,with each number exactly once ...

  6. HDU 2102 A计划(DFS)

    题目链接 Problem Description 可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验.魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主 ...

  7. SharePoint 入门书籍推荐 转载来源http://www.cnblogs.com/jianyus/p/3513238.html

    最近,总有人说刚入门SharePoint,没有好的资料或者电子书,资料推荐大家多看看博客园和CSDN的博客.对于看博客,我一般是两个思路,要么找一个人的从头到尾看一遍,觉得有意义的,就把地址加收藏:或 ...

  8. maven混淆Java代码

    Maven 环境下使用 proguard-maven-plugin 插件混淆你的源码 时间 2014-08-20 15:23:56 肖国颖的个人页面 原文  http://my.oschina.net ...

  9. linux下ClamAV使用

    第一步:Clamav下载http://www.clamav.net/downloads#yuminstall wget –y第二步:创建clamav用户和组groupaddclamav   (创建cl ...

  10. js 中null 和 undifined

    1.一个重要问题 null == undifined (true) ; null === undefined (false) 为什么是这样的呢? undifined是未赋值的基本数据类型,未定义: n ...