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

[经验分享] fdisk分区的过程

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2017-8-18 11:32:37 | 显示全部楼层 |阅读模式
1.1 分区1.1.1 准备环境 添加两块100MG(0.1G)的硬盘                              
reboot 重启服务器
查看硬盘是否添加成功
fdisk -l 命令
[iyunv@oldboy-39 ~]# fdisk -l|grep "/dev/sd[abc]:"
Disk /dev/sda: 10.7 GB, 10737418240 bytes
Disk /dev/sdb: 106 MB, 106954752 bytes
Disk /dev/sdc: 106 MB, 106954752 bytes

1.1.2 创建分区的过程  fdisk给小于2TB磁盘进行分区(MBR)
parted 给大于2TB磁盘进行分区(GPT 小于2TB也可以用)
1.1.3  fdisk进行分区小于2TB的磁盘【第一步】  fdisk -cu /dev/sdb
创建一个50M的主分区
[iyunv@oldboy-39 ~]# fdisk -cu /dev/sdb   -c 关掉DOS-compatible模式  -u在列出分区表时,在扇区中给出大小,而不是柱面
Device contains neither a valid DOS partitiontable, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier0xb58dc072.
Changes will remain in memory only, until youdecide to write them.
After that, of course, the previous content won'tbe recoverable.

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

Command (m for help):
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   quitwithout 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):
Command (m for help): n
Command action  
   e   extended                      ## 扩展分区
   p   primary partition (1-4)                ## 主分区
p
Partition number (1-4): 1
First sector (2048-208895, default 2048):            ##直接按回车
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-208895,default 208895): +50M  ###分多大的空间(分50M)   
Command (m for help): p

Disk /dev/sdb: 106 MB, 106954752 bytes
64 heads, 32 sectors/track, 102 cylinders, total208896 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb58dc072

   DeviceBoot      Start         End      Blocks  Id  System
/dev/sdb1           2048      104447       51200  83  Linux

Command (m for help):
【第二步】 先创建扩展在创建逻辑分区
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e                               ##扩展分区
Partition number (1-4): 2               
First sector (104448-208895, default 104448):   
Using default value 104448
Last sector, +sectors or +size{K,M,G}(104448-208895, default 208895):   ##剩多少给多少 按回车
Using default value 208895
Command (m for help): n                             ##新建分区
Command action
   l   logical (5 or over)                      ##逻辑分区
   p   primary partition (1-4)
l
First sector (106496-208895, default 106496):                ##按回车
Using default value 106496
Last sector, +sectors or +size{K,M,G}(106496-208895, default 208895): +20 ##分20M的空间

Command (m for help): p

Disk /dev/sdb: 106 MB, 106954752 bytes
64 heads, 32 sectors/track, 102 cylinders, total208896 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb58dc072

   DeviceBoot      Start         End      Blocks  Id  System
/dev/sdb1            2048      104447       51200  83  Linux
/dev/sdb2          104448      208895       52224   5  Extended
/dev/sdb5          106496      147455       20480  83  Linux

Command (m for help):
实例1-1删除分区
Command (m for help): d
Partition number (1-5): 1
实例1-2把磁盘sdb的容量用了创建一个分区 /dev/sdb1 ,把这个分区挂载到/mnt
第一个里程碑-创建分区
Command (m for help): p

Disk /dev/sdb: 106 MB, 106954752 bytes
64 heads, 32 sectors/track, 102 cylinders, total 208896 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: 0x0c7ada8f

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-208895, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-208895, default 208895):
Using default value 208895

Command (m for help): p         

Disk /dev/sdb: 106 MB, 106954752 bytes
64 heads, 32 sectors/track, 102 cylinders, total 208896 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: 0x0c7ada8f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      208895      103424   83  Linux
Command (m for help): w                ##保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
第二个里程碑-通知系统 /dev/sdb磁盘的分区表修改了  变化了
partprobe/dev/sdb                       ##执行命令即可
第三个里程碑-格式化创建文件系统
[iyunv@oldboy-39 ~]# mkfs.ext4  /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
25896 inodes, 103424 blocks
5171 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
13 block groups
8192 blocks per group, 8192 fragments per group
1992 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 accountinginformation: done

This filesystem will be automatically checked every27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
第四个里程碑-让系统不对我们新创建的分区 进行磁盘检查
[iyunv@oldboy-39 ~]# tune2fs -c 0 -i 0 /dev/sdb1   ##-c挂载次数 -i 每个多少天
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds
第五个里程碑-挂载与检查
[iyunv@oldboy-39 ~]# mount /dev/sdb1 /mnt/          ##挂载
[iyunv@oldboy-39 ~]# df -h                          ##检查
Filesystem     Size  Used Avail Use% Mounted on
/dev/sda3      8.8G  1.5G  6.9G 18% /
tmpfs          491M     0  491M  0% /dev/shm
/dev/sda1      190M   35M  146M 19% /boot
/dev/sdb1       94M  1.6M   88M  2% /mnt
第六个历程碑-需要永久挂载
  • 挂载命令放入到 /etc/rc.local 文件中
  • /etc/fstab




运维网声明 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-403120-1-1.html 上篇帖子: Linux SMB和NFS文件共享 下篇帖子: cnetos 6/7 yum升级最新内核
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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