贴一篇自己写的Linux在线硬盘扩容的几种解决办法,算是经验总结吧。 注:转帖请注明出处!
If disk space not enough issue can't be fixed by deleted unused or unnecessary temp files. We could use resize2fs command to extend the disk space on line, will not infect the system.
I neatened a guide in details about how to extend the disk space on line including the normal situation and abnormal status here.
resize2fs - ext2/ext3/ext4 file system resize, listed on different RHEL system, the according command. Ps. Should use root account do the admin operation.
On RHEL6 # e.g. /sbin/resize2fs/dev/vg00/lvol9
On RHEL5 # e.g. /sbin/resize3fs/dev/vg00/lvol9
On RHEL4 # e.g. /sbin/ext2online/dev/vg00/lvol9
The resize2fs program will resize ext2, ext3, or ext4 file systems. It can be used to enlarge or shrink an un-mounted file system located on device.
If the file system is mounted, it can be used to expand the size of the mounted file system, assuming the kernel supports on-line resizing. (As of
this writing, the Linux 2.6 kernel supports on-line resize for file-systems mounted using ext3 only). Using the command to check the kernel version
# uname -r
2.6.32-71.el6.x86_64
Normal Situation
1. Extended the disk space on line:
# /sbin/tune2fs -l /dev/mapper/vg00-lvol9 //To check how much space we can extend.
# /usr/sbin/vgdisplay //To check whether it can be extended or not.
Free PE / Size 30354 / 118.57 GiB
# df -h /opt //To check where it will be extended
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lvol9
50G 0G 50G 100% /opt
# /usr/sbin/lvextend -L+5G /dev/mapper/vg00-lvol9 //Extend on line.
# /sbin/resize2fs /dev/vg00/lvol9 //To take it into effect
Abnormal Situation
1. Situation when device is busy
# fuser -m /opt //identify processes using files or sockets
/opt: 1244c 2721c 16747c 19635c
# kill -9 1244 2721 16747 19635 //kill all the processes.
# umount /opt //umount the directory
# /sbin/resize2fs /dev/vg00/lvol9
resize2fs 1.35 (28-Feb-2004)
Please run 'e2fsck -f /dev/vg00/lvol9' first.
# e2fsck -f /dev/vg00/lvol9 //To check ext2|ext3|ext4 file system correctness!
e2fsck 1.35 (28-Feb-2004)
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/vg00/lvol9: 1406312/6553600 files (2.8% non-contiguous), 12277130/13107200 blocks
# /sbin/resize2fs /dev/vg00/lvol9
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/vg00/lvol9 to 14417920 (4k) blocks.
The filesystem on /dev/vg00/lvol9 is now 14417920 blocks long.
# mount /opt
# df -h /opt
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lvol9
55G 47G 5.4G 90% /opt
2. Situation when volume group mapper doesn't exist…
# /usr/sbin/lvextend -L+5G /dev/mapper/vg00-lvol9
Volume group mapper doesn't exist
# /usr/sbin/lvextend -L+5G /dev/vg00/lvol9
3. Situation when iNode of '/' directory is full…
# df -ih//To check the iNode usage touched 100% or not. If it is. Extended / directory first, after that then adding others disk space.
<p></p><pre code_snippet_id="182965" snippet_file_name="blog_20140210_1_8231303">