关于 Linux下硬盘分区的操作步骤分享

Admin 2021-03-15 群英行业资讯

要掌握Linux硬盘的分区,就要知道MBR、扩展分区和逻辑分区的概念,今天小编就给大家介绍下Linux硬盘分区的详细步骤,有兴趣的朋友不妨来了解下吧。




1、查看硬盘大小,并分区。

[root@colud ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x000c16ac

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9971712   8e  Linux LVM

Disk /dev/sdb: 59.1 GB, 59055800320 bytes
255 heads, 63 sectors/track, 7179 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: 0xda4662fa

   Device Boot      Start         End      Blocks   Id  System


........... 
后边还有好多就不列出来了,此时可以看到有一个/dev/sdb硬盘是没有进行分区的。可以看到大小是59.1G。解析来对这个磁盘进行分区即可。



2、对空白盘分区

使用fdisk命令管理/dev/sdb,进去以后输入“n”执行增加分区,选择“P”创建主分区,填写分区编号,选择分区大小First cylinder起始柱面默认即可,然后写上去分区想分多大,可以使用+100M,10G,20G等直接写明需要多大的分区,Last cylinder如果也用默认即是整个磁盘分一个分区,最后使用“w”保存下分区即可。命令操作如下所示,当有多块磁盘时按照步骤重复分区就可以了:

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

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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-7179, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-7179, default 7179): +20G

Command (m for help): p

Disk /dev/sdb: 59.1 GB, 59055800320 bytes
255 heads, 63 sectors/track, 7179 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: 0xda4662fa

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2612    20980858+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


3、格式化分区


常见的分区格式有ext2、ext3、ext4、xfs等格式,此处可以使用ext4格式来对分区进行格式化,需要其他格式的根据你的实际情况决定就可以。

命令为:mkfs.ext4 /dev/sdb1 ,此处的sdb1是刚分出来的新分区。

[root@colud ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1313760 inodes, 5245214 blocks
262260 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=0
161 block groups
32768 blocks per group, 32768 fragments per group
8160 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
4096000

正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


4、对分区进行挂载,使系统每次重启可以自动挂载此分区,否则将无法往此分区写数据。


对分区挂载步骤如下:

创建挂载点:mkdir /data

手动挂载分区:moutn /dev/sdb1 /data

将挂载信息写入分区表,方便系统启动自动挂载:

vi /etc/fstab 然后在最后一行写入挂载信息:

/dev/sdb1               /data                   ext4    defaults        0 0


上面就是Linux硬盘分区的详细步骤介绍了,Linux系统在进行硬盘分区的时候有几个地方需要特别注意,按照本文介绍的步骤操作。


标签: 硬盘安装linux

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。

猜你喜欢

云活动 云活动
群英网络助力开启安全的云计算之旅
立即注册,领取新人大礼包
  • 联系我们
  • 24小时售后:4006784567
  • 24小时TEL :0668-2555666
  • 售前咨询TEL:400-678-4567

  • 官方微信

    官方微信
Copyright  ©  QY  Network  Company  Ltd. All  Rights  Reserved. 2003-2019  群英网络  版权所有   茂名市群英网络有限公司
增值电信经营许可证 : B1.B2-20140078   粤ICP备09006778号
免费拨打  400-678-4567
免费拨打  400-678-4567 免费拨打 400-678-4567 或 0668-2555555
微信公众号
返回顶部
返回顶部 返回顶部