当硬盘分区不使用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的值

 

posted on 2017-01-26 16:33  飞儿传媒  阅读(8380)  评论(0编辑  收藏  举报
飞儿传媒