RedHat Linux磁盘空间不足 和 挂载新硬盘方法


说一台很旧的 RedHat机器硬盘空间不足,去df -m查看下

[root@192.168.14.117:/root]#df -m
Filesystem           1M-blocks      Used        Available Use% Mounted on
/dev/sda3                17599       15619      1072          94%   /
/dev/sda1                  251         16             223           7%     /boot
tmpfs                      760            0               760           0%     /dev/shm
/dev/sdb3                30236       23542      5159          83%   /data

原来是因为本来空间就不大,只有50多个G,du一路查下去,发现是cgi的日志文件和so的core文件占用了很大的空间,但是想想也没啥可清理的了。(注:检查磁盘空间占用,可以用du -ah --max-depth=1,打印当前目录下,各个文件大小和目录的磁盘空间占用情况,也可以在后面指定显示某个目录的子目录和文件空间占用信息)

因为还有一块20G的老硬盘闲置在那里,所以就干脆把它挂上去。

1、拆机,硬盘挂上

2、重启机器,fdisk -l 查看

[root@192.168.14.117:/dev]#fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id System
/dev/sda1   *           1          33      265041   83 Linux
/dev/sda2              34         294     2096482+ 82 Linux swap / Solaris
/dev/sda3             295        2610    18603270   83 Linux

Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id System
/dev/sdb3               1        3916    31455238+ 83 Linux

Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

很好,刚挂上去的第三块盘认到了,sdc,21.4G,不过盘上还没有任何分区。

3、创建分区。执行 fdisk /dev/sdc

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 2610.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):

提示我输入命令,可怜的记不住命令,只能打一个m,for help了 ^-^

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   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)

大概看了一个m出来的命令,毫不犹豫选择了 n ,添加一个新分区

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-2610, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): 
Using default value 2610

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

最后一个w是把分区信息写入磁盘并退出fdisk。

然后执行fdisk -l

[root@192.168.14.117:/dev]#fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id System
/dev/sda1   *           1          33      265041   83 Linux
/dev/sda2              34         294     2096482+ 82 Linux swap / Solaris
/dev/sda3             295        2610    18603270   83 Linux

Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id System
/dev/sdb3               1        3916    31455238+ 83 Linux

Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id System
/dev/sdc1               1        2610    20964793+   5 Extended

得意忘形了一下,然后直接执行

mount /dev/sdc1 /datalog

就被泼了冷水

[root@192.168.14.117:/dev]#mount /dev/sdc1 /datalog
mount: you must specify the filesystem type
[root@192.168.14.117:/dev]#mount -t ext3 /dev/sdc1 /datalog
mount: wrong fs type, bad option, bad superblock on /dev/sdc1,
       missing codepage or other error
       (aren't you trying to mount an extended partition,
       instead of some logical partition inside?)
       In some cases useful info is found in syslog - try
       dmesg | tail or so

才想到创建了逻辑盘还没有创建逻辑分区呢,也没有创建文件系统,然后再执行一下:fdisk /dev/sdc

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (1-2610, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): 
Using default value 2610

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

再查看一下

[root@192.168.14.117:/root]#fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id System
/dev/sda1   *           1          33      265041   83 Linux
/dev/sda2              34         294     2096482+ 82 Linux swap / Solaris
/dev/sda3             295        2610    18603270   83 Linux

Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id System
/dev/sdb3               1        3916    31455238+ 83 Linux

Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id System
/dev/sdc1               1        2610    20964793+   5 Extended
/dev/sdc5               1        2610    20964762   83 Linux

很好,一切正常

4、创建文件系统

执行mkfs.ext3 /dev/sdc5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5241190 blocks
262059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
160 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

正常

5、挂载到根目录下的datalog目录

mount /dev/sdc5 /datalog

再执行df

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3             18020368 15983692   1106516 94% /
/dev/sda1               256666     15923    227491   7% /boot
tmpfs                   777688         0    777688   0% /dev/shm
/dev/sdb3             30961664 24018284   5370620 82% /data
/dev/sdc5             20635668    176200 19411232   1% /datalog

都正常了。完美解决。

Linux环境下,处理磁盘空间已满,导致数据库无法正常使用的处理方法: 第一步:查看磁盘空间的使用情况 df -f 第二步:找到日志文件,并清理 1) 进入跟目录 cd / 2)查找日志文件(区分大小写) find -name *.Log; find -name *.log; find -name *.000; 第三步:进入到相应的目录,并删除日志文件 如: cd ./home1/data/db2inst2/NODE0000/SQL00001/SQLOGDIR/; rm -f *.LOG; 或者 rm -f *.log; 或者 rm -f *.000; linux下DB2管理命令 1:进入实例 su - db2inst2 2:查看某个库的表空间 db2pd -tablespaces -db mcmxfb 3:查看这个模式下所有活动库的表空间 db2pd -tablespaces -alldbs option and active database; 4: 系统重启后,对数据库的重启,首先要进入到实例下,再执行重启数据库的命令。系统会重启这个实例下的各个数据库 db2start; (注意,不同的实例,要分别进入各个实例,再重启); root用户下,重启系统的方法: 重启命令: 1、reboot 2、shutdown -r now 立刻重启(root用户使用) 3、shutdown -r 10 过10分钟自动重启(root用户使用) 4、shutdown -r 20:35 在时间为20:35时候重启(root用户使用) 关机命令: 1、halt 立刻关机 2、poweroff 立刻关机 3、shutdown -h now 立刻关机(root用户使用) 4、shutdown -h 10 10分钟后自动关机 Linux环境下,磁盘空间已满,导致db2数据库无法正常使用。这里解决的,主要是日志文件和环境文件占用磁盘空间太多所引起问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值