Linux下磁盘分区调整(在不使用LVM的情况下)

当硬盘分区不使用LVM的时候,将不能使用lvresize等指令调整


在调整分区之前,先来了解一下当前的磁盘分区信息
1:使用Fdisk指令查看后发现sda1的分区有195309568个Sectors(扇区)
每个扇区有512字节,所以总共有99998498816字节
================================================================
root@X9DRLiF:~# fdisk -l /dev/sda
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7eefe6fa

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 195311615 195309568 93.1G 83 Linux
/dev/sda2 * 453236736 468860927 15624192 7.5G 83 Linux
================================================================


2:使用resize2fs发现sda1的文件系统有24413696个blocks(块),
所以总共有99998498816字节
================================================================
root@X9DRLiF:~# resize2fs /dev/sda1
resize2fs 1.42.13 (17-May-2015)
The filesystem is already 24413696 (4k) blocks long. Nothing to do!
================================================================
用resize2fs调整如果超过了分区的界限就会有错误,可以用这个方法还原回去
resize2fs -f /dev/sda1 24413696
这里的24413696可以通过Sectors*512/4096所得

3:开始减小ext4分区,调整到200G-1M=204799M*(256)=52428544blocks
root@X9DRLiF:~# resize2fs -f /dev/sda1 52428544
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/sda1 is mounted on /mnt/data; on-line resizing required
resize2fs: On-line shrinking not supported
这里应该先umount,如果umount不了就用fuser -k /mnt/data
===========================================================
root@X9DRLiF:~# resize2fs -f /dev/sda1 52428544
resize2fs 1.42.13 (17-May-2015)
Resizing the filesystem on /dev/sda1 to 52428544 (4k) blocks.
The filesystem on /dev/sda1 is now 52428544 (4k) blocks long.

4:然后用fdisk调整(就是d删除,n新建分区)
===================下面是调整后的样子==================
root@X9DRLiF:~# fdisk -l /dev/sda
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7eefe6fa

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 419430399 419428352 200G 83 Linux
/dev/sda2 * 453236736 468860927 15624192 7.5G 83 Linux
====================================================================
这里的/dev/sda1的Sectors为419428352,除以8,刚好是block的值

 

转载于:https://www.cnblogs.com/firadio/p/6351718.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值