/dev/mapper/volgroup-lv_root is a logical volume, and you can see that it is associated with the "/" root partition through the df–h command, which you can also understand as the root partition.
[[email protected] ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 18G 1.2G 16G 7% /tmpfs 495M 0 495M 0% /dev/shm/dev/sda1 485M 32M 428M 7% /boot
There are two possibilities for a full partition: The inode is filled and the block is full.
First, the inode is full.
For example: If your scheduled task Cron does not do standard output and standard error output redirection, just do not start the mail service, then the Mail queue directory/var/spool/clientmquene, there will be a large number of log files (small files), consumes the partition of the Inode, Cause the disk to be full. The Clientmquene directory is a temporary queue for sendmail messages only if the SendMail service is installed. centos5.8 installed by default sendmail,centos6.6 is not sendmail by default, but Postfix.
[[email protected] ~]# df –i 查看分区inode使用情况Filesystem Inodes IUsed IFree IUse% Mounted on/dev/mapper/VolGroup-lv_root 1152816 38319 1114497 4% /tmpfs 126568 1 126567 1% /dev/shm/dev/sda1 128016 38 127978 1% /boot
Processing method:
The first is to clean up the/var/spool/clientmquene directory, emptying it, but this is only a temporary solution to the root, want to once and for all, but also in the scheduled task cron to do standard redirection, and recommended to increase the regular cleanup server log files scheduled tasks.
vim /var/spool/cron/root 00 00 * * * /bin/sh /server/scripts/tar_rsync_del.sh >/dev/null 2>&1
Second, the block is full.
The inode is primarily used to store the attributes of the file, and the block stores the data content, which is what we want to preserve. Block full, usually large files are often caused, it is easy to solve, find out, confirm whether it is important files, not delete, otherwise you have to expand the partition.
You can use DF and du to locate which directory in which partition occupies a large disk capacity. Df–h Locate the partition, du–sh the size of each directory under the view partition.
[[email protected] ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 18G 1.2G 16G 7% /tmpfs 495M 0 495M 0% /dev/shm/dev/sda1 485M 32M 428M 7% /boot/dev/sdb1 8.9G 149M 8.3G 2% /home[[email protected] ~]# du -sh /*6.1M /bin22M /boot232K /dev24M /etc20K /home134M /lib21M /lib64
Of course, can also directly find find out more than 100M files, how much, their own decision.
find / -type f -size +100M –exec ls –lh \;
If the confirmation is a junk file or an unimportant file that has a backup, you can consider deleting
find / -type f -size +100M –exec rm {} \;或find / -type f –size +100M |xargs rm –f
The use of the Find command, followed by a special article, the command in the work of a very large, useful tool.
Root partition expansion
If you use a partition that is installed by default, you may allocate a lot of space to volgroup-lv_home, the/home partition, and the back of the host will not use much space at all, so it wastes a lot of disk resources, so you can cut the capacity of the home partition to the root partition. The other way is to increase the disk directly, and then allocate the new disk space to Volgroup-lv_root.
For security reasons, it is recommended that you back up your data before you expand.
Goal: Reduce the volgroup-lv_home to 20G and add the remaining space to the Volgroup-lv_root
1. Check disk usage First
[[[email protected] ~]# df -h文件系统 容量 已用 可用 已用% 挂载点Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 154G 7.9G 139G 6% /tmpfs 1.9G 100K 1.9G 1% /dev/shm/dev/sda1 485M 69M 391M 15% /boot/dev/mapper/VolGroup-lv_home 299G 984M 283G 1% /home
2. Uninstall/Home
[[email protected] ~]# umount /homeumount /home 如果提示无法卸载 [[email protected] ~]# umount –lf /home 强制卸载-f:强制卸载-l:清除与文件系统相关的引用
3. Adjust the partition size
[[email protected] ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 20G如果提示运行“e2fsck -f /dev/mapper/VolGroup-lv_home”,则执行相关命令: [[email protected] ~]# e2fsck -f /dev/mapper/VolGroup-lv_home 然后重新执行命令:[[email protected] ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 20G
Note: resize2fs to reset the disk size, just re-specify the size, do not affect the results, requires the following lvreduce mates
4. Mount Home/home to view disk usage
[[email protected] ~]# mount /home[[email protected] ~]# df -h
5. Set free space
Use the Lvreduce directive to reduce the amount of space that LVM logical volumes occupy. The data already on the logical volume may be deleted, so you must confirm it before the operation. Remember to enter "Y"
[[email protected] ~]# lvreduce -L 20G /dev/mapper/VolGroup-lv_home
Note: lvreduce-l 20G means to set the current file system to 20G if lvreduce-l 20G means to reduce 20G from the current file system
Use Lvreduce to reduce the size of the logical volume. Note: The reduced size cannot be less than the size of the file, otherwise the data will be lost.
You can use the Vgdisplay command to see what size you can manipulate. You can also use the FDISK-L command to view detailed information.
[[email protected] ~]# vgdisplay
Note: Vgdisplay is the metadata information for displaying LVM volume groups
6. Hang the unused space in the root directory
[[email protected] ~]# lvextend -L +283G /dev/mapper/VolGroup-lv_root注:lvextend -L +283G为在文件系统上增加283G[[email protected] ~]# resize2fs -p /dev/mapper/VolGroup-lv_root
7. Check the adjustment results
[[email protected] ~]# df -h
Adding new disks to Volgroup-lv_root
As mentioned earlier,/dev/mapper/volgroup-lv_root is a logical volume, and since it is a logical volume, it can be scaled to its volume group (resource pool).
[[email protected] ~]# df -h文件系统 容量 已用 可用 已用%% 挂载点/dev/mapper/VolGroup-lv_root 18G 1.2G 16G 7% /tmpfs 495M 0 495M 0% /dev/shm/dev/sda1 485M 32M 428M 7% /boot/dev/sdb1 8.9G 149M 8.3G 2% /home
Add a 10G disk and partition the disk, but do not mount it.
fdisk /dev/sdb 分区yum -y install parted 安装part工具partprobe /dev/sdb 告知内核分区表的更新mkfs.ext4 /dev/sdb1 格式化分区
Create a physical volume
[[email protected] ~]# pvcreate /dev/sdb1 如果分区挂载了则不可以 Can‘t open /dev/sdb1 exclusively. Mounted filesystem?[[email protected] ~]# umount /home[[email protected] ~]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created
查看卷组名
[[email protected] ~]# vgscan Reading all physical volumes. This may take a while... Found volume group "VolGroup" using metadata type lvm2
把新增的物理卷加入卷组
[[email protected] ~]# vgextend VolGroup /dev/sdb1 Volume group "VolGroup" successfully extended
Extended volgroup-lv_root logical volume, increased by 8G
[[email protected] ~]# lvextend -L +8G /dev/mapper/VolGroup-lv_root Extending logical volume lv_root to 25.57 GiB Logical volume lv_root successfully resized[[email protected] ~]# df -h文件系统 容量 已用 可用 已用%% 挂载点/dev/mapper/VolGroup-lv_root 18G 1.2G 16G 7% /tmpfs 495M 0 495M 0% /dev/shm/dev/sda1 485M 32M 428M 7% /boot
Then using the dh–f, we found that the actual capacity did not change, because our system does not know the file system of the disk just added, so we also need to expand the file system.
[[email protected] ~]# resize2fs -f /dev/mapper/VolGroup-lv_root resize2fs 1.41.12 (17-May-2010)Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing requiredold desc_blocks = 2, new_desc_blocks = 2Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 6703104 (4k) blocks.The filesystem on /dev/mapper/VolGroup-lv_root is now 6703104 blocks long.[[email protected] ~]# df -h文件系统 容量 已用 可用 已用%% 挂载点/dev/mapper/VolGroup-lv_root 26G 1.2G 23G 5% /tmpfs 495M 0 495M 0% /dev/shm/dev/sda1 485M 32M 428M 7% /boot
Root partition expansion idea: Using LVM management, using the relationship between Volume group (resource pool), physical volume, logical volume to expand, create physical volume, add volume group, expand the logical volume by volume group, and expand the file system after the logical volume is enlarged.
/dev/mapper/volgroup-lv_root full of two possible and root partition expansion