1834666 Members
2569 Online
110069 Solutions
New Discussion

lvextend options

 
SOLVED
Go to solution
Todd McDaniel_1
Honored Contributor

lvextend options

I am trying to recreate my /tmp directory with 8GB on a new disk by adding 2 new disks to the VG01, one of which will be the mirror. It is under vg01 not vg00 so that is not an issue.

The line with "lvextend -l 1 /dev/dsk/cXtXdX" is the one I have a question about.


I have this procedure that I got from a co-worker for adding disks to a VG and I need some advice about a certain line. It appears that it is only adding 1 LE to it.

umount /tmp
lvremove /dev/vg01/tmp
lvcreate -n tmp /dev/vg01
####
lvextend -l 1 /dev/vg01/tmp /dev/dsk/c3t3d0 #### Is this a good line???
lvextend -m 1 /dev/vg01/tmp /dev/dsk/c4t3d0
lvextend -L 8000 /dev/vg01/tmp /dev/dsk/c3t3d0 /dev/dsk/c4t3d0
newfs -F vxfs /dev/vg01/rtmp
mount /tmp


It appears that they are doing this to begin the process of mirroring, but it looks like it is doing the same thing 2 commands later when it lvextends -L 8000.

I think I could just get rid of that command and move up the one from 2 lines below and then do the miror command.

please help me clarify this.

Unix, the other white meat.
13 REPLIES 13
A. Clay Stephenson
Acclaimed Contributor

Re: lvextend options

I would simply do the lvextend -L 8000 /dev/vg01/tmp /dev/dsk/c3t3d0 first
and then do the mirror.
lvextend -m 1 /dev/vg01/tmp /dev/dsk/c4t3d0

I like the fact that you are mirroring on separate SCSI buses.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: lvextend options

By the way, you should never need a huge /tmp but rather might need a large /var/tmp. /tmp should really only be used for system temp files. /var/tmp should be used for all user temp files. I suggest that /var/tmp (and possibly /var/spool and /var/mail) be separate mountpoint because a full /var filesystem will stop a box in its tracks.
If it ain't broke, I can fix that.
Sanjay_6
Honored Contributor
Solution

Re: lvextend options

Hi,

I normally do it this way,

# lvcreate -n lv_name /dev/vg_name
# lvextend -L size_MB /dev/vg_name/lv_name /dev/dsk/first_pv
# lvextend -m 1 /dev/vg_name/lv_name /dev/dsk/second_pv

You can use more options with lvcreate command to suit your specific requirements. See "man lvcreate" for more help on lvcreate command.

Hope this helps.

Regds

Patrick Wallek
Honored Contributor

Re: lvextend options

You can combine the lvcreate and lvextend commands into 1 command:

lvcreate -L 8000 -m 1 -s y -n tmp /dev/vg01

This will work if /dev/dsk/c3t3d0 and /dev/dsk/c4t3d0

The '-s y' option will tell lvcreate that the primary and mirror extents can NOT occupy the same physical disk.
Ted Ellis_2
Honored Contributor

Re: lvextend options

it is a functional line, but that only creates a 1 extent logical volume...

think you may need a new approach. If you are adding these disks solely to support /tmp... then I think you should just create a new volume group and not extend vg01. Try this:

1. pvcreate /dev/rdsk/cxtxdx (the new disks)
2. mkdir /dev/vg02 (or whatever is next in sequence)
3. cd /dev/vg02
4. mknod group c 64 0x02000 (the 2 needs to be unique, but making it match the vg number usually covers this)
5. vgcreate /dev/vg02 /dev/dsk/cxtxdx /dev/dsk/cxtxdx (use the 2 disks you just created)
6. lvcreate -L 8000 -n tmp /dev/vg02
7. newfs -F vxfs /dev/vg02/rtmp

** now you need to decide if you want any files in the current /tmp... if you do, save them somewhere with a tar (tar -cvf /var/xxx.tar /tmp)

You may also have trouble getting /tmp unmounted if the system is busy... at any rate

8. umount /tmp
9. Edit the /etc/fstab file (after saving a copy somewhere) and create a line for the new /tmp and remove the old one.
10. mount -a will mount the new /tmp and also verify that the /etc/fstab is clean
11. bdf... should see a nice fat 8 GB /tmp
12. Restore /tmp files if you wanted them from the tar (tar -xvf /var/xxx.tar)
13. perform a vgdisplay -v vg02 and see if all of the extents created are on one disk and note the one that has none on it (/dev/dsk/cxtxdx)
14. now mirror: lvextend -m 1 /dev/vg02/tmp /dev/dsk/cxtxdx

whew...

Ted
James R. Ferguson
Acclaimed Contributor

Re: lvextend options

Hi Todd:

I agree with Clay.

Perhaps your co-worker was thinking (or adopted this code) from a situation where he/she wanted to 'lvcreate' a logical volume but target it to a specific physical volume of a volume group. In the ase of 'lvcreate' omitting the '-l' and '-L' options allows a logical volume to be created with zero length. In turn, this permits you to choose its physical volume location when you allocate logical extents with the 'lvextend'.

Regards!

...JRF...

Todd McDaniel_1
Honored Contributor

Re: lvextend options

Thanks for the help. I am beginning to think he just mistyped it or cut and pasted badly and had an extra line in there by mistake.

Here is some more explanation of my situation with this box.

First, my /tmp, /usr/tmp and /var/tmp are linked to the /tmp directory, becuase many of my Oracle processes are hardcoded to write to /var/tmp which was very small, considering that /var is only 1.6GB.

Second, the reason I need 8GB for tmp is that this box is a major webserver along with 3 other ones and my DBAs like to have a lot of space for temp files generated by the web browser as well as for Oracle. Potentially, I could have several hundred users online at the same time.

Thanks for the -s y option, I knew about that option which is a very good suggestion to make sure that it is strict.

thanks again.
Unix, the other white meat.
Todd McDaniel_1
Honored Contributor

Re: lvextend options

Great idea to create a new vg03, already have a vg02, in my case to have /tmp all by its lonesome!

That will be much easier than what I was going to do, trying to lvextend it where it was. I have 3 other filesystems in vg01. It will make it easier to administer down the road.
Unix, the other white meat.
Tony Contratto
Respected Contributor

Re: lvextend options

Hi Todd,

Here is my interpretation of the logic behind this procedure:

lvcreate -n tmp /dev/vg01

creates the new lvol with no size specified.


lvextend -l 1 /dev/vg01/tmp /dev/dsk/c3t3d0

extend the size of the lvol to be 1 extent on the specified PV.


lvextend -m 1 /dev/vg01/tmp /dev/dsk/c4t3d0

Create the mirror of the lvol on the specified PV. Since the previous lvextend command only made the size of the lvol 1 extent, which defaults to 4MB, the sync of the lvol that happens when you create the mirror will be very fast.


lvextend -L 8000 /dev/vg01/tmp /dev/dsk/c3t3d0 /dev/dsk/c4t3d0

Now, AFTER it is mirrored, extend it to the size you want.


newfs -F vxfs /dev/vg01/rtmp

create the new file system on the lvol.


If you had created the lvol as 8GB, then did the lvextend to mirror it, the process would take much longer to execute. Since you are creating this as a new lvol there is no reason to copy all 8GB of data between the two disks, especially when the next command is to do a newfs.

Just my $0.02

--
Tony
got root?
Bernhard Mueller
Honored Contributor

Re: lvextend options

Hello,

just like to add that Anthony absolutely hit it.

this procedure will speed up the process by HOURS if you need to set up lvm mirrored lvols with a total of hundred or more GB - especially on a D- or K-Class.

Regards,
Bernhard

Tony Contratto
Respected Contributor

Re: lvextend options

Thanks Bernhard.

Also, Patrick's solution would provide the same results minus the capability of specifying explicitly which disks to use.

--
Tony
got root?
fg_1
Trusted Contributor

Re: lvextend options

Hello there

just perform the lvextend and fsadm commands listed below:

lvcreate -L 8000 -m 1 -s y -n tmp /dev/vg01

fsadm -F vxfs /dev/vg01/rtmp

Hope this helps

fg.





David_246
Trusted Contributor

Re: lvextend options

Hi ,

A very late reply, but I think it is still valuable. The notes from your collegue are absolute correct.
The reason why he first created a volume containing 1 PE is because you want to mirror it.

If you first make an 80 Gb Volume and than start mirroring, the disk will resync the 80 Gb of "data". If you first create a 1 Pe (most of all 4 or 8 Mb) volume, you will sync only 8 Mb data a max when you start mirroring.
When you add 80 Gb now, your data does not need a resync, but just gets added in mirror format. This saves you lots of disk load and waiting time, before you can proceed to take next steps.

In short; adding a mirror needs resyncing your current volume data. If you keep your volume as small as possible it saves resync time.

Notice : Once you already have a mirrored volume, no resyncing is necesary when increasing the volume size.

Regs David
@yourservice