登录linux服务器,执行以下命令:
fdisk -l输出以下信息:
Disk /dev/vda: 32.2 GB, 32212254720 bytes, 62914560 sectorsUnits = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c1d0e
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 61442047 30720000 83 Linux
Disk /dev/vdb: 75.2 GB, 75161927680 bytes, 146800640 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000cc312
Device Boot Start End Blocks Id System
/dev/vdb1 2048 146800639 73399296 83 Linux
说明:测试服务器有两个分区,vda1和vdb1。
效果图:
2.删除vdb1分区,执行以下命令:
fdisk /dev/vdb1接着输入:
d然后选择分区号
最后输入w保存。
注意事项:删除分区前备份数据。
分区示例:比如分/dev/sda 硬盘#: fdisk /dev/sdaThe number of cylinders for this disk is set to 19457.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)Command (m for help): m #帮助,输入MCommand actiona toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partition 删除一个分区l list known partition typesm print this menun add a new partition 创建一个新的分区o create a new empty DOS partition tablep print the partition table 打印分区表q quit without saving changes 退出不保存s create a new empty Sun disklabelt change a partition\'s system id 改变分区类型u change display/entry units 改变显示/输入的单位v verify the partition table 验证这个分区表w write table to disk and exit 保存退出x extra functionality (experts only)Command (m for help): d #删除分区Partition number (1-8): 2Command (m for help): p # 打印分区表Disk /dev/sda: 160.0 GB, 160041885696 bytes255 heads, 63 sectors/track, 19457 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0x0003ce53Device Boot Start End Blocks Id System/dev/sda1 * 13825307200007 HPFS/NTFS/dev/sda37650 11474307200007 HPFS/NTFS/dev/sda4 11475 1945764123447+ 5 Extended/dev/sda5 11475 1444423856472+ 7 HPFS/NTFS/dev/sda6 19247 19457 1694826 82 Linux swap / Solaris/dev/sda7 14445 15660 9767488+ 83 Linux/dev/sda8 15661 1924628804513+ 83 LinuxPartition table entries are not in disk orderCommand (m for help): n #建立新分区Command actionl logical (5 or over)p primary partition (1-4)p #主分区Selected partition 2First cylinder (3825-19457, default 3825): 可以选Using default value 3825Last cylinder, +cylinders or +size{K,M,G} (3825-7649, default 7649): 输入分区大小 比如100GUsing default value 7649Command (m for help):1、定期对重要文件系统扫描,并作对比,分析那些文件经常读写
#ls–lR/home>files.txt
#diff filesold.txt files.txt
通过分析预测空间的增长情况,同时可以考虑对不经常读写的文件进行压缩,以减少占用空间。
2、查看空间满的文件系统的inodes消耗
#df -i/home
如果还有大量inode可用,说明大文件占用空间,否则是可能大量小文件占用空间。
3、找出占用空间较大的目录
查看/home占用的空间
#du -hs/home
查看/home下占用空间超过1000m
#du |awk '$1>2000'
4、找出占用空间较大的文件
#find /homesize+2000k
5、找出最近修改或创建的文件
先touch一个你想要的时间的文件如下:
# touch-t 08190800 test
#find/home -newer test -print
6、删除系统日志等
删除生成core,mbox等文件
#find/ -name core|xargs rm -rf
删除日志
#rm -rf/var/log/*
7、对分区做链接
在有空间的分区,对没有空间分区做链接
#ln -s /home/usr/home
8、找出耗费大量的空间的进程
根据不同的应用,找出对应的进程,分析原因
9、检查并修复文件系统
#fsck -y/home
10、重启机器
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)