Extend root filesystems on Oracle Linux

Before you begin :
1. Verify your new disk is detect on the systems
in this case, I’m using /dev/sdb
2. Identify your volgroup
in this case, my my root vg is vg_allen.

Here we go :

[root@allen ~]# fdisk /dev/sdb 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x079df05d.
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): 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1566, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1566, default 1566): 
Using default value 1566

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@allen ~]# fdisk -l

Disk /dev/sda: 12.9 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009af64

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1567    12069888   8e  Linux LVM

Disk /dev/sdb: 12.9 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x079df05d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1566    12578863+  8e  Linux LVM

Disk /dev/mapper/vg_allen-lv_root: 10.2 GB, 10242490368 bytes
255 heads, 63 sectors/track, 1245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_allen-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@allen ~]# partprobe 
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.
[root@allen ~]# pvcreate /dev/sdb
sdb   sdb1  
[root@allen ~]# pvcreate /dev/sdb1 
  Writing physical volume data to disk "/dev/sdb1"
  Physical volume "/dev/sdb1" successfully created
[root@allen ~]# vgextend vg_allen /dev/sdb1 
  Volume group "vg_allen" successfully extended
[root@allen ~]# lvextend /dev/vg_allen/lv_
lv_root  lv_swap  
[root@allen ~]# lvextend /dev/vg_allen/lv_root /dev/sdb1 
  Extending logical volume lv_root to 21.53 GiB
  Logical volume lv_root successfully resized
[root@allen ~]# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_allen-lv_root
                      9.4G  8.5G  504M  95% /
[root@allen ~]# resize2fs /dev/vg_allen/lv_root 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_allen/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_allen/lv_root to 5644288 (4k) blocks.
The filesystem on /dev/vg_allen/lv_root is now 5644288 blocks long.

[root@allen ~]# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_allen-lv_root
                       22G  8.5G   12G  42% /

About these ads

2 thoughts on “Extend root filesystems on Oracle Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s