硬盘热添加
硬盘在进行添加时 不会显示在Linux上 所以我们需要对他进行设置
如果是在原有基础上进行添加 这时需要在原有盘上进行分区
[root@seafile ~]# fdisk /dev/sda欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。命令(输入 m 获取帮助):nPartition type:p primary (3 primary, 0 extended, 1 free)e extendedSelect (default e): p已选择分区 4起始 扇区 (125829120-209715199,默认为 125829120):将使用默认值 125829120Last 扇区, +扇区 or +size{K,M,G} (125829120-209715199,默认为 209715199):将使用默认值 209715199分区 4 已设置为 Linux 类型,大小设为 40 GiB命令(输入 m 获取帮助):wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)正在同步磁盘。
分区格式化
[root@seafile ~]# mkfs -t ext3 /dev/sda4mke2fs 1.42.9 (28-Dec-2013)Discarding device blocks: 完成文件系统标签=OS type: Linux块大小=4096 (log=2)分块大小=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks2621440 inodes, 10485760 blocks524288 blocks (5.00%) reserved for the super user第一个数据块=0Maximum filesystem blocks=2157969408320 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654096000, 7962624Allocating group tables: 完成正在写入inode表: 完成Creating journal (32768 blocks): 完成Writing superblocks and filesystem accounting information: 完成这里我是把格式变成了 ext4格式
将/dev/sda3 加入到物理卷
[root@localhost ~]# pvcreate /dev/sda3WARNING: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: yWiping ext4 signature on /dev/sda3.Physical volume "/dev/sda3" successfully created.[root@localhost ~]# pvsPV VG Fmt Attr PSize PFree/dev/sda2 centos lvm2 a-- <39.00g 0/dev/sda3 lvm2 --- 20.00g 20.00g
可以发现主机中是存在着centos这个卷组的 我们把这个分区加入进去
[root@localhost ~]# vgextend centos /dev/sda3Volume group "centos" successfully extended[root@localhost ~]# vgsVG #PV #LV #SN Attr VSize VFreecentos 2 2 0 wz--n- 58.99g <20.00g加入逻辑卷[root@localhost ~]# lvresize -L +9983 /dev/mapper/centos-root 这里的+ 后面跟的是你分区磁盘 的PE大小这里的9983 是通过vgdisplay查看所得[root@localhost ~]# vgdisplay--- Volume group ---VG Name centosSystem IDFormat lvm2Metadata Areas 2Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 2Open LV 2Max PV 0Cur PV 2Act PV 2VG Size 58.99 GiBPE Size 4.00 MiBTotal PE 15102Alloc PE / Size 9983 / <39.00 GiBFree PE / Size 5119 / <20.00 GiBVG UUID pOGOek-TS1T-BNje-ilOD-y4LL-YPXQ-EI47TY
重新识别分区信息
[root@localhost ~]# resize2fs /dev/centos/rootresize2fs 1.42.9 (28-Dec-2013)resize2fs: Bad magic number in super-block 当尝试打开 /dev/centos/root 时找不到有效的文件系统超级块.不行的话换下一个[root@localhost ~]# xfs_growfs /dev/mapper/cl-rootxfs_growfs: /dev/mapper/cl-root is not a mounted XFS filesystem[root@localhost ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 60G 0 disk├─sda1 8:1 0 1G 0 part /boot├─sda2 8:2 0 39G 0 part│ ├─centos-root 253:0 0 44.8G 0 lvm /│ └─centos-swap 253:1 0 4G 0 lvm [SWAP]└─sda3 8:3 0 20G 0 part└─centos-root 253:0 0 20 0 lvm /sr0 11:0 1 4.2G 0 rom
