Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving around disk space

Status
Not open for further replies.

Dinkytoy

IS-IT--Management
Jun 14, 2007
147
0
0
GB
Hi I'm very green to linux and have been requested to make changes to a server's filesystem so more space is available.

Essentially what is wanted is make some of the un-used space in /usr available to /var.

I've googled this and found various bits of information but none of it makes a great deal of sense to me. I'm not even sure it's possible at this stage.

Can anyone shed any light on this? The distribution is a version of RH but not sure of the actual release.
 
It's pretty simple if you are using LVM, otherwise it can get a bit tricky. If you google "resize linux partition", you'll most likely get a plethora of options.

"We can categorically state that we have not released man-eating badgers into the area" - Major Mike Shearer
 
Sounds like an older sytem. I know that in the olden days you had an option to make mount points grow as needed. I can't remember if you can go into fdisk and change that after the fact so you may have to do it the ugly way. Basically, if you can copy /usr to another partition, this will allow you to delete and recreate /usr to the new size. Then you can copy everything back to the new space and do the same thing for /var. Like I said this is an ugly (and time consuming) way. Another way may be to use LVM. You may have to upgrade to be able to use it but it will make life a lot easier in the future. LVM will take all the drives on your system including ones you add later and create one large virtual drive. All partitions such as /usr, /var, /etc and so on are nothing more than directories. You may want to look into something like that before you go with my first suggestion. Good luck.

 
Below is the output from the server on commands that I've managed to find to display the existing disk layout. It looks like LVM is used so the question is can I shrink Vol5 and assign the free space to Vol4?

[root@xx /]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup_ID_16205-LogVol1
1032088 445112 534548 46% /
/dev/sda3 99150 12324 81706 14% /boot
none 2075684 0 2075684 0% /dev/shm
/dev/mapper/VolGroup_ID_16205-LogVol2
507748 10555 470979 3% /tmp
/dev/mapper/VolGroup_ID_16205-LogVol5
10063176 3665956 5886040 39% /usr
/dev/mapper/VolGroup_ID_16205-LogVol4
507748 142623 338911 30% /var
/dev/mapper/VolGroup_ID_16205-LogVolHome
6386192 4316100 1745692 72% /home
[root@xx /]#


[root@xx ~]# vgdisplay
--- Volume group ---
VG Name VolGroup_ID_16205
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 6
Open LV 6
Max PV 0
Cur PV 2
Act PV 2
VG Size 25.06 GB
PE Size 32.00 MB
Total PE 802
Alloc PE / Size 628 / 19.62 GB
Free PE / Size 174 / 5.44 GB
VG UUID GfiASN-VbE6-z353-jibQ-iB3L-dlNa-tSyxnS


[root@xx ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name VolGroup_ID_16205
PV Size 18.88 GB / not usable 0
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 604
Free PE 0
Allocated PE 604
PV UUID NPtfmU-gphC-j6Zz-8IdS-YMtv-0vtK-2dEfi0

--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup_ID_16205
PV Size 6.19 GB / not usable 0
Allocatable yes
PE Size (KByte) 32768
Total PE 198
Free PE 174
Allocated PE 24
PV UUID pCWqRr-ZRbs-kF6B-7xyv-2p03-Hbrj-zn5eLR


[root@xx ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup_ID_16205/LogVol1
VG Name VolGroup_ID_16205
LV UUID UPpMK7-WHkj-zZql-L8oH-pQtu-Y7BX-sHADlY
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:0

--- Logical volume ---
LV Name /dev/VolGroup_ID_16205/LogVol2
VG Name VolGroup_ID_16205
LV UUID 36upfn-PC5K-kOzH-lBD6-LzU8-2qJe-cNqejC
LV Write Access read/write
LV Status available
# open 1
LV Size 512.00 MB
Current LE 16
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:1

--- Logical volume ---
LV Name /dev/VolGroup_ID_16205/LogVol5
VG Name VolGroup_ID_16205
LV UUID cWz3uB-tR4D-j2G8-4qyr-9F07-ElIY-17PP1W
LV Write Access read/write
LV Status available
# open 1
LV Size 9.75 GB
Current LE 312
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:2

--- Logical volume ---
LV Name /dev/VolGroup_ID_16205/LogVol4
VG Name VolGroup_ID_16205
LV UUID VLJeZH-8MDt-5SpP-BGTF-LU7X-WPwP-g66ECU
LV Write Access read/write
LV Status available
# open 1
LV Size 512.00 MB
Current LE 16
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:3

--- Logical volume ---
LV Name /dev/VolGroup_ID_16205/LogVol0
VG Name VolGroup_ID_16205
LV UUID ryMyUd-IZtq-pv0b-K17f-ow26-nMn8-dUXjIg
LV Write Access read/write
LV Status available
# open 1
LV Size 1.69 GB
Current LE 54
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:4

--- Logical volume ---
LV Name /dev/VolGroup_ID_16205/LogVolHome
VG Name VolGroup_ID_16205
LV UUID RcNyyv-Jd8B-4I2V-dGZ3-AvTp-0UPS-Q8ysuK
LV Write Access read/write
LV Status available
# open 1
LV Size 6.19 GB
Current LE 198
Segments 2
Allocation inherit
Read ahead sectors 0
Block device 253:5
 
vgdisplay shows that you still have 174 PEs (5.44 GB) of unallocated space left. Why not use that to extend/expand your LV.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Ok, so I should then be able to simply do:

lvextend -L+5G /dev/VolGroup_ID_16205/LogVol4

Followed by

ext2online /dev/VolGroup_ID_16205/LogVol4

According to what I've read, is that correct?
 
Expand the LV then expand the FS. Yes, that should be correct. I have never seen the command ext2online before. I do know of resize2fs though.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top