Resizing the filesystem of your Oracle VM on-line.
Jump to navigation
Jump to search
Resizing the filesystem of your Oracle VM on-line.
- Review the current size.
[root@ol6 ~]# df -H Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_ol6-lv_root 27G 22G 3.8G 86% / tmpfs 1.3G 209M 1.1G 17% /dev/shm /dev/sda1 508M 97M 385M 21% /boot Downloads 750G 172G 578G 23% /media/sf_Downloads
Plan to add 30G into the root file system.
- Put a partition on the newly-added disk
[root@ol6 ~]# fdisk /dev/sdf Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x0c04311f. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-3916, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-3916, default 3916): Using default value 3916 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
- Create a physical volume on top of it.
[root@ol6 ~]# pvcreate /dev/sdf1 Writing physical volume data to disk "/dev/sdf1" Physical volume "/dev/sdf1" successfully created
- Review the current volume to be added. Note that there is no free extends (noted by zero value of the "Free PE / Size").
[root@ol6 ~]# vgdisplay --- Volume group --- VG Name vg_ol6 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 29.51 GiB PE Size 4.00 MiB Total PE 7554 Alloc PE / Size 7554 / 29.51 GiB Free PE / Size 0 / 0 VG UUID 2e2VHd-Mb3D-Uz0G-4Yec-tbfe-f3cI-7cvpby
- Extend this volume with a new physical disk.
[root@ol6 ~]# vgextend vg_ol6 /dev/sdf1 Volume group "vg_ol6" successfully extended
- Check the volume again. Note that the "Free PE / Size" is now 30G.
[root@ol6 ~]# vgdisplay
--- Volume group --- VG Name vg_ol6 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 59.50 GiB PE Size 4.00 MiB Total PE 15233 Alloc PE / Size 7554 / 29.51 GiB Free PE / Size 7679 / 30.00 GiB VG UUID 2e2VHd-Mb3D-Uz0G-4Yec-tbfe-f3cI-7cvpby
- Now let's review the logical volume.
[root@ol6 ~]# lvdisplay --- Logical volume --- LV Path /dev/vg_ol6/lv_root LV Name lv_root VG Name vg_ol6 LV UUID rd2d4X-vqE8-xENi-clCz-Oa0T-0R6X-RFCBDq LV Write Access read/write LV Creation host, time , LV Status available # open 1 LV Size 25.10 GiB Current LE 6426 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Path /dev/vg_ol6/lv_swap LV Name lv_swap VG Name vg_ol6 LV UUID xM3Blz-wvpG-IUfF-WhWc-EHoI-I0xG-oeV1IR LV Write Access read/write LV Creation host, time , LV Status available # open 1 LV Size 4.41 GiB Current LE 1128 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1
We want to add additional 30G into the existing /dev/vg_ol6/lv_root. So the total size will be 55.1GB.
- Let's extend the logical volume.
[root@ol6 ~]# lvextend -L 55.10G /dev/vg_ol6/lv_root Rounding size to boundary between physical extents: 55.10 GiB Extending logical volume lv_root to 55.10 GiB Insufficient free space: 5120 extents needed, but only 5119 available # You may have to adjust the size if the initial specified size is too large. [root@ol6 ~]# lvextend -L 55G /dev/vg_ol6/lv_root Extending logical volume lv_root to 55.00 GiB Logical volume lv_root successfully resized
- Now you can extend the file system.
[root@ol6 ~]# resize2fs /dev/vg_ol6/lv_root 55G resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/vg_ol6/lv_root is mounted on /; on-line resizing required old desc_blocks = 3, new_desc_blocks = 4 Performing an on-line resize of /dev/vg_ol6/lv_root to 14417920 (4k) blocks. The filesystem on /dev/vg_ol6/lv_root is now 14417920 blocks long.
- Now the file system is resized while the system is still on-line.
[root@ol6 ~]# df -H Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_ol6-lv_root 55G 22G 33G 39% / tmpfs 1.3G 209M 1.1G 17% /dev/shm /dev/sda1 508M 97M 385M 21% /boot Downloads 750G 172G 578G 23% /media/sf_Downloads
References: