磁盘管理 - parted、resize2fs、e2fsck扩容分区

admin 2020-06-20 PM 165℃ 0条

一、分区扩容

   思路:parted先删除原有分区, 重建分区,用e2fsck检查一下分区, 再用resize2fs扩容分区文件系统

[root@kvm ~]# fuser -m -k /home   //结束占用home的进程,可以加一个-i 参数,杀死一个程序前,会询问

[root@kvm ~]# umount /home

[root@kvm ~]# parted /dev/sdc

GNU Parted 3.1

Using /dev/sdc

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted)print

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdc: 21.5GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:


Number  Start   End     Size    File system  Name  Flags

 1      1049kB  5000MB  4999MB  ext4


(parted) rm 1   //删除分区重建

(parted) mkpart

Partition name?  []?

File system type?  [ext2]?

Start? 1049kB

End? 100%

(parted) print

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sdc: 21.5GB

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:


Number  Start   End     Size    File system  Name  Flags

 1      1049kB  21.5GB  21.5GB  ext4


(parted) quit

Information: You may need to update /etc/fstab.


[root@kvm ~]# e2fsck -f /dev/sdc1   //检查分区

e2fsck 1.42.9 (28-Dec-2013)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/sdc1: 12/305216 files (0.0% non-contiguous), 56703/1220352 blocks

[root@kvm ~]# resize2fs /dev/sdc1   //扩容分区

resize2fs 1.42.9 (28-Dec-2013)

Resizing the filesystem on /dev/sdc1 to 5242368 (4k) blocks.

The filesystem on /dev/sdc1 is now 5242368 blocks long.


[root@kvm ~]# mount /dev/sdc1 /home   //重新挂载分区

[root@kvm ~]# df -h

Filesystem                   Size  Used Avail Use% Mounted on

devtmpfs                     899M     0  899M   0% /dev

tmpfs                        910M     0  910M   0% /dev/shm

tmpfs                        910M   50M  861M   6% /run

tmpfs                        910M     0  910M   0% /sys/fs/cgroup

/dev/mapper/centos-root      9.0G  2.1G  6.9G  23% /

/dev/sda1                   1014M  187M  828M  19% /boot

tmpfs                        182M     0  182M   0% /run/user/0

/dev/sdc1                     20G   26M   19G   1% /home


标签: parted, resize2fs, e2fsck

非特殊说明,本博所有文章均为博主原创。