容器技术交流

 找回密码
 立即注册
查看: 5779|回复: 1

Centos系统挂载硬盘

[复制链接]
发表于 2012-5-27 20:46:46 | 显示全部楼层 |阅读模式
星外默认centos系统的硬盘是10g,当开通硬盘大于10g的时候就需要,开通后手动的挂载
  1. [root@localhost ~]# fdisk -l  

  2. Disk /dev/hda: 21.4 GB, 21474836480 bytes  
  3. 255 heads, 63 sectors/track, 2610 cylinders  
  4. Units = cylinders of 16065 * 512 = 8225280 bytes  

  5.    Device Boot      Start         End      Blocks   Id  System  
  6. /dev/hda1   *           1          13      104391   83  Linux  
  7. /dev/hda2              14        1305    10377990   8e  Linux LVM  
  8. [root@localhost ~]# df -h  
  9. 文件系统              容量  已用 可用 已用% 挂载点  
  10. /dev/mapper/VolGroup00-LogVol00  
  11.                       7.7G  1.9G  5.4G  27% /  
  12. /dev/hda1              99M   22M   73M  23% /boot  
  13. tmpfs                 252M     0  252M   0% /dev/shm  
复制代码
如上所示/dev/dha硬盘总大小是21G,实际VolGroup00-LogVol00只有7.7G的空间
下面的步骤就是把剩余的空闲硬盘都增加到VolGroup00-LogVol00逻辑卷中

1.使用fdisk创建LVM分区
fdisk /dev/hda
  1. [root@localhost ~]# fdisk /dev/hda  

  2. The number of cylinders for this disk is set to 2610.  
  3. There is nothing wrong with that, but this is larger than 1024,  
  4. and could in certain setups cause problems with:  
  5. 1) software that runs at boot time (e.g., old versions of LILO)  
  6. 2) booting and partitioning software from other OSs  
  7.    (e.g., DOS FDISK, OS/2 FDISK)  

  8. Command (m for help): n  
  9. Command action
  10.    e   extended  
  11.    p   primary partition (1-4)  
  12. p  
  13. Partition number (1-4): 3  
  14. First cylinder (1306-2610, default 1306):  
  15. Using default value 1306  
  16. Last cylinder or +size or +sizeM or +sizeK (1306-2610, default 2610):  
  17. Using default value 2610  
复制代码
输入n增加分区
输入p类型设置为:主分区
输入3分区编号设置为3
回车 为默认大小
回车 为默认 大小
然后再设置分区的类型
  1. Command (m for help): t  
  2. Partition number (1-4): 3  
  3. Hex code (type L to list codes): 8e  
  4. Changed system type of partition 3 to 8e (Linux LVM)
复制代码
输入t 设置分区类型
输入3 3号分区
输入8e 设置为LVM
  1. Command (m for help): p  

  2. Disk /dev/hda: 21.4 GB, 21474836480 bytes  
  3. 255 heads, 63 sectors/track, 2610 cylinders  
  4. Units = cylinders of 16065 * 512 = 8225280 bytes  

  5.    Device Boot      Start         End      Blocks   Id  System  
  6. /dev/hda1   *           1          13      104391   83  Linux  
  7. /dev/hda2              14        1305    10377990   8e  Linux LVM  
  8. /dev/hda3            1306        2610    10482412+  8e  Linux LVM
复制代码
输入p 打印分区表 (可以看到刚刚创建的/dev/hda3)
  1. Command (m for help): v  
  2. 13452 unallocated sectors  

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

  5. Calling ioctl() to re-read partition table.  

  6. WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.  
  7. The kernel still uses the old table.  
  8. The new table will be used at the next reboot.  
  9. Syncing disks.  
复制代码
输入v  检查分区表
输入w 写入分区表
提示当先的内核依然是使用的旧的分区表,
新写入的分区表在下次重启后生效
输入q  退回fdisk

2.使用reboot或init 6来重启系统(重要!!!)

此时使用fdisk -l来查看分区是否成功的创建
  1. [root@localhost ~]# fdisk -l  

  2. Disk /dev/hda: 21.4 GB, 21474836480 bytes  
  3. 255 heads, 63 sectors/track, 2610 cylinders  
  4. Units = cylinders of 16065 * 512 = 8225280 bytes  

  5.    Device Boot      Start         End      Blocks   Id  System  
  6. /dev/hda1   *           1          13      104391   83  Linux  
  7. /dev/hda2              14        1305    10377990   8e  Linux LVM  
  8. /dev/hda3            1306        2610    10482412+  8e  Linux LVM
复制代码
3.创建物理卷pv

pvcreate /dev/hda3
  1. [root@localhost ~]# pvcreate /dev/hda3  
  2.   Physical volume "/dev/hda3" successfully created  
复制代码
查看已经创建的pv
pvscan;pvdisplay
  1. [root@localhost ~]# pvscan  
  2.   PV /dev/hda2   VG VolGroup00      lvm2 [9.88 GB / 0    free]  
  3.   PV /dev/hda3                      lvm2 [10.00 GB]  
  4.   Total: 2 [19.87 GB] / in use: 1 [9.88 GB] / in no VG: 1 [10.00 GB]  
复制代码
4.添加/dev/hda3到默认的卷组VolGroup00

vgextend VolGroup00 /dev/hda3
  1. [root@localhost ~]# vgextend VolGroup00 /dev/hda3  
  2.   Volume group "VolGroup00" successfully extended
复制代码
查看是否添加正确
vgscan;vgdisplay

5.把所有卷组里的空闲硬盘增加到/dev/VolGroup00/LogVol00

lvextend -l +100%free /dev/VolGroup00/LogVol00
  1. [root@localhost ~]# lvextend -l +100%free /dev/VolGroup00/LogVol00  
  2.   Extending logical volume LogVol00 to 17.84 GB  
  3.   Logical volume LogVol00 successfully resized
复制代码
查看逻辑卷的大小

lvscan;lvdisplay
  1. [root@localhost ~]# lvscan  
  2.   ACTIVE            '/dev/VolGroup00/LogVol00' [17.84 GB] inherit  
  3.   ACTIVE            '/dev/VolGroup00/LogVol01' [2.00 GB] inherit
复制代码
/dev/VolGroup00/LogVol00为当前硬盘
/dev/VolGroup00/LogVol01为系统交换分区

6.最后使用resize2fs来让系统识别硬盘

resize2fs /dev/VolGroup00/LogVol00
  1. [root@localhost ~]# resize2fs /dev/VolGroup00/LogVol00  
  2. resize2fs 1.39 (29-May-2006)  
  3. Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required  
  4. Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4677632 (4k) blocks.  
  5. The filesystem on /dev/VolGroup00/LogVol00 is now 4677632 blocks long.  
复制代码
df -h查看添加后的硬盘大小
  1. [root@localhost ~]# df -h  
  2. 文件系统              容量  已用 可用 已用% 挂载点  
  3. /dev/mapper/VolGroup00-LogVol00  
  4.                        18G  1.9G   15G  12% /  
  5. /dev/hda1              99M   22M   73M  23% /boot  
  6. tmpfs                 252M     0  252M   0% /dev/shm
复制代码
本文来自:http://sweetsingle.blog.51cto.com/3429592/751933
发表于 2012-5-29 23:43:47 | 显示全部楼层
提心吊胆的执行完全部步骤
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Archiver|URLOS ( 粤ICP备18087780号 )

GMT+8, 2024-4-27 10:59 , Processed in 0.032356 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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