Pages

Thursday, November 5, 2015

Linux Extend Disk Space on Logical Volume

========================================
Extend disk space on Volume 
========================================
In this example, logical volume /dev/Volume00/LogVol01 is extended by 2Gb.
Order of commands:

df
cat /etc/fstab
vgs
lvextend -L +2G /dev/Volume00/LogVol01 && resize2fs /dev/Volume00/LogVol01
df

========================================
Each command by example
========================================
1. df
Use df to check the current situation

df - Disk Free Report

oracle@my_server:~>% df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p1               927M  142M  738M  17% /boot
tmpfs                           4.0G  2.7G  1.4G  66% /dev/shm
/dev/mapper/Volume00-LogVol00   2.0G  689M  1.3G  36% /
/dev/mapper/Volume00-LogVol05   992M   34M  949M   4% /home
/dev/mapper/Volume00-LogVol10   2.5G  961M  1.5G  40% /kits
/dev/mapper/Volume00-LogVol04   3.0G  504M  2.4G  18% /opt
/dev/mapper/Volume00-LogVol13    31M  4.5M   27M  15% /oracle_db
/dev/mapper/Volume00-LogVol08    80G   67G   13G  84% /oracle_db/db1
/dev/mapper/Volume00-LogVol12   3.9G  1.4G  2.6G  35% /software
/dev/mapper/Volume00-LogVol07   9.7G  8.0G  1.7G  84% /software/oracle
/dev/mapper/Volume00-LogVol11    62G   34G   27G  56% /starhome
/dev/mapper/Volume00-LogVol03   992M   36M  947M   4% /tmp
/dev/mapper/Volume00-LogVol01   5.9G  3.6G  2.2G  63% /usr
/dev/mapper/Volume00-LogVol02   2.0G  399M  1.6G  21% /var
/dev/mapper/Volume00-Backup      31M  4.5M   27M  15% /backup
/dev/mapper/OraVG01-OraLV01     159G   12G  145G   8% /backup/ora_online
/dev/mapper/OraVG01-OraLV02     100G   58G   41G  59% /backup/ora_exp
/dev/mapper/OraVG02-OraVol03    197G  188M  195G   1% /oracle_db/db2


2. cat /etc/fstab
oracle@my_server:~>% cat /etc/fstab
/dev/Volume00/LogVol00  /                       ext3    defaults,acl    1 1
/dev/cciss/c0d0p1       /boot                   ext3    defaults,acl    1 2
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
tmpfs                   /dev/shm                tmpfs   size=4g         0 0
/dev/Volume00/LogVol05  /home                   ext3    defaults,acl    1 2
/dev/Volume00/LogVol10  /kits                   ext3    defaults,acl    1 2
/dev/Volume00/LogVol04  /opt                    ext3    defaults,acl    1 2
/dev/Volume00/LogVol13  /oracle_db              ext3    defaults,acl    1 2
/dev/Volume00/LogVol08  /oracle_db/db1          ext3    defaults,acl    1 2
proc                    /proc                   proc    defaults        0 0
/dev/Volume00/LogVol12  /software               ext3    defaults,acl    1 2
/dev/Volume00/LogVol07  /software/oracle        ext3    defaults,acl    1 2
/dev/Volume00/LogVol11  /starhome               ext3    defaults,acl    1 2
sysfs                   /sys                    sysfs   defaults        0 0
/dev/Volume00/LogVol03  /tmp                    ext3    defaults,acl    1 2
/dev/Volume00/LogVol01  /usr                    ext3    defaults,acl    1 2
/dev/Volume00/LogVol02  /var                    ext3    defaults,acl    1 2
/dev/Volume00/LogVol06  swap                    swap    defaults        0 0
/dev/Volume00/Backup    /backup                 ext3    defaults,acl    1 2
/dev/OraVG01/OraLV01    /backup/ora_online      ext3    defaults,acl    1 2
/dev/OraVG01/OraLV02    /backup/ora_exp         ext3    defaults,acl    1 2
/dev/OraVG02/OraVol03   /oracle_db/db2          ext3    defaults,acl    1 2

3. vgs
vgs - Volume Groups Information. Must be run as root.
oracle@my_server:/software/oracle>% su -
Password:
oracle@my_server:~>% vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  OraVG01    1   2   0 wz--n- 271.00G  9.00G
  OraVG02    1   1   0 wz--n- 220.00G 20.00G
  Volume00   1  17   0 wz--n- 278.41G 74.84G

3. lvextend && resize2fs
To extent size and resize, use the file system name from fstab file

lvextend -L +2G /dev/Volume00/LogVol07
Add 2Gb to /dev/Volume00/LogVol01.

resize2fs /dev/Volume00/LogVol07
Resize ext2, ext3, or ext4 file systems.

tune2fs -c 0 -i 0 -m 1 /dev/OraVg1/db1
Modify tunable parameters on ext2, ext3 and ext4 type filesystems.
The purpose of below options, is to fasten up the startup of server.

-c 0: Adjust the number of mounts after which the filesystem will be checked by e2fsck(8).
         If max-mount-counts is 0 or -1, the number of times the filesystem is mounted
          will be disregarded by e2fsck(8) and the kernel.
-i 0: -i <interval-between-checks in Days/Weeks/Months>

-m 1: -m <reserved-blocks-percentage>
          Set the percentage of reserved filesystem blocks.

-l:  Would List current settings
The command to run:

root@my_server:~>% lvextend -L +2G /dev/Volume00/LogVol07 && resize2fs /dev/Volume00/LogVol07
  Extending logical volume LogVol07 to 10.00 GB
  Logical volume LogVol07 successfully resized
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/Volume00/LogVol07 is mounted on /software/oracle; on-line resizing required
Performing an on-line resize of /dev/Volume00/LogVol07 to 2621440 (4k) blocks.
The filesystem on /dev/Volume00/LogVol07 is now 2621440 blocks long.


root@my_server:~>% lvextend -L +8G /dev/Volume00/LogVol08 && resize2fs /dev/Volume00/LogVol08
  Extending logical volume LogVol08 to 90.00 GB
  Logical volume LogVol08 successfully resized
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/Volume00/LogVol08 is mounted on /oracle_db/db1; on-line resizing required
Performing an on-line resize of /dev/Volume00/LogVol08 to 23592960 (4k) blocks.
The filesystem on /dev/Volume00/LogVol08 is now 23592960 blocks long.

4. df
Use df to check the current situationoracle@my_server:~>% df -h
Filesystem                      Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p1               927M  142M  738M  17% /boot
tmpfs                           4.0G  2.7G  1.4G  66% /dev/shm
/dev/mapper/Volume00-LogVol00   2.0G  689M  1.3G  36% /
/dev/mapper/Volume00-LogVol05   992M   34M  949M   4% /home
/dev/mapper/Volume00-LogVol10   2.5G  961M  1.5G  40% /kits
/dev/mapper/Volume00-LogVol04   3.0G  504M  2.4G  18% /opt
/dev/mapper/Volume00-LogVol13    31M  4.5M   27M  15% /oracle_db
/dev/mapper/Volume00-LogVol08    88G   67G   21G  77% /oracle_db/db1
/dev/mapper/Volume00-LogVol12   3.9G  1.4G  2.6G  35% /software
/dev/mapper/Volume00-LogVol07    12G  8.0G  3.6G  70% /software/oracle
/dev/mapper/Volume00-LogVol11    62G   34G   27G  56% /starhome
/dev/mapper/Volume00-LogVol03   992M   36M  947M   4% /tmp
/dev/mapper/Volume00-LogVol01   5.9G  3.6G  2.2G  63% /usr
/dev/mapper/Volume00-LogVol02   2.0G  399M  1.6G  21% /var
/dev/mapper/Volume00-Backup      31M  4.5M   27M  15% /backup
/dev/mapper/OraVG01-OraLV01     159G   12G  145G   8% /backup/ora_online
/dev/mapper/OraVG01-OraLV02     100G   58G   41G  59% /backup/ora_exp


/dev/mapper/OraVG02-OraVol03    197G  188M  195G   1% /oracle_db/db2


One more example
root@my_server:~>% df -hP | grep usr
/dev/mapper/Volume00-LogVol01   14G   12G  1.9G  86% /usr

root@my_server:~>% less /etc/fstab | grep usr
/dev/Volume00/LogVol01  /usr          ext3    defaults,acl        1 2

root@my_server:~>% lvextend -L +2G /dev/Volume00/LogVol01 && resize2fs /dev/Volume00/LogVol01

  Extending logical volume LogVol01 to 16.00 GB
  Logical volume LogVol01 successfully resized
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/Volume00/LogVol01 is mounted on /usr; on-line resizing required
Performing an on-line resize of /dev/Volume00/LogVol01 to 4194304 (4k) blocks.
The filesystem on /dev/Volume00/LogVol01 is now 4194304 blocks long.

root@my_server:~>% df -hP | grep usr
/dev/mapper/Volume00-LogVol01   16G   12G  3.7G  76% /usr

No comments:

Post a Comment