day20-磁盘管理

02.磁盘分区
面试题:
1.小于2TB的磁盘 使用fdisk分区   MBR
2.大于2TB的磁盘 使用parted分区  GPT

对小于2T的磁盘分区: fdisk
第一步: 添加一块新的硬盘
vmware: 右键--->设置-->添加-->硬盘--》下一步
物理机: 拿到新的硬盘-->直接插入到面板处即可  支持热插拔
云服务器: 阿里云 亚马逊云 在线磁盘扩容

第二步: 查看是否可以识别到第二块磁盘
[root@oldboy:~]# fdisk -l 重启生效
[root@oldboy:~]# reboot

[root@oldboy:~]# fdisk -l
Disk /dev/sdb: 500 GiB, 536870912000 bytes, 1048576000 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

第三步: 磁盘分区  类似打隔断
[root@oldboy:~]# fdisk /dev/sdb
Command (m for help): m			 # 按m 显示菜单
Help:
   d   delete a partition		 # 删除分区
   n   add a new partition		 # 创建分区
   p   print the partition table # 打印分区
   m   print this menu			 # 显示菜单
   w   write table to disk and exit # 保存并退出
   q   quit without saving changes  # 退出不保存

Command (m for help): n    		# 创建分区
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 			# 创建主分区

Using default response p.
Partition number (1-4, default 1): 		# 分区的编号 sdb1
First sector (2048-1048575999, default 2048):  # 开始的大小
Last sector, +/-sectors or +/-size{
   
   K,M,G,T,P} (2048-1048575999, default 1048575999): +100G #分区大小

Command (m for help): p			# 查看分区表
Device     Boot Start       End   Sectors  Size Id Type
/dev/sdb1        2048 209717247 209715200  100G 83 Linux

Command (m for help): n		    #分区
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p):

Using default response p.
Partition number (2-4, default 2):  # 分区编号
First sector (63-1048575999, default 63):
Last sector, +/-sectors or +/-size{
   
   K,M,G,T,P} (63-1048575999, default 1048575999): +100G # 大小
Created a new partition 2 of type 'Linux' and of size 100 GiB.


Command (m for help): d		# 删除分区
Partition number (1-4, default 4):   # 默认删除最后面的编号


划分扩展分区:
Command (m for help): n
Partition type
   p   primary (3 primary, 0 extended, 1 free)
   e   extended (container for logical partitions)
Select (default e):

Using default response e.
Selected partition 4
First sector (419432449-1048575999, default 419432449):
Last sector, +/-sectors or +/-size{
   
   K,M,G,T,P} (419432449-1048575999, default 1048575999): # 直接回车给所有的空间

基于扩展分区划分逻辑分区:
Command (m for help): n
All primary partitions are in use.
Adding logical partition 5
First sector (419432512-1048575999, default 419432512):
Last sector, +/-sectors or +/-size{
   
   K,M,G,T,P} (419432512-1048575999, default 1048575999): +100G  # 第一个逻辑分区给100G

Created a new partition 5 of type 'Linux' and of size 100 GiB.


查看最后的分区结果:
Command (m for help): p
Device     Boot     Start        End   Sectors  Size Id Type
/dev/sdb1            2048  209717247 209715200  100G 83 Linux
/dev/sdb2              63  209715263 209715201  100G 83 Linux
/dev/sdb3       209717248  419432448 209715201  100G 83 Linux
/dev/sdb4       419432449 1048575999 629143551  300G  5 Extended
/dev/sdb5       419432512  629147712 209715201  100G 83 Linux
/dev/sdb6       629147776 1048575999 419428224  200G 83 Linux

Command (m for help): w 	#保存并且推出


查看磁盘分区信息:
[root
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值