Operating System - HP-UX
1837835 Members
2436 Online
110121 Solutions
New Discussion

Decrease the size of a logical volume without data loss

 
Chandrasekar_2
Occasional Advisor

Decrease the size of a logical volume without data loss

I have a HP workstation running on HP-UX 10.x. I have a problem with reducing
the size of logical volumes. I created a volume group using one of the hard
disks . I got a new hard disk and assigned it to the same volume group as that
of the former. I increased the size of my logical volumes mounted on /home and
/usr to use the new hard disk. I want to revert back these changes i.e I want
to remove the physical extents of the new physical volume(new hard disk)
alloted to the logical volumes mounted on /home and /usr. In short I want
/home and /usr to be confined to my old hard disk. Is it possible to do it
without any data loss as this is a big requirement for me. Could you please
explain the steps in detail on how to go about doing this?
regards
chandrasekar
13 REPLIES 13
nancy rippey
Trusted Contributor

Re: Decrease the size of a logical volume without data loss

What I would do if the space is available on the disk is to create a new logical volume
/home1 the size you wish to have, make the file system and directory and mount the filesystem as /home1
Then copy the data from /home to /home1
cd /home
tar cvf - . | (cd /home1; tar xvpf - )
Once this is complete I would umount /home
Rename /home1 as /home and remount it.

There are sure to be other ways, possible lvreduce but you would not lose any data this way.

Hope this helps
nrip
harry d brown jr
Honored Contributor

Re: Decrease the size of a logical volume without data loss

chandrasekar,

The safest bet is to back up your FileSystems, then remove them, recreate them the way you want, and restore your FS's.

live free or die
harry
Live Free or Die
Krishna Prasad
Trusted Contributor

Re: Decrease the size of a logical volume without data loss

Nancy - has a good idea if you have the space. You can also use the cp -r command if you have the space.

If this is not possible you will have to backup up your directories. umount the filesystems. remove the logical volumes from the volume group. re-create the logical volumes with the correct size. create new filesystem. mount filesystem. restore data from backup.

Simply put lvreduce will corrupt your filesystem.
Positive Results requires Positive Thinking
Chandrasekar_2
Occasional Advisor

Re: Decrease the size of a logical volume without data loss

Hi Nancy
The problem I have is that I dont have space left in my old hard disk to create a new logical volume.
Victor BERRIDGE
Honored Contributor

Re: Decrease the size of a logical volume without data loss

Hi,
If you are sure all enters on one disk, then try Ignite-UX => do a make_recovery of all vg00, then boot from the tape and reinstall using make_recovery's interractive menus to give the new sizes you want...

All the best

Victor
nancy rippey
Trusted Contributor

Re: Decrease the size of a logical volume without data loss

Do you happen to have enough space on one of your other filesystems to copy the data of /home, blow away the home directory and logical volume, receate it and then copy the data back. You could then do the same with /usr. If you don't they you will have to copy the data to tape or another server, remove the logical volumes and then recreate them as Harry and Ron mentioned.

nancy
nrip
James R. Ferguson
Acclaimed Contributor

Re: Decrease the size of a logical volume without data loss

Hi:

I presume that you expanded your filesystem (via 'extendfs' or 'fsadm') after enlarging the logical volume (via 'lvextend').

If this is the case, then if you have Online JFS, you *might* be successful dynamically shrinking the filesystem (via 'fsadm'), and then doing an 'lvreduce'.

If you do not have Online JFS, and you have enlarged the filesystem with 'extendfs', then to shrink it, you *must* backup the filesystem; 'lvreduce', 'newfs'; and restore your data.

*IF* you *only* went as far as the 'lvextend', but never did an 'extendfs' on the filesystem, then you should be able to 'lvreduce' the extents without needing to restore the filesystem.

Regards!

...JRF...
Chandrasekar_2
Occasional Advisor

Re: Decrease the size of a logical volume without data loss

Hi everyone
Thanks for the help. It seems to work fine for /home directory. But now Iam faced with a bigger problem.I made a backup of my /usr in /opt which was the only directory which had space in it. Then I turned to single user mode to unmount /usr directory. But when I want to copy (i.e. move since no /usr is there) the directory back to /usr, the directory tree under /opt is not visible in single -user mode. How do I go abt doing this?
Thanks in advance
regards
chandrasekar
Patrick Wallek
Honored Contributor

Re: Decrease the size of a logical volume without data loss

To see /opt while in single user mode do:

# mount /opt
Chandrasekar_2
Occasional Advisor

Re: Decrease the size of a logical volume without data loss

Hi Patrick
Thanks for the info. But I tried to exit out of single user mode by pressing run-level 3, which I think is multi-user mode. System hangs now.How do I get back again in single user mode to do the changes you have suggested me.Iam a novice to this field.Bail me out
regards
chandrasekar
Michael Tully
Honored Contributor

Re: Decrease the size of a logical volume without data loss

Hi,

When you are in single user mode, you can
mount whatever filesystem you like. From
where you stand now, you need to reboot
your system back into single user mode, before
proceeding further. By default /opt is
not mounted in single user mode. You can
mount as suggested by Patrick.

-Michael
Anyone for a Mutiny ?
Chandrasekar_2
Occasional Advisor

Re: Decrease the size of a logical volume without data loss

Hi
I got to single user mode and tried to move the files from /opt/usr1 to my original /usr directory as the cp doesnot work. I gave this logical volume the original size which I gave earlier when it occupied single hard disk. But now it is not able to copy all the files. It says the file system is full.
This is the foll which I did in single user mode
i) umount /usr
ii) lvremove -f /dev/vgoo/lvol8
iii) lvcreate -s n -n lvol8 vg00
iv) lvextend -L 1128 /dev/vg00/lvol8 /dev/dsk/c0t6d0 (original hard disk)
v) newfs -F hfs /dev/vg00/rlvol8
vi) mount /usr
vii) mv /opt/usr1/* /usr
I have a big problem with the mv command as it had split the files between /usr and /opt/usr1 due to incompletion. Can someone explain why am I not able to copy to a logical volume mounted on /usr which was existend before.
I checked out the details of the physical volume. It says it occupies all the extents.
Please mail me asap as I have to make this system ready by tommorrrow. thanks in advance
regards
chandrasekar
Chandrasekar_2
Occasional Advisor

Re: Decrease the size of a logical volume without data loss

Hi everyone
My problems seem to accrue like anything. I tried rebooting the system .Now it gives me an error
"INIT:single user mode"
crt0:Error couldnt open /usr/lib/dld.sl errno:000000002
This messages goes in a loop and Iam unable to go to the command prompt.
I think I wud be fine with having the /usr on two hard disk then to update the HP-UX OS which I cant afford doing it
Please Could someone tell me what shud I do abt this?
regards
chandrasekar