BigAdmin System Administration Portal
Community-Submitted Tech Tip
Print-friendly VersionPrint-friendly Version
This content is submitted by a BigAdmin user. It has not been reviewed for technical accuracy by Sun Microsystems, though it may have been lightly edited to improve readability. If you find an error or would like to comment on the article, please contact the submitter or use the comment field at the bottom of the article. Community submissions may not follow Sun trademark guidelines. For information on Sun trademarks, please see http://www.sun.com/suntrademarks/.
 
 

Increasing the Size of a File System With Linux Logical Volume Manager

Nagesh Ghungarde, June 2007

Here are the steps you need to increase your file system using Linux Logical Volume Manager (LVM).

First check the file systems available in LVM and the free space.

# df -k
/home      (/dev/vg00/lvol5       ):  1041432 total allocated Kb
                                        918000 free allocated Kb
                                        123432 used allocated Kb
                                            11 % allocation used
/mna       (/dev/vg00/mna         ): 26174886 total allocated Kb
                                       1230944 free allocated Kb
                                      24943942 used allocated Kb
                                            95 % allocation used
/mnb       (/dev/vg00/lvol10      ): 13520275 total allocated Kb
                                      12240452 free allocated Kb
                                       1279823 used allocated Kb
                                             9 % allocation used
/opt       (/dev/vg00/lvol6       ):  4316832 total allocated Kb
                                       1092264 free allocated Kb
                                       3224568 used allocated Kb
                                            74 % allocation used
/tmp       (/dev/vg00/lvol4       ):   716320 total allocated Kb
                                        711768 free allocated Kb
                                          4552 used allocated Kb
                                             0 % allocation used
/usr       (/dev/vg00/lvol7       ):  2611832 total allocated Kb
                                       1223968 free allocated Kb
                                       1387864 used allocated Kb
                                            53 % allocation used
/var       (/dev/vg00/lvol8       ):  4690896 total allocated Kb
                                       3521864 free allocated Kb
                                       1169032 used allocated Kb
                                            24 % allocation used
/stand     (/dev/vg00/lvol1       ):   269032 total allocated Kb
                                        214624 free allocated Kb
                                         54408 used allocated Kb
                                            20 % allocation used
/          (/dev/vg00/lvol3       ):   262144 total allocated Kb
                                        111552 free allocated Kb
                                        150592 used allocated Kb
                                            57 % allocation used
$

Check the free space on the disk.

# vgdisplay -v
--- Volume groups ---
VG Name                     /dev/vg00
VG Write Access             read/write
VG Status                   available
Max LV                      255
Cur LV                      10
Open LV                     10
Max PV                      16
Cur PV                      1
Act PV                      1
Max PE per PV               4384
VGDA                        2
PE Size (Mbytes)            16
Total PE                    4374
Alloc PE                    3586
Free PE                     788
Total PVG                   0
Total Spare PVs             0
Total Spare PVs in use      0

   --- Logical volumes ---
   LV Name                     /dev/vg00/lvol1
   LV Status                   available/syncd
   LV Size (Mbytes)            304
   Current LE                  19
   Allocated PE                19
   Used PV                     1

   LV Name                     /dev/vg00/lvol2
   LV Status                   available/syncd
   LV Size (Mbytes)            4096
   Current LE                  256
   Allocated PE                256
   Used PV                     1

   LV Name                     /dev/vg00/lvol3
   LV Status                   available/syncd
   LV Size (Mbytes)            256
   Current LE                  16
   Allocated PE                16
   Used PV                     1

   LV Name                     /dev/vg00/lvol4
   LV Status                   available/syncd
   LV Size (Mbytes)            704
   Current LE                  44
   Allocated PE                44
   Used PV                     1

   LV Name                     /dev/vg00/lvol5
   LV Status                   available/syncd
   LV Size (Mbytes)            1024
   Current LE                  64
   Allocated PE                64
   Used PV                     1

   LV Name                     /dev/vg00/lvol6
   LV Status                   available/syncd
   LV Size (Mbytes)            4224
   Current LE                  264
   Allocated PE                264
   Used PV                     1

   LV Name                     /dev/vg00/lvol7
   LV Status                   available/syncd
   LV Size (Mbytes)            2560
   Current LE                  160
   Allocated PE                160
   Used PV                     1

   LV Name                     /dev/vg00/lvol8
   LV Status                   available/syncd
   LV Size (Mbytes)            4608
   Current LE                  288
   Allocated PE                288
   Used PV                     1

   LV Name                     /dev/vg00/mna
   LV Status                   available/syncd
   LV Size (Mbytes)            25600
   Current LE                  1600
   Allocated PE                1600
   Used PV                     1

   LV Name                     /dev/vg00/lvol10
   LV Status                   available/syncd
   LV Size (Mbytes)            14000
   Current LE                  875
   Allocated PE                875
   Used PV                     1


   --- Physical volumes ---
   PV Name                     /dev/dsk/c0t6d0
   PV Status                   available
   Total PE                    4374
   Free PE                     788
   Autoswitch                  On


VG Name                     /dev/vg01
VG Write Access             read/write
VG Status                   available
Max LV                      255
Cur LV                      0
Open LV                     0
Max PV                      16
Cur PV                      1
Act PV                      1
Max PE per PV               35004
VGDA                        2
PE Size (Mbytes)            16
Total PE                    8749
Alloc PE                    0
Free PE                     8749
Total PVG                   0
Total Spare PVs             0
Total Spare PVs in use      0


   --- Physical volumes ---
   PV Name                     /dev/dsk/c0t5d0
   PV Status                   available
   Total PE                    8749
   Free PE                     8749
   Autoswitch                  On

Check which users are currently logged in to the system.

# who -a
   .    system boot  Mar 2 10:40
   .     run-level 3 Mar 2 10:40    3   0    S
vxenable        .    Mar 2 10:40  0:01    61  id=vxen term=0 exit=0
bcheckrc        .    Mar 2 10:40  0:01    62  id=brc1 term=0 exit=0
cat             .    Mar 2 10:40  0:01    95  id=cprt term=0 exit=0
rm              .    Mar 2 10:40  0:01    96  id=ems1 term=0 exit=0
sh              .    Mar 2 10:40  0:01    97  id=ems2 term=0 exit=0
sh              .    Mar 2 10:40  0:01   100  id=link term=0 exit=0
rc              .    Mar 2 10:42  0:01   104  id=sqnc term=0 exit=0
LOGIN      console   Mar 2 10:42  old   3179  system console
krsd            .    Mar 2 10:42  0:01  3180  id=krsd
sfd             .    Mar 2 10:42  0:01  3181  id= sfd
cimserve        .    Mar 2 10:42  0:01  3182  id=cim1
sh              .    Mar 2 10:42  0:01  3183  id=ems3 term=0 exit=0
p_client        .    Mar 2 10:42  0:01  3187  id=ems4
utild           .    Mar 2 10:42  0:01  3188  id=util
LOGIN      console   Mar 2 10:44  old   3745
gateway    dtremote  Mar 8 18:21   .    1606  id=al:0 term=0 exit=0
gateway3   pts/0     Mar 9 15:28  0:21  2330  10.4.3.175
gateway    pts/1     Mar 8 18:21 22:15  1658  id=   1 term=0 exit=0
root       pts/2     Mar 2 18:12  old  15570  id=   2 term=0 exit=0
gateway4   pts/ta    Mar 9 15:13  3:19 28619  id=  ta term=0 exit=0
gateway2   pts/3     Mar 9 16:15  0:01  4344  ehgwin02
gateway2   dtremote  Mar 9 16:10   .    4170  ehgwin02.geometr
buildusr   dtremote  Mar 5 19:25   .    2833  id=cal: term=0 exit=0
gateway3   pts/4     Mar 9 16:24   .    4786  10.4.3.175:2.0
gateway2   pts/5     Mar 9 16:10  0:26  2962  id=   5 term=0 exit=0
root       pts/tb    Mar 9 14:24   .     394  ajays.geometric.local
gateway4   pts/tc    Mar 9 15:13  3:16 28865  id=  tc term=0 exit=0
root       dtremote  Mar 8 12:47   .   26979  id=13:1 term=0 exit=0
gateway3   dtremote  Mar 9 15:13   .   23547  id=13:0 term=0 exit=0
   .       ttyp1     Mar 9 16:15  0:21  2422  id=  p1 term=0 exit=0
root       dtremote  Mar 9 12:24   .   26971  id=al:2 term=0 exit=0
   .       ttyp2     Mar 9 15:13  1:43  1529  id=  p2 term=0 exit=0
LOGIN      dtremote  Mar 9 14:43   .     909  id=75:0 term=0 exit=4
gateway3   pts/td    Mar 9 14:50  1:45  1125  id=  td term=0 exit=0
gateway3   dtremote  Mar 9 15:59   .    3634  10.4.3.175:2
gateway3   pts/6     Mar 9 16:00  0:12  3696  10.4.3.175:2.0
gateway3   pts/7     Mar 9 16:02   .    3832  10.4.3.175:2.0

We need to kill all the users before unmounting the file system. The fuser command will show the PIDs using the /home file system.

# fuser -kc /home
/home:     3677c    4205co    4341c    3667c    2330co    4787c
3830c    4786co    4784c    3683c    3669co    3634co    4213c
4152c    3276co    4342cKilled
bash-2.04#     4197c    3612c    4783c    3693c    3829c
3694c    3696co

Kill the processes one by one to remove the users.

# kill -9 pid

Before changing the size, we need to unmount the file system.

# umount /home

Now extend the logical volume first (/home is available in /dev/vg00/lvol5; -L 1024 will increase the size by 1024 MB).

bash-2.04# lvextend -L 1024M  /dev/vg00/lvol5

Now extend the file system using the extendfs command, which will increase the file system available in lvol5, that is, /home.

bash-2.04# extendfs /dev/vg00/lvol5

Now mount the file system.

bash-2.04# mount home

Now you can check the file system size by using the following command:

bash-2.04# bdf
Filesystem          kbytes    used   avail %used Mounted on
/dev/vg00/lvol3     262144  150592  111552   57% /
/dev/vg00/lvol1     298928   54408  214624   20% /stand
/dev/vg00/lvol8    4718592 1169024 3521872   25% /var
/dev/vg00/lvol7    2621440 1387880 1223952   53% /usr
/dev/vg00/lvol4     720896    7984  708360    1% /tmp
/dev/vg00/lvol6    4325376 3224568 1092264   75% /opt
/dev/vg00/lvol10   14336000 1279823 12240452    9% /mnb
/dev/vg00/mna      26214400 24943942 1230944   95% /mna
/dev/vg00/lvol5    1048576  123432  918000   12% /home
bash-2.04#

Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


BigAdmin
  
 
 
 
Contact About Sun News & Events Employment Site Map Privacy Terms of Use Trademarks Copyright 1994-2008 Sun Microsystems, Inc.