Link to home
Start Free TrialLog in
Avatar of SqueezeOJ
SqueezeOJFlag for United States of America

asked on

How to Increase Size of /home Directory?

Hello,

I need to increase the size of my /home partition.  Here's what "df" reveals:
[root@camerahost /]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      51606140   6175480  44906508  13% /
tmpfs                  1672232       284   1671948   1% /dev/shm
/dev/sdb1               495844     48110    422134  11% /boot
/dev/mapper/VolGroup-lv_home
                      96341764  91447860         4 100% /home

Open in new window

Could someone please give me simple & concrete directions to increase the size of the /home directory?

THANKS!
Avatar of farzanj
farzanj
Flag of Canada image

It is on LVM so that is good.  Do you know where do you want to get the extra space from?  Root LVM appears to have some space.  Do you want space from there or somewhere else?

Also issue commands:

lvmdiskscan
pvs
vgs
lvs
pvdisplay
vgdisplay
lvdisplay
df -hT

You need to get space, add space to your logical volume and increase the size of your LVM.  Then after that you need to increase the size of your filesystem
As was pointed out by farzanj, you have to have available space either within the VG to expand the lv using lvresize. If you have space in the pv, you would use vgexpand to get the available space from the pv to the VG and then expand the lv.
Hi

What shows vgs VolGroup? If VolGroup has still some VFree you can extend your filestystem by the amount there.

lvextend -L +1g /dev/mapper/VolGroup-lv_home
resize2fs /dev/mapper/VolGroup-lv_home

Open in new window


Thath should expand it by 1g. Replace 1g with the amount you have / want.
Avatar of SqueezeOJ

ASKER

Hello All,

Ideally I'd to add 200gb to /home, but I don't see that much in the initial df that I ran.

I'm pretty sure this computer has a 500gb hard drive, but I don't see that amount available in my df.

I'd be happy to add any amount to /home from VolGroup-lv_root but I'd rather figure out IF I have more unused disk space and then add as much of that as possible to /home.

Thanks!

Here are the commands you asked for:
[root@camerahost user]# clear
[root@camerahost user]# lvmdiskscan
  /dev/ram0             [      16.00 MiB] 
  /dev/root             [      50.00 GiB] 
  /dev/ram1             [      16.00 MiB] 
  /dev/VolGroup/lv_swap [       5.19 GiB] 
  /dev/ram2             [      16.00 MiB] 
  /dev/VolGroup/lv_home [      93.34 GiB] 
  /dev/ram3             [      16.00 MiB] 
  /dev/ram4             [      16.00 MiB] 
  /dev/ram5             [      16.00 MiB] 
  /dev/ram6             [      16.00 MiB] 
  /dev/ram7             [      16.00 MiB] 
  /dev/ram8             [      16.00 MiB] 
  /dev/ram9             [      16.00 MiB] 
  /dev/ram10            [      16.00 MiB] 
  /dev/ram11            [      16.00 MiB] 
  /dev/ram12            [      16.00 MiB] 
  /dev/ram13            [      16.00 MiB] 
  /dev/ram14            [      16.00 MiB] 
  /dev/ram15            [      16.00 MiB] 
  /dev/sdb1             [     500.00 MiB] 
  /dev/sdb2             [     148.56 GiB] LVM physical volume
  /dev/sdc1             [     500.00 MiB] 
  /dev/sdc2             [      50.00 GiB] 
  /dev/sdc3             [       5.20 GiB] 
  /dev/sdc5             [     410.07 GiB] 
  3 disks
  21 partitions
  0 LVM physical volume whole disks
  1 LVM physical volume
[root@camerahost user]# pvs
  PV         VG       Fmt  Attr PSize   PFree
  /dev/sdb2  VolGroup lvm2 a-   148.53g    0 
[root@camerahost user]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  VolGroup   1   3   0 wz--n- 148.53g    0 
[root@camerahost user]# lvs
  LV      VG       Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  lv_home VolGroup -wi-ao 93.34g                                      
  lv_root VolGroup -wi-ao 50.00g                                      
  lv_swap VolGroup -wi-ao  5.19g                                      
[root@camerahost user]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb2
  VG Name               VolGroup
  PV Size               148.56 GiB / not usable 30.00 MiB
  Allocatable           yes (but full)
  PE Size               32.00 MiB
  Total PE              4753
  Free PE               0
  Allocated PE          4753
  PV UUID               8ffE4u-gb8j-c1q2-V46F-EQy6-N9sI-L1GBCP
   
[root@camerahost user]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               148.53 GiB
  PE Size               32.00 MiB
  Total PE              4753
  Alloc PE / Size       4753 / 148.53 GiB
  Free  PE / Size       0 / 0   
  VG UUID               62ObMF-t8cH-D3OM-ZcfR-cL7k-JTmk-JcB94f
   
[root@camerahost user]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup/lv_root
  VG Name                VolGroup
  LV UUID                5rfozC-7AIW-ALRt-ItkE-thxo-wK0H-3NocnD
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             1600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Name                /dev/VolGroup/lv_home
  VG Name                VolGroup
  LV UUID                MFAvrC-fJvQ-sOT1-C7Ec-Xs1U-4gD4-hkxI3U
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                93.34 GiB
  Current LE             2987
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
   
  --- Logical volume ---
  LV Name                /dev/VolGroup/lv_swap
  VG Name                VolGroup
  LV UUID                u0tFCw-F3j6-f9hZ-u7QS-APKw-xNOr-irFUPl
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                5.19 GiB
  Current LE             166
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
[root@camerahost user]# df-hT
bash: df-hT: command not found...

Open in new window


Note that the last command, df-hT, did not work.  I tried df-ht but that was unrecognized as well.  Did you need me to install something?

THANKS,
Jason
You are missing the space between the command df and its argument -hT

You have /dev/sdc5 with 400GB but it is not clear where it is used

fdisk -l
pvdisplay
vgdisplay

You could add the /dev/sdc5 into the VolGroup, and then expand the /home volume.
The main issue I see is that you mis-allocated much of your resources.

You have 100GB in / more than needed.
I tend to specifically allocate storage
/ 5GB
/boot 500mb
/var 2.5GB
/usr 5GB
/var/log 2.5GB
/home as needed
/var/www/HTML as needed if you are running a web server
If you are running a mailserver with mailbox format, you would allocate more space to /var or create a separate /var/spool/mail
2GB for swap
Thanks for the syntax check, Arnold.  Here's my df -hT:

[root@camerahost user]# df -hT
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
              ext4     50G  5.9G   43G  13% /
tmpfs        tmpfs    1.6G  284K  1.6G   1% /dev/shm
/dev/sdb1     ext4    485M   47M  413M  11% /boot
/dev/mapper/VolGroup-lv_home
              ext4     92G   88G     0 100% /home

Open in new window


And then the other commands you wanted me to run:
[root@camerahost user]# fdisk -l

Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xcba1b13a

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048     1026047      512000   83  Linux
/dev/sdb2         1026048   312580095   155777024   8e  Linux LVM

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4c670e08

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *        2048     1026047      512000   83  Linux
/dev/sdc2         1026048   105883647    52428800   83  Linux
/dev/sdc3       105883648   116795391     5455872   82  Linux swap / Solaris
/dev/sdc4       116795392   976773167   429988888    5  Extended
/dev/sdc5       116797440   976773119   429987840   83  Linux

Disk /dev/dm-0: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 5570 MB, 5570035712 bytes
255 heads, 63 sectors/track, 677 cylinders, total 10878976 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/dm-1 doesn't contain a valid partition table

Disk /dev/dm-2: 100.2 GB, 100227088384 bytes
255 heads, 63 sectors/track, 12185 cylinders, total 195756032 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/dm-2 doesn't contain a valid partition table
[root@camerahost user]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb2
  VG Name               VolGroup
  PV Size               148.56 GiB / not usable 30.00 MiB
  Allocatable           yes (but full)
  PE Size               32.00 MiB
  Total PE              4753
  Free PE               0
  Allocated PE          4753
  PV UUID               8ffE4u-gb8j-c1q2-V46F-EQy6-N9sI-L1GBCP
   
[root@camerahost user]# 
[root@camerahost user]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               148.53 GiB
  PE Size               32.00 MiB
  Total PE              4753
  Alloc PE / Size       4753 / 148.53 GiB
  Free  PE / Size       0 / 0   
  VG UUID               62ObMF-t8cH-D3OM-ZcfR-cL7k-JTmk-JcB94f

Open in new window


And I would agree that my allocation is bad!  I do not run a mail server.  This is really just a DVR for a security system with Apache to run the web component.

Thanks,
Jason
If /dev/sdc5 is not used just add it to lvm

pvcreate /dev/sdc5
vgextend VolGroup /dev/sdc5

Open in new window


after that continue as I have written before
unlx86,

Here's what I've run:
[root@camerahost user]# pvcreate /dev/sdc5
  Physical volume "/dev/sdc5" successfully created
[root@camerahost user]# vgextend VolGroup /dev/sdc5
  Volume group "VolGroup" successfully extended
[root@camerahost user]# lvextend -L +1g /dev/mapper/VolGroup-lv_home
  Extending logical volume lv_home to 94.34 GiB
  Logical volume lv_home successfully resized
[root@camerahost user]# resize2fs /dev/mapper/VolGroup-lv_home
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_home is mounted on /home; on-line resizing required
old desc_blocks = 6, new_desc_blocks = 6
Performing an on-line resize of /dev/mapper/VolGroup-lv_home to 24731648 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_home is now 24731648 blocks long.

Open in new window

And this looks good!
As you said, that only adds 1gb.  So, how do I know how much I can add to /home?

THANKS!
Jason
with "vgs" you see how much you have free. The maximum amount is what you see

Example

VG       #PV #LV #SN Attr   VSize   VFree  
  vg_vxp01   2   7   0 wz-pn- 485.26g 215.56g

Open in new window


I could add 215.56g to my logical volumes
ASKER CERTIFIED SOLUTION
Avatar of Chris Sandrini
Chris Sandrini
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent.

So, I could run these two commands to add 80% of my free space to lv_home:
lvextend -l +80%FREE /dev/mapper/VolGroup-lv_home
resize2fs /dev/mapper/VolGroup-lv_home 

Open in new window

Exactly.
Are you running zoneminder?  Which input card are you using?
Not sure whether you have /dev/sdc5 used as a raw device for your DVR capture.

/home is not accessible from the web server configuration.
you might have had to create a separate partition in /var/www/html/DVR_DATA or something similar.
SUCCESS!

[root@camerahost user]# lvextend -l +80%FREE /dev/mapper/VolGroup-lv_home
  Extending logical volume lv_home to 421.59 GiB
  Logical volume lv_home successfully resized
[root@camerahost user]# resize2fs /dev/mapper/VolGroup-lv_home
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_home is mounted on /home; on-line resizing required
old desc_blocks = 6, new_desc_blocks = 27
Performing an on-line resize of /dev/mapper/VolGroup-lv_home to 110518272 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_home is now 110518272 blocks long.

[root@camerahost user]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      51606140   6177252  44904736  13% /
tmpfs                  1672232       284   1671948   1% /dev/shm
/dev/sdb1               495844     48110    422134  11% /boot
/dev/mapper/VolGroup-lv_home
                     435136184  91458860 321591620  23% /home

Open in new window

Thanks for asking about ZoneMinder.  Originally I had been using that, but recently moved away from it.

This may sound lame, but I made a virtual windows XP machine and installed the Trendnet SecureView program to run everything.  It's been much easier and it runs its own webserver DVR program for me.

So, I don't actually need Apache anymore.
I've requested that this question be closed as follows:

Accepted answer: 0 points for SqueezeOJ's comment #a38827546

for the following reason:

Did exactly what I needed to do.  Thank you!
Exactly what I needed to do.  THANKS!