1、查看当前分区的硬盘使用情况:
2、查看当前的硬盘挂载点的数据完整性。弄个图片做个记号
3、使用fdisk 命令来进行删除之前的分区,不格式化重新新建新的分区
查看当前sdb1分区的柱面空间1–1306
[root@pp mnt]# fdisk -l | grep sdb1
/dev/sdb1 1 1306 10490413+ 83 Linux
4、进行扩容前需要先卸载之前的挂载
[root@pp /]# umount /dev/sdb1
5、再次查看当前分区情况
[root@pp /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 10G 0 part
sdc 8:32 0 20G 0 disk
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─VolGroup-lv_root (dm-0) 253:0 0 17.6G 0 lvm /
└─VolGroup-lv_swap (dm-1) 253:1 0 2G 0 lvm [SWAP]
6、进行删除当前分区并进行扩容。这里的主要是更改了该分区的结束柱面号。
[root@pp /]# fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +15G
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@pp /]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 15G 0 part
sdc 8:32 0 20G 0 disk
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─VolGroup-lv_root (dm-0) 253:0 0 17.6G 0 lvm /
└─VolGroup-lv_swap (dm-1) 253:1 0 2G 0 lvm [SWAP]
查看一下当前大小,请问怎么大小没有改变?
[root@pp /]# mount /dev/sdb1 /mnt/
[root@pp /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
18G 889M 16G 6% /
tmpfs 498M 0 498M 0% /dev/shm
/dev/sda1 477M 30M 422M 7% /boot
/dev/sdb1 9.9G 71M 9.5G 1% /mnt
[root@pp /]# resize2fs /dev/sdb
sdb sdb1
[root@pp /]# resize2fs /dev/sdb1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/sdb1 is mounted on /mnt; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/sdb1 to 3933909 (4k) blocks.
The filesystem on /dev/sdb1 is now 3933909 blocks long.
[root@pp /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
18G 889M 16G 6% /
tmpfs 498M 0 498M 0% /dev/shm
/dev/sda1 477M 30M 422M 7% /boot
/dev/sdb1 15G 72M 15G 1% /mnt
查看当前分区的开始和结束柱面
[root@pp /]# fdisk -l | grep /dev/sdb1
/dev/sdb1 1 1959 15735636 83 Linux