Linux下磁盤分區調整(在不使用LVM的狀況下)

當硬盤分區不使用LVM的時候,將不能使用lvresize等指令調整ide


在調整分區以前,先來了解一下當前的磁盤分區信息
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: 0x7eefe6faui

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
================================================================it


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所得require

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.file

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的值im

相關文章
相關標籤/搜索