Operating System - HP-UX
1831602 Members
2310 Online
110027 Solutions
New Discussion

Re: Physically removing a file system?

 
Darren Eckhoff
Advisor

Physically removing a file system?

I'm trying to remove a file system so I can use the logical volume as a swap device, but I can't find a command to remove the file system physically from the LVOL.

I tried using "lvremove" then "lvcreate" but it still says the LV has a file system even though I'm not recreating one (i.e. I am NOT using newfs or mkfs). It's as though using "lvremove" doesn't actually erase the data even though the man page says it does.

Any ideas?
12 REPLIES 12
James R. Ferguson
Acclaimed Contributor

Re: Physically removing a file system?

Hi Darren:

> I tried using "lvremove" then "lvcreate" but it still says the LV has a file system even though I'm not recreating one

Post (exactly) the sequence of commands you have used, please, including how you then attempt to create your swap.

Regards!

...JRF...
Ivan Krastev
Honored Contributor

Re: Physically removing a file system?

You can delete the logical volume with lvremove and recreate it again for swap usage.

regards,
ivan
SKR_1
Trusted Contributor

Re: Physically removing a file system?

umount the FS and use lvremove command to remove lvol. Then check with vgdisplay command for the new free space. Then do lvcreate for creating new FS. And use swapon command to make it as swap.

Thanks

SKR
ManojK_1
Valued Contributor

Re: Physically removing a file system?

I think you are not unmounted the filesystem before doing the lvremove command.

Please unmount the FS.
Do a lvremove then do a lvcreate. It will work.

Manoj K
Thanks and Regards,
Manoj K
Wim Rombauts
Honored Contributor

Re: Physically removing a file system?

You indeed have to first unmount the filesystem, but then, what is the issue with the filesystem being there ?
Add the Logical volume to your device swap, and I assure you that not much will be left of the filesystem that was on it as soon as the system starts swapping to the volume.
There is no need to driop an LV and create one specific for swap. an LV is an LV and is just a storage area. What you do with it is up to you. Device swap does not need any pre-formatting, just use it.

likid0
Honored Contributor

Re: Physically removing a file system?

The only advantange is that if you wan't to add that swap device to your dump space, it has to be contigous, if not you can recreate using the lvcreate -C y

Windows?, no thanks
Darren Eckhoff
Advisor

Re: Physically removing a file system?

Yes, I've gone through all the steps mentioned, unmount filesystem, lvremove, lvcreate (with -C option), but as I said before, lvremove doesn't actually destroy the data.

Here's an experiment I just did (this works on 11.23 and 11.31):

=======================
# lvcreate -l 5 -n lvtest vg00
Logical volume "/dev/vg00/lvtest" has been successfully created with
character device "/dev/vg00/rlvtest".
Logical volume "/dev/vg00/lvtest" has been successfully extended.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf
# newfs -F vxfs /dev/vg00/rlvtest
version 5 layout
81920 sectors, 81920 blocks of size 1024, log size 1024 blocks
unlimited inodes, largefiles not supported
81920 data blocks, 80808 free data blocks
3 allocation units of 32768 blocks, 32768 data blocks
last allocation unit has 16384 data blocks
# mkdir /test
# mount /dev/vg00/lvtest /test
# echo "test data" > /test/file1
# cat /test/file1
test data
# umount /test
# lvremove /dev/vg00/lvtest
The logical volume "/dev/vg00/lvtest" is not empty;
do you really want to delete the logical volume (y/n) : y
Logical volume "/dev/vg00/lvtest" has been successfully removed.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf
# lvcreate -l 5 -n lvtest vg00
Logical volume "/dev/vg00/lvtest" has been successfully created with
character device "/dev/vg00/rlvtest".
Logical volume "/dev/vg00/lvtest" has been successfully extended.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf
# mount /dev/vg00/lvtest /test
# cat /test/file1
test data
=====================

Notice I did NOT rerun "newfs" the second time I made the LV.

Try the above commands yourself.
Wim Rombauts
Honored Contributor

Re: Physically removing a file system?

Still, what's your problem ?

Please unmount the filesystem, stop using lvremove and lvcreate and start using swapon on the logical volume and go ahead with your extra device swap.

That was what you want to do, not ? Don't bother about the filesystem. It will be overwritten (and thereby destroyed) by swap activity.
James R. Ferguson
Acclaimed Contributor

Re: Physically removing a file system?

HI (again):

Simply issuing 'lvremove' does not do anything to the underlying physical disk's data as you found aside from destroying the metadata in the LVM header that relates to the logical volume. This is expected.

Did you do your device swap creation along these lines?

# lvcreate -C y -r n -l 5 -n lvolN /dev/vg00

# swapon -p 0 /dev/vg00/lvolN

Regards!

...JRF...


Wim Rombauts
Honored Contributor

Re: Physically removing a file system?

By the way,

lvremove does nothing more than remove a configuration line in the lvm configuration file and mark the extents as unused. It's like deleting a file : The pointer to the file in the directory is removed, and th block are set "available" but the effective file is still there.

lvcreate does nothing more than adding a line in the lvm configuration file and mark the extents as used.

So if you lvremove an LV and the lvcreate another LV of the same size, the filesystem will indeed be still there. Even if you lvcreate a smaller LV, the filesystem will seem to be there, until you write it full and the filesystem wants to access blocks that are now outside the LV.
Darren Eckhoff
Advisor

Re: Physically removing a file system?

Ok thanks for the suggestion on just using swapon to destroy the file system. At first I wasn't aware I could do this because it complains about the file system being there and won't activate. That lead me to believe I had to first remove the file system with lvremove (and I'd like to point out that the man page for lvremove clearly says it destroys the data, which is inaccurate).

Using the "-f" option with swapon did the trick.
Darren Eckhoff
Advisor

Re: Physically removing a file system?

Closing comment: "swapon -f" solved the problem.