找回密码
 开放注册

QQ登录

只需一步,快速开始

微信登录

微信扫码,快速开始

搜索
查看: 817|回复: 1

linux磁盘空间不足 和 挂载新硬盘 (1)

[复制链接]

155

主题

15

回帖

360

牛毛

一级牛人

积分
360
发表于 2011-9-28 14:34:46 | 显示全部楼层 |阅读模式 来自 河北省石家庄市
  早上同事报告说一台很旧的RedHat机器硬盘空间不足,去df -m查看下
  [root@192.168.14.117:/root]#df -m
  Filesystem           1M-blocks      Used        Available Use% Mounted on
  /dev/sda3                17***99       15***19      1072          94%   /
  /dev/sda1                  251         16             223           7%     /boot
  tmpfs                      760            0               760           0%     /dev/shm
  /dev/sdb3                30***36       23***42      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, 214****6480 bytes
  255 heads, 63 sectors/track, 2610 cylinders
  Units = cylinders of 16***65 * 512 = 82***80 bytes
  Device Boot      Start         End      Blocks   Id System
  /dev/sda1   *           1          33      26***41   83 Linux
  /dev/sda2              34         294     20***82+ 82 Linux swap / Solaris
  /dev/sda3             295        2610    186****3270   83 Linux
  Disk /dev/sdb: 32.2 GB, 322****4720 bytes
  255 heads, 63 sectors/track, 3916 cylinders
  Units = cylinders of 16***65 * 512 = 82***80 bytes
  Device Boot      Start         End      Blocks   Id System
  /dev/sdb3               1        3916    314****5238+ 83 Linux
  Disk /dev/sdc: 21.4 GB, 214****6480 bytes
  255 heads, 63 sectors/track, 2610 cylinders
  Units = cylinders of 16***65 * 512 = 82***80 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, 214****6480 bytes
  255 heads, 63 sectors/track, 2610 cylinders
  Units = cylinders of 16***65 * 512 = 82***80 bytes
  Device Boot      Start         End      Blocks   Id System
  /dev/sda1   *           1          33      26***41   83 Linux
  /dev/sda2              34         294     20***82+ 82 Linux swap / Solaris
  /dev/sda3             295        2610    186****3270   83 Linux
  Disk /dev/sdb: 32.2 GB, 322****4720 bytes
  255 heads, 63 sectors/track, 3916 cylinders
  Units = cylinders of 16***65 * 512 = 82***80 bytes
  Device Boot      Start         End      Blocks   Id System
  /dev/sdb3               1        3916    314****5238+ 83 Linux
  Disk /dev/sdc: 21.4 GB, 214****6480 bytes
  255 heads, 63 sectors/track, 2610 cylinders
  Units = cylinders of 16***65 * 512 = 82***80 bytes
  Device Boot      Start         End      Blocks   Id System
  /dev/sdc1               1        2610    209****4793+   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, 214****6480 bytes
  255 heads, 63 sectors/track, 2610 cylinders
  Units = cylinders of 16***65 * 512 = 82***80 bytes
  Device Boot      Start         End      Blocks   Id System
  /dev/sda1   *           1          33      26***41   83 Linux
  /dev/sda2              34    &nb
本文由:SKF轴承 http://wwww.9-zc.com 整理发布

4

主题

745

回帖

801

牛毛

一级牛人

积分
801
发表于 2011-9-29 11:59:32 | 显示全部楼层 来自 广东省珠海市香洲区
安全很重要啊
您需要登录后才可以回帖 登录 | 开放注册

本版积分规则

帮助|Archiver|小黑屋|通信管理局专项备案号:[2008]238号|NB5社区 ( 皖ICP备08004151号;皖公网安备34010402700514号 )

GMT+8, 2025-4-25 14:59 , Processed in 0.234961 second(s), 38 queries .

Powered by Discuz! X3.5

快速回复 返回顶部 返回列表