今天在做gc 12cr2版本的实验的时候,发现/目录的空间不够了,于是手动增加了一块盘,在线扩文件系统,不过前提是/文件系统是放到VG里面的,而不是单独的分区,如果是单个分区,是不能扩的。
测试环境:OS:RHEL 5.4
1,查看硬盘
如果硬盘没有发现,我们可以通过/etc/init.d/kudzu来在线发现,一直觉得LINUX在线配置硬件设置这块,就没有AIX这一块做得好。
[root@gc12r2 ~]# fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 5221 41833260 8e Linux LVM Disk /dev/sdb: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table
2,格式化磁盘
[root@gc12r2 ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
3,把PV增加到VG中
[root@gc12r2 ~]# vgs VG #PV #LV #SN Attr VSize VFree rootvg 1 2 0 wz--n- 39.88G 2.50G [root@gc12r2 ~]# vgextend rootvg /dev/sdb /dev/hdc: open failed: Read-only file system /dev/cdrom: open failed: Read-only file system Attempt to close device '/dev/cdrom' which is not open. Volume group "rootvg" successfully extended [root@gc12r2 ~]# vgdisplay -v Finding all volume groups Finding volume group "rootvg" --- Volume group --- VG Name rootvg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 79.84 GB PE Size 32.00 MB Total PE 2555 Alloc PE / Size 1196 / 37.38 GB Free PE / Size 1359 / 42.47 GB VG UUID 1zJ3d3-b5WO-qNXD-F6a6-j4mA-rKMj-k7Ar8r --- Logical volume --- LV Name /dev/rootvg/rootlv VG Name rootvg LV UUID apcaZv-CeDg-gNmg-f7pL-duSG-4UPj-REGcAp LV Write Access read/write LV Status available # open 1 LV Size 29.28 GB Current LE 937 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/rootvg/swap VG Name rootvg LV UUID LsMRXz-C0oh-rnvP-10iT-Di8q-77YR-e4XlY7 LV Write Access read/write LV Status available # open 1 LV Size 8.09 GB Current LE 259 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Physical volumes --- PV Name /dev/sda2 PV UUID sqToLA-R3Tg-jfCN-NR1f-bLie-e7cD-wMzZLP PV Status allocatable Total PE / Free PE 1276 / 80 PV Name /dev/sdb PV UUID 2q1urp-b0VM-h7Pm-G0ZT-FpdQ-TrS5-bEzc9d PV Status allocatable Total PE / Free PE 1279 / 1279
4,在线扩LV
[root@gc12r2 ~]# lvextend -L50G /dev/rootvg/rootlv Extending logical volume rootlv to 50.00 GB Logical volume rootlv successfully resized
5,在线扩文件系统
如果是rhel 4版本的系统需要使用ext2online命令来实现。
[root@gc12r2 ~]# resize2fs -p /dev/rootvg/rootlv resize2fs 1.39 (29-May-2006) Filesystem at /dev/rootvg/rootlv is mounted on /; on-line resizing required Performing an on-line resize of /dev/rootvg/rootlv to 13107200 (4k) blocks. The filesystem on /dev/rootvg/rootlv is now 13107200 blocks long. [root@gc12r2 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rootvg-rootlv 49G 22G 25G 48% / /dev/sda1 99M 13M 82M 14% /boot tmpfs 3.9G 0 3.9G 0% /dev/shm //192.168.111.1/install 932G 729G 204G 79% /sof
已经扩展成功。
下面是resize2fs命令的帮助手册
[root@gc12r2 ~]# man resize2fs RESIZE2FS(8) RESIZE2FS(8) NAME resize2fs - ext2/ext3 file system resizer SYNOPSIS resize2fs [ -d debug-flags ] [ -S RAID-stride ] [ -f ] [ -F ] [ -p ] device [ size ] DESCRIPTION The resize2fs program will resize ext2 or ext3 file systems. It can be used to enlarge or shrink an unmounted file system located on device. If the filesystem is mounted, it can be used to expand the size of the mounted filesystem, assuming the kernel supports on-line resizing. (As of this writing, the Linux 2.6 kernel supports on-line resize for filesystems mounted using ext3 only.). The size parameter specifies the requested new size of the filesystem. If no units are specified, the units of the size parameter shall be the filesystem blocksize of the filesystem. Optionally, the size parameter may be suffixed by one of the following the units designators: ’s’, ’K’, ’M’, or ’G’, for 512 byte sectors, kilobytes, megabytes, or gigabytes, respectively. The size of the filesystem may never be larger than the size of the partition. If size parameter is not specified, it will default to the size of the partition. The resize2fs program does not manipulate the size of partitions. If you wish to enlarge a filesystem, you must first make sure you can expand the size of the underly- ing partition first. This can be done using fdisk(8) by deleting the partition and recreating it with a larger size or using lvextend(8), if you’re using the logical volume manager lvm(8). When recreating the partition, make sure you create it with the same starting disk cylinder as before! Otherwise, the resize operation will cer- tainly not work, and you may lose your entire filesystem. After running fdisk(8), run resize2fs to resize the ext2 filesystem to use all of the space in the newly enlarged partition. If you wish to shrink an ext2 partition, first use resize2fs to shrink the size of filesystem. Then you may use fdisk(8) to shrink the size of the partition. When shrinking the size of the partition, make sure you do not make it smaller than the new size of the ext2 filesystem! OPTIONS -d debug-flags Turns on various resize2fs debugging features, if they have been compiled into the binary. debug-flags should be computed by adding the numbers of the desired features from the following list: 1 - Print out all disk I/O 2 - Debug block relocations 8 - Debug inode relocations 16 - Debug moving the inode table -S RAID-stride The resize2fs program will heuristically determine the RAID stride that was specified when the filesystem was created. This option allows the user to explicitly specify a RAID stride setting to be used by resize2fs instead. -p Prints out a percentage completion bars for each resize2fs operation, so that the user can keep track of what the program is doing. -f Forces resize2fs to proceed with the filesystem resize operation, overriding some safety checks which resize2fs normally enforces. -F Flush the filesystem device’s buffer caches before beginning. Only really useful for doing resize2fs time trials. AUTHOR resize2fs was written by Theodore Ts’o <tytso@mit.edu>. COPYRIGHT Resize2fs is Copyright 1998 by Theodore Ts’o and PowerQuest, Inc. All rights reserved. As of April, 2000 Resize2fs may be redistributed under the terms of the GPL. SEE ALSO fdisk(8), e2fsck(8), mke2fs(8), lvm(8), lvextend(8) E2fsprogs version 1.39 May 2006 RESIZE2FS(8)
resize2fs 仅仅用于ext2/ext3 的文件系统resize,其它文件系统也有对应命令来resize ,小弟最新就因为这个遭了,http://www.pqfun.com/2014/05/lvm-common-tasks/ 可以参考下resize_reiserfs xfs_growfs