1、卸载主分区
[root@wrx ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 5.5G 12G 33% / tmpfs 495M 72K 495M 1% /dev/shm /dev/sda1 291M 34M 242M 13% /boot /dev/sdb1 20G 172M 19G 1% /data
#卸载 [root@wrx ~]# umount /dev/sdb1
[root@wrx ~]# umount /dev/sdb1 umount: /data: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1)) #卸载时如果出现上面的情况可以使用fuser命令 [root@wrx ~]# fuser -m /data -k /data: 2305c 2322c
#查看是否卸载成功 [root@wrx ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 5.5G 12G 33% / tmpfs 495M 72K 495M 1% /dev/shm /dev/sda1 291M 34M 242M 13% /boot
2、使用fdisk删除原来分区,并创建新分区
[root@wrx ~]# fdisk /dev/sdb 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): Using default value 2610 Command (m for help): wq The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks
3、检查文件系统,并变更文件系统大小
[root@wrx ~]# e2fsck -f /dev/sdb1 e2fsck 1.41.12 (17-May-2010) 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/sdb1: 11/655776 files (0.0% non-contiguous), 79700/2622603 blocks [root@wrx ~]# resize2fs /dev/sdb1 resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/sdb1 to 5241198 (4k) blocks. The filesystem on /dev/sdb1 is now 5241198 blocks long. [root@wrx ~]#
4、将扩容后的文件系统挂载到原来挂载点下
[root@wrx ~]# mount /dev/sdb1 /data [root@wrx ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 18G 5.5G 12G 33% / tmpfs 495M 72K 495M 1% /dev/shm /dev/sda1 291M 34M 242M 13% /boot /dev/sdb1