Linux下硬盘如何分区?

发布网友 发布时间:2022-03-20 19:49

我来回答

6个回答

懂视网 时间:2022-03-21 00:10

产品型号:Thinkpad E15

系统版本:centos8

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

在虚拟机上添加一块硬盘

例:对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    #查看


热心网友 时间:2022-03-20 21:18

/boot分120M够了,一般人不会超过3个内核,一个内核占用20M左右,其他配置文件都很小

swap分区1-2倍内存

剩下的给 /,个人使用没必要再细分了

热心网友 时间:2022-03-20 22:36

1.简单方案 /13g 内存大于等于2g不用swap
2.合理方案
/ 1g
/boot 100m
/usr >3g
/var 1g
/home 剩余空间

热心网友 时间:2022-03-21 00:11

交换分区---内存2倍
/boot---400m 足够
/ 将剩下的都给根

热心网友 时间:2022-03-21 02:02

最简单的
/swap 2G
/ ext3 剩余的全部
只有这两个就可以

热心网友 时间:2022-03-21 04:10

懒人的分法:/boot 100M
swap 内存的2倍,大内存的1~1.5倍
/ 剩下的全部空间

推荐的分法:/boot 100M(占用主分区!)
swap 内存的2倍,大内存的1~1.5倍
/ 10G
/var 1G
/home 剩下的全部空间

PS:据说把/usr分出来有点不好哦。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com