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

[经验分享] 对linux下 fdisk 中 primary , extented, logical 分区的理解

[复制链接]

尚未签到

发表于 2016-11-22 08:20:25 | 显示全部楼层 |阅读模式
  磨砺技术珠矶,践行数据之道,追求卓越价值
  回到上一级页面: PostgreSQL杂记页     回到顶级页面:PostgreSQL索引页
  首先,由于 历史上的原因,各个操作系统为共存的需要而约定俗成。一个物理磁盘最多有4个主分区。
  http://www.express.nec.co.jp/linux/distributions/knowledge/system/fdisk.html
  可以是这样:
  比如第一块物理磁盘,它一般会有启动分区部分用来包含系统。其余的可以作其他用途。
  它可能最多包含四个主分区:
       第一区:主分区(被设为活动者,启动时,此分区被引导)
       第二区:主分区
       第三区:主分区
       第四区:主分区
  也可能是这样:
       第一区: 主分区
       第二区: 扩展分区
       而扩展分区 又分为  : 逻辑分区1 , 逻辑分区2,逻辑分区3 ,逻辑分区4....
  第一块物理硬盘中,主分区是必须的,因为要引导系统嘛,这是没有办法的事。
  对第二块物理硬盘, 可以有几种方法去使用:
       1  主分区 + 扩展分区(里面分成逻辑分区1,逻辑分区2...),
         此方式下,此处主分区似乎有点不伦不类。当然也是可以当作数据区使用。
       2  仅有一个 主分区,拿来直接当数据区用也是可以的。
       3  完全是扩展分区。(里面分成逻辑分区1,逻辑分区2...)
    要注意: 仅有扩展分区,不进一步划分逻辑分区,是不能拿来做文件系统的。
  下面就以第三种情况来试验一下:
  



[iyunv@localhost ~]# fdisk -l
Disk /dev/sda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1566 12474472+ 8e Linux LVM
Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
  
  在第二块物理硬盘上建立扩展分区:



[iyunv@localhost ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 1566.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that 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): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-1566, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1566, default 1566):
Using default value 1566
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[iyunv@localhost ~]# fdisk -l
Disk /dev/sda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1566 12474472+ 8e Linux LVM
Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1566 12578863+ 5 Extended
  此时如果直接建文件系统会失败:



[iyunv@localhost ~]# mkfs /dev/sdb1
mke2fs 1.39 (29-May-2006)
/dev/sdb1: Invalid argument passed to ext2 library while setting up superblock
[iyunv@localhost ~]#
[iyunv@localhost ~]# mkfs /dev/sdb
mke2fs 1.39 (29-May-2006)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) n
[iyunv@localhost ~]#
  对/dev/sdb 继续运用 fdisk, 此时会出现 l 与 p 选项,不要理会p, 用l (logical)



[iyunv@localhost ~]# fdisk /dev/sdb1
Unable to read /dev/sdb1
[iyunv@localhost ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 1566.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that 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): p
Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1566 12578863+ 5 Extended
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-1566, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-1566, default 1566): +8G
  上面选 +8G 做一个8G的逻辑分区后,再做一个:



Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (975-1566, default 975):
Using default value 975
Last cylinder or +size or +sizeM or +sizeK (975-1566, default 1566):
Using default value 1566
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[iyunv@localhost ~]#
[iyunv@localhost ~]# fdisk -l
Disk /dev/sda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1566 12474472+ 8e Linux LVM
Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1566 12578863+ 5 Extended
/dev/sdb5 1 974 7823592 83 Linux
/dev/sdb6 975 1566 4755208+ 83 Linux
  此时可以作文件系统了,注意由于是逻辑分区,所以从第5开始计数:/dev/sdb5  /dev/sdb6



[iyunv@localhost ~]# mkfs /dev/sdb5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
979200 inodes, 1955898 blocks
97794 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2004877312
60 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[iyunv@localhost ~]# mkfs /dev/sdb6
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
595552 inodes, 1188802 blocks
59440 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1220542464
37 block groups
32768 blocks per group, 32768 fragments per group
16096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[iyunv@localhost ~]# cd /
[iyunv@localhost /]# ls
bin etc lib64 misc opt sbin sys tmp
boot home lost+found mnt proc selinux test usr
dev lib media net root srv tftpboot var
[iyunv@localhost /]# mkdir /test01
[iyunv@localhost /]# mkdir /test02
[iyunv@localhost /]# mount /dev/sdb5 /test01
[iyunv@localhost /]# mount /dev/sdb6 /test02
[iyunv@localhost /]# cd /test01
[iyunv@localhost test01]# ls
lost+found
[iyunv@localhost test01]# cd /test02
[iyunv@localhost test02]#
  回到上一级页面: PostgreSQL杂记页     回到顶级页面:PostgreSQL索引页
  磨砺技术珠矶,践行数据之道,追求卓越价值

运维网声明 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-303720-1-1.html 上篇帖子: gem install mysql 报extconf.rb failed错误 下篇帖子: PHP 中使用参数化查询
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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