当前位置:懂科普 >

IT科技

> linux一般怎么分区

linux一般怎么分区

产品型号:Thinkpad E15

系统版本:centos8

案例:在sdb盘上建一个分区,大小为1G

在虚拟机上添加一块硬盘

 

linux一般怎么分区

例:对sdb这块盘划分一个100M的分区出来

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

...

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   删除分区

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   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): p   -----打印分区表

Command (m for help): n   ----新建一个分区

Partition type:

   p   primary (2 primary, 0 extended, 2 free)    p:主分区

   e   extended                         e:扩展分区

Select (default p):     --#直接默认

Using default response p

Partition number (1,4, default 1):   ---#直接默认

First sector (1230848-41943039, default 1230848):   ---#直接默认 

Using default value 1230848

Last sector, +sectors or +size{K,M,G} (1230848-41943039, default 41943039): +1G 

#输入分区大小

Partition 3 of type Linux and of size 1 GiB is set

Command (m for help): w   #保存退出

格式化并创建文件系统

[root@xuegod63 ~]# mkfs.xfs  /dev/sdb1   

注:-f 参数可以对已经存在文件系统的分区,强制格式化

[root@xuegod63 ~]# mkdir /sdb1   #创建挂载点

[root@xuegod63 ~]# mount /dev/sdb1 /sdb1/#挂载

[root@xuegod63 ~]# df -h    #查看

总结: 

1. 添加硬盘

2. fdisk /dev/sdb创建分区

3. mkfs.xfs /dev/sdb1格式化并创建文件系统

4. 创建挂载目录/sdb1

5. 挂载/dev/sdb1到/sdb1

标签: linux 分区
  • 文章版权属于文章作者所有,转载请注明 https://dongkepu.com/itkeji/79x8r.html