Operating System - HP-UX
1833788 Members
2626 Online
110063 Solutions
New Discussion

lvrduce syntax !! help !!

 
Chapaya
Frequent Advisor

lvrduce syntax !! help !!

Hello ,
I have 1 lv with 2 disks :
/dev/vg01/lvol1 with c4t13d0 (36G) and c4t1d0 (9G) . The lvol is 44G , i wan to stay just with the 36G .
Pls give me the full commands .

Eran
13 REPLIES 13
Pete Randall
Outstanding Contributor

Re: lvrduce syntax !! help !!

Are there any other lvols in this VG? If not, the easiest way is to blow it away with a vgexport. Deactivate it first with vgchange, the use vgexport, then re-create.


Pete


Pete
Patrick Wallek
Honored Contributor

Re: lvrduce syntax !! help !!

I personally wouldn't lvreduce. I would backup my data, blow away the 44 GB lvol, create a 36GB lvol and restore the data.

So:

1) somehow backup your data (fbackup or something)

2) umount the dir that is mounted against vg01/lvol1

3) lvremove /dev/vg01/lvol1

4) lvcreate -L 34000 /dev/vg01
(Don't try to create a 36GB LV and expect it to stay all on the 36GB disk. You do not have the full 36GB available on that disk)

5) newfs -F vxfs /dev/vg01/rlvol1

6) remount the dir to the new lvol1

7) restore your data
Steven E. Protter
Exalted Contributor

Re: lvrduce syntax !! help !!

You need to cover yourself before you start.

make_tape_recovery

Back up your system.

fbackup the entire system, with databases shut.

Now you need to get the lay of the land.

pvdisplay -v /dev/rdsk/c4t13d0

pvdisplay -v /dev/rdsk/c4t1d0

Identify which logical volume needs to be removed or reduced.

You may need to use lvremove to remove a logical volume.

lvremove /dev/vg00/lvolname


now lvreduce

lvreduce -l /dev/vg00/lvolname

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
S.K. Chan
Honored Contributor

Re: lvrduce syntax !! help !!

This is assuming you do not have OnlineJFS and the capacity of the FS which /dev/vg01/lvol1 is mounted on is less than 80% (to ensure a succesful lvreduce operation).
# bdf -l|grep -e "/dev/vg01/lvol1"
==> Check if /dev/vg01/lvol1 is mounted or not. If it is you need to umount the FS first (assuming the mount point is /data).
# umount /data
==> If you can't umount it, it means some process is holding it. You then need to either terminate these processes or do this in single-user-mode.
# mkdir /temp
# mount /dev/vg01/lvol1 /temp
==> Next perform a full backup on /temp to tape or you can make a copy of your data to another FS (provided space is not a problem).
# umount /temp ; rmdir /temp
# vgdisplay -v vg01
==> Take note of Total PE available for c4t13d0 (if your intention is to ONLY use this disk for lvol1).
# lvreduce -l /dev/vg01/lvol1
# newfs -F vxfs /dev/vg01/rlvol1
# mount /dev/vg01/lvol1 /data
Next restore you data back to /data. I would go with Patrick's suggestion of recreating lvol1 which is much "cleaner".
Con O'Kelly
Honored Contributor

Re: lvrduce syntax !! help !!

Hi Eran

In addition to the other replies I'd offer a slightly different approach, assuming as SK has said you do not have OnlineJFS. I'd go with what everyone says and recreate the lvol, rather than lvreduce.

As others have said backup the filesystem on /dev/vg01/lvol1 ( preferably twice to be sure!) and then remove it.

1. Then create a new logical volume with 0MB of space:
# lvcreate /dev/vg01

2. Check how many physical extents (PE) are available on disk /dev/dsk/c4t13d0:
# pvdisplay /dev/dsk/c4t13d0
(Look for Total PE value - its probably around 9200 if you're using default 4 MB extent size.)

3. Extend the logical volume you created, using all the space on /dev/dsk/c4t13d0:
# lvextend -l /dev/vg01/lvol1 /dev/dsk/c4t13d0
(The "Total PE" is the value you got from pvdisplay in step 2.)

4. Create filesystem & mount as detailed by others.

5. Restore your data back to /dev/vg01/lvol1

This will have created a new lvol1 using only the space on /dev/dsk/c4t13d0, leaving /dev/dsk/c4t1d0 free to be removed from VG or used as space for another lvol in vg01.

Cheers
Con

Chapaya
Frequent Advisor

Re: lvrduce syntax !! help !!

Its more compicate .

The data is written on both disks ,
i want to seperate them .

Eran
Pete Randall
Outstanding Contributor

Re: lvrduce syntax !! help !!

Eran,

That doesn't really complicate anything. The steps are still the same: backup the data; blow away the lvol, re-create the lvol, restore the data.


Pete


Pete
Pete Randall
Outstanding Contributor

Re: lvrduce syntax !! help !!

Eran,

Oh, wait a minute - I see what you're saying. You want to not use the 9GB disk (c4t1d0). That does make it a little more complicated. Run a pvdisplay command against that disk "pvdisplay /dev/dsk/c4t1d0". This will tell you what logical volumes reside there. You will need to back up, remove, re-create and restore each of them in order to free up the 9GB disk.

Post the output of the pvdisplay command and we'll take a look.


Pete


Pete
Pete Randall
Outstanding Contributor

Re: lvrduce syntax !! help !!

Eran,

Oh, wait a minute - I see what you're saying. You want to not use the 9GB disk (c4t1d0). That does make it a little more complicated. Run a pvdisplay command against that disk "pvdisplay -v /dev/dsk/c4t1d0". This will tell you what logical volumes reside there. You will need to back up, remove, re-create and restore each of them in order to free up the 9GB disk.

Post the output of the pvdisplay command and we'll take a look. Pipe it to more and just post the first part - that's all we need to see.


Pete


Pete
Pete Randall
Outstanding Contributor

Re: lvrduce syntax !! help !!

Sorry about the duplication - ignore the middle post.


Pete


Pete
Pete Randall
Outstanding Contributor

Re: lvrduce syntax !! help !!

Eran,

One more thought - this will add one step:

1) backup the data

2) lvremove the lvol

3) vgreduce the 9GB disk out of the vg

4) recreate the lvol

5) restore the data



Pete


Pete
Nagaraju Gudala
Occasional Advisor

Re: lvrduce syntax !! help !!

lvreduce is not recommended to use as it may lead to file system inconsisteny and data loss.
lvreduce -L /dev/vg01/lvol1
but before doing this take backup of all the data in that lvol1.after lvreduce run fsck on the lvol1.Create a new filesystem on the remaining 9GB ,fsck and mount it.
Tim Adamson_1
Honored Contributor

Re: lvrduce syntax !! help !!

Hi Eran

Shutdown any applications that use lvol1 on vg01 and kill any processes left on the filesystem. You can use fuser to check what processes are still using the filesystem.

# fuser -cu / and then use kill or
# fuser -ku / to do it in one hit

Now backup the data on lvol1 on vg01 using whatever backup utility you want.

Unmount the filesystem, deactivate the volume group and vgexport it to blow it away so you can recreate the volume group, logical volume and filesystem.

# umount
# vgchange -a n /dev/vg01
# vgexport /dev/vg01
# mkdir /dev/vg01
# mknod /dev/vg01/group c 64 0x010000
# pvcreate -f /dev/rdsk/c4t13d0
# vgcreate /dev/vg01 /dev/dsk/c4t13d0

Check how many free physical extents are available on the physical volume

# pvdisplay /dev/dsk/c4t13d0

Note the number of Free PEs

# lvcreate -l /dev/vg01
# newfs -F vxfs /dev/vg01/rlvol1
# mount /dev/vg01/lvol1 /

Now restore your data.


Cheers!!



Yesterday is history, tomorrow is a mystery, today is a gift. That's why it's called the present.