设为首页 收藏本站
查看: 364|回复: 0

[经验分享] linux 磁盘分区 fdisk

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-6-27 09:43:16 | 显示全部楼层 |阅读模式
linux磁盘分区:fdisk(小于2T的分区工具)

[iyunv@zyl ~]# fdisk -l                                                    #####查看磁盘空间

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00061f64

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         307     2252800   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             307        1959    13270016   83  Linux

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[iyunv@zyl ~]# fdisk --help                                        #####查看帮助                                        
fdisk: invalid option -- '-'

Usage:
fdisk [options] <disk>    change partition table
fdisk [options] -l <disk> list partition table(s)
fdisk -s <partition>      give partition size(s) in blocks

Options:
-b <size>                 sector size (512, 1024, 2048 or 4096)
-c                        switch off DOS-compatible mode
-h                        print help
-u <size>                 give sizes in sectors instead of cylinders
-v                        print version
-C <number>               specify the number of cylinders
-H <number>               specify the number of heads
-S <number>               specify the number of sectors per track

[iyunv@zyl ~]# fdisk -l /dev/sdb                                       #####查看/dev/sdb磁盘空间

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[iyunv@zyl ~]# fdisk /dev/sdb                                         #####查看/dev/sdb磁盘空间
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x4f8513b3.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

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

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): m                      ##### 输入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            #####查看分区类型对应的编号列表
   m   print this menu                       #####打印此帮助菜单
   n   add a new partition                   #####新建一个分区
   o   create a new empty DOS partition table
   p   print the partition table             #####打印分区列表
   q   quit without saving changes           #####退出程序,不保存
   s   create a new empty Sun disklabel  
   t   change a partition's system id        #####更改分区类型
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit          #####将分区写入分区表并退出程序
   x   extra functionality (experts only)

Command (m for help): n                      #####新建一个分区
Command action
   e   extended                              #####分区类型  扩展分区
   p   primary partition (1-4)               #####主分区
p                                            #####新建主分区
Partition number (1-4): 1
First cylinder (1-130, default 1):           #####默认为1
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +100M

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4f8513b3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          14      112423+  83  Linux

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
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 1
Partition 1 is already defined.  Delete it before re-adding it.#分区1已经定义。删除它之前重新添加它

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e                                                  #####新建扩展分区
Partition number (1-4): 2
First cylinder (15-130, default 15): 15
Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130):
Using default value 130

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4f8513b3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          14      112423+  83  Linux
/dev/sdb2              15         130      931770    5  Extended

Command (m for help): n
Command action
   l   logical (5 or over)                        #####分区类型  逻辑分区
   p   primary partition (1-4)
p
Partition number (1-4): 2                         #####此仅为测试
Partition 2 is already defined.  Delete it before re-adding it.

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
p
Partition number (1-4): 4                        #####此仅为测试
No free sectors available                        #####发现没有空间。即创建逻辑分区

Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (15-130, default 15):
Using default value 15
Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130): +400M
Unsupported suffix+400M'.
Supported: 10^N: KB (KiloByte), MB (MegaByte), GB (GigaByte)
            2^N: K  (KibiByte), M  (MebiByte), G  (GibiByte)
Last cylinder, +cylinders or +size{K,M,G} (15-130, default 130): +400M

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4f8513b3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          14      112423+  83  Linux
/dev/sdb2              15         130      931770    5  Extended
/dev/sdb5              15          66      417658+  83  Linux

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (67-130, default 67):
Using default value 67
Last cylinder, +cylinders or +size{K,M,G} (67-130, default 130):
Using default value 130

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4f8513b3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          14      112423+  83  Linux
/dev/sdb2              15         130      931770    5  Extended
/dev/sdb5              15          66      417658+  83  Linux
/dev/sdb6              67         130      514048+  83  Linux

[iyunv@zyl ~]# fdisk -l

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00061f64

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         307     2252800   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             307        1959    13270016   83  Linux

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4f8513b3

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          14      112423+  83  Linux
/dev/sdb2              15         130      931770    5  Extended
/dev/sdb5              15          66      417658+  83  Linux
/dev/sdb6              67         130      514048+  83  Linux  
[iyunv@zyl ~]# partprobe                                  #####强制内核重新查找一次分区表
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
[iyunv@zyl /]# ll /dev/sd*
brw-rw----. 1 root disk 8,  0 Jun 25  2016 /dev/sda
brw-rw----. 1 root disk 8,  1 Jun 25 01:58 /dev/sda1
brw-rw----. 1 root disk 8,  2 Jun 25  2016 /dev/sda2
brw-rw----. 1 root disk 8,  3 Jun 25  2016 /dev/sda3
brw-rw----. 1 root disk 8, 16 Jun 25 02:16 /dev/sdb
brw-rw----. 1 root disk 8, 17 Jun 25 02:16 /dev/sdb1
brw-rw----. 1 root disk 8, 18 Jun 25 02:16 /dev/sdb2
brw-rw----. 1 root disk 8, 21 Jun 25 02:16 /dev/sdb5
brw-rw----. 1 root disk 8, 22 Jun 25 02:16 /dev/sdb6

[iyunv@zyl /]# mkfs.ext4 /dev/sdb1                        #####格式化/dev/sdb1  
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
28112 inodes, 112420 blocks
5621 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
14 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729

Writing inode tables: done                           
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[iyunv@zyl /]#
[iyunv@zyl /]# tune2fs -c -1 /dev/sdb1          #####调整和查看/dev/sdb1文件系统的参数
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1
[iyunv@zyl /]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        13G  1.6G   11G  14% /
tmpfs           935M     0  935M   0% /dev/shm
/dev/sda1       194M   34M  151M  19% /boot
[iyunv@zyl /]#
[iyunv@zyl /]#
[iyunv@zyl /]# ls /dev/sd*
/dev/sda   /dev/sda2  /dev/sdb   /dev/sdb2  /dev/sdb6
/dev/sda1  /dev/sda3  /dev/sdb1  /dev/sdb5
[iyunv@zyl /]# ll /dev/sd*
brw-rw----. 1 root disk 8,  0 Jun 25  2016 /dev/sda
brw-rw----. 1 root disk 8,  1 Jun 25 01:58 /dev/sda1
brw-rw----. 1 root disk 8,  2 Jun 25  2016 /dev/sda2
brw-rw----. 1 root disk 8,  3 Jun 25  2016 /dev/sda3
brw-rw----. 1 root disk 8, 16 Jun 25 02:24 /dev/sdb
brw-rw----. 1 root disk 8, 17 Jun 25 02:28 /dev/sdb1
brw-rw----. 1 root disk 8, 18 Jun 25 02:16 /dev/sdb2
brw-rw----. 1 root disk 8, 21 Jun 25 02:16 /dev/sdb5
brw-rw----. 1 root disk 8, 22 Jun 25 02:16 /dev/sdb6
[iyunv@zyl /]# mount /dev/sd
sda   sda1  sda2  sda3  sdb   sdb1  sdb2  sdb5  sdb6  
[iyunv@zyl /]# mount /dev/sdb1 /mnt
[iyunv@zyl /]# touch /mnt/dddd
[iyunv@zyl /]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        13G  1.6G   11G  14% /
tmpfs           935M     0  935M   0% /dev/shm
/dev/sda1       194M   34M  151M  19% /boot
/dev/sdb1       107M  5.6M   96M   6% /mnt
[iyunv@zyl /]# parted /dev/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-235805-1-1.html 上篇帖子: openvswitch centos6.X 安装及使用 下篇帖子: linux安装smb的步骤 linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表