LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   LVM: Wanting to remove a partition from a Volume Grou (https://www.linuxquestions.org/questions/linux-general-1/lvm-wanting-to-remove-a-partition-from-a-volume-grou-488343/)

Jongi 09-30-2006 06:27 PM

LVM: Wanting to remove a partition from a Volume Grou
 
I have a volume group Home, created as such

Code:

# pvdisplay
  --- Physical volume ---
  PV Name              /dev/sda14
  VG Name              Home
  PV Size              32.88 GB / not usable 0
  Allocatable          yes (but full)
  PE Size (KByte)      4096
  Total PE              8418
  Free PE              0
  Allocated PE          8418
  PV UUID              NfTX8K-nJG0-xvCx-jyCm-l8Qu-5Wgk-gV7hpV

  --- Physical volume ---
  PV Name              /dev/hdd8
  VG Name              Home
  PV Size              30.31 GB / not usable 0
  Allocatable          yes (but full)
  PE Size (KByte)      4096
  Total PE              7759
  Free PE              0
  Allocated PE          7759
  PV UUID              3gLP4u-jEPr-qN13-OFKZ-5rzB-kZlw-eb2zxH

Code:

# vgdisplay Home
  --- Volume group ---
  VG Name              Home
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  8
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                1
  Open LV              1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size              63.19 GB
  PE Size              4.00 MB
  Total PE              16177
  Alloc PE / Size      16177 / 63.19 GB
  Free  PE / Size      0 / 0
  VG UUID              K4JT4Q-I31s-eypt-RBm0-Sisb-3g4O-0h3hLO

Code:

# pvmove /dev/hdd8
  No extents available for allocation

Both partitions and the volume group are formatted as reiserfs. I want to remove /dev/hdd8 as being part of the volume group.

I assume that the pvmove means that there is no data hdd8. Is that a correct assumption? If yes then I will do the below.

I am thinking of booting of a Knoppix LiveCD and using vgreduce Home /dev/hdd8. I will probably try use chroot to make sure that the FC install is referenced as the root directory.

haertig 09-30-2006 07:00 PM

You have a VG named "Home" that is made up of two PV's, /dev/sda14 (33Gb) and /dev/hdd8 (30Gb). VG "Home" is therefore 63Gb in size.

If you look at you pvdisplay and vgdisplay outputs, you'll see that everything is fully allocated (i.e., no more free space left). So you can't get rid of /dev/hdd8 because it's currently in use. You need to free it up before you can use vgreduce. That's what the pvmove command is for. To migrate data off of PV hdd8 to some other PV in it's same volume group.

But you have no room on the other PV in that group (sda14) to move anything on to, because sda14 fully allocated just like hdd8.

To get hdd8 out of there, first you will need to clear up lots of space. This can be done by deleting files and then using lvreduce or lvremove to get rid of the space taked by the LV's assigned to VG "Home". Provided you remove enough stuff from VG "Home" so that it would only require 33Gb of space total (not the 63Gb it now requires), then you can start pvmove'ing and vgreduce'ing.

Use df to find out how much space you're using from your LV's. Just because you may have an LV created with 30Gb of space doesn't mean that's all in use. You may be able to do some lvreduce'ing. You will need to shrink the filesystem(s) on the LV before you can use lvreduce. Luckily you used Reiser, which is shrinkable. Some other filesystem types are not shrinkable (XFS, JFS, etc.)

Reduce operations always scare me. You should run a complete backup before doing this.

Jongi 09-30-2006 08:05 PM

You see this is the thing that made me ask about LVM:

Here is the free space on Home: 64452MB of 64706MB free

haertig 09-30-2006 10:21 PM

Quote:

Originally Posted by Jongi
Here is the free space on Home: 64452MB of 64706MB free

Yes. That is quite the waste of disk space. You have allocated 64Gb to /home, but you're only using 250Mb of that!

You're in luck. Everything you have under /home will easily fit on a CD. So backup is a no-brainer. I suggest you backup the entirity of /home to a CD. Fix your LVM, or delete it and start over, then restore /home from your backup CD. Since you'd have a solid backup of your /home to a CD, go ahead and play around to your heart's content with LVM. Resize your /home filesystem, then lvreduce, then pvmove, then vgreduce, etc. Just mess with it to learn all the steps and expose any pitfalls. If you totally destroy things in LVM, no matter ... you have a backup and can start over from scratch with LVM (if you want). Check out the LVM HowTo to learn about all the commands if you haven't already. http://tldp.org/HOWTO/LVM-HOWTO/

I'd certainly be interested in seeing your fdisk -l and cat /etc/fstab output. Not that it's relevent to your current problem. But with sda14 (FOURTEEN) and hdd8 (EIGHT) you've got to have a mess of partitions out there. Not to mention with hdd ("D") you've got to have a minor little disk farm attached (either that, or maybe a bunch of optical drives or other peripherals). I'd just be interested in seeing what you're doing with your system. Chances are you've got plenty of other disk space to backup 250Mb of /home without resorting to burning a CD (although I'd still go the CD route myself, for safety).

Jongi 10-02-2006 02:56 AM

Yeah I've basically set up the sda drive to house multiple distros. I've got another non-LVM partition available which I can backup the /home directory to.

The other option I thought of was (from the LVM HOWTO):

# resize_reiserfs -s-30.31G /dev/Home/lvol0
# lvreduce -L-30.31G /dev/Home/lvol0

then
# vgreduce Home /dev/hdd8

saikee 10-02-2006 06:22 AM

Sorry to barge in to learn something about LVM.

I have stayed away from LVM so that I can do whatever I wish with the partitions (got 60 and 57 partitions in my two IDE disks).

Looking at the problem reported here I wonder what benefit do we get ourselves into opting for LVM. I understand a LVM can link partitions across different disks but if we not not doing it what is the point of using it?

I know Grub (and possibly Lilo) has a problem of booting from a LVM because at the booting stage a boot loader has no access to a kernel and can't possibly go inside a LVM to find data to load. That limitation alone is an deterrent for users wanting to multiboot different systems. Have I got this wrong?

I ask the above question because it seems a user needs to do something extraordinary just to delete a partition.

haertig 10-02-2006 10:38 AM

Quote:

Sorry to barge in to learn something about LVM.
The mods are gonna get us for a hijack, so I emailed you with some of my thoughts on LVM. (From your profile, "Send a message via email to saikee".) It might be worthwhile for you to start a new thread "LVM? Why or why not?" or something to that effect. If you do, feel free to repost my email to that thread to start it off, if you'd like.

haertig 10-02-2006 11:09 AM

Quote:

Originally Posted by Jongi
# resize_reiserfs -s-30.31G /dev/Home/lvol0
# lvreduce -L-30.31G /dev/Home/lvol0

then
# vgreduce Home /dev/hdd8

You may or may not need a pvmove before the vgreduce. vgreduce should inform you of that need, if it exists.

Jongi 10-05-2006 10:24 AM

Code:

[root:~#] resize_reiserfs -s-30.31G /dev/Home/lvol0
resize_reiserfs 3.6.19 (2003 www.namesys.com)


resizer_reiserfs: the new size value is wrong.

So I also tried this before that:

Code:

[root:~#] umount /home
umount: /home: device is busy
umount: /home: device is busy

So I guess I will most likely need a LiveCD that can handle LVM

haertig 10-05-2006 11:07 AM

I can't comment on the Reiser resizing. I've only resized ext3 and xfs, and then, only to grow them, not shrink them.

Maybe I can help on the unmounting part though. I do not know whether Reiser wnats to be mounted or unmounted for resizing. I assume unmounted, because that's what you're trying to do here. I know ext3 needs to be unmounted to resize, but xfs and jfs are resized while they are mounted. I just don't know about Reiser. I assume you checked into that.

Whenever I'm doing my resizing, on my desktop system where I am the only user, I always drop down to single-user mode. That makes unmounting things much easier. Gets rid of all those other pesky user processes that cling to the filesystems making them hard to unmount (your "device is busy" errors).

Here's how I would resize a filesystem on my Debian computer. The steps should be similar on whatever distro you are using, but you may have to alter the final telinit command if your default multi-user runlevel is not 2 like mine. Also, your resize'ing and fsck'ing commands will be different for Reiser.
Code:

From Gnome, KDE, etc...
CTRL-ALT-F1 to grab a new virtual console
login: root
password: ...
# telinit 1  ( not very nice to other users, but since I'm the only one ... go ahead! )
# df -h /home
# umount /home
( the above should work, but if it's busy for some odd reason, try umount -l /home )
( if you still have "busy" problems, find out why with fuser -m /home | xargs ps -o'user,pid,cmd' -p or lsof /home )
# lvextend -L+1G /dev/vg_linux/home
# e2fsck -f /dev/vg_linux/home
# resize2fs /dev/vg_linux/home
# mount /home
# df -h /home
# telinit 2


Jongi 10-08-2006 11:19 AM

Regarding the resize_reiserfs command. Does that take only whole numbers? If that's the case and I issue the commands as follows:

resize_reiserfs -s -31G /dev/Home/lvol0
lvreduce -L-31G /dev/Home/lvol0
vgreduce Home /dev/hdd8

Should that work?

Jongi 10-08-2006 01:49 PM

So I did what I last posted.

Then I did:

Code:

# mkfs.reiserfs /dev/hdd8
# pvcreate /dev/hdd8
# vgextend Store /dev/hdd8
# lvextend -L +30.31G /dev/Store/lvol0 (I actually added incremently until it amounted to 30.31GB)

Now this is where my system is at:

Code:

[root:~#] cat /etc/fstab | grep Store
/dev/Store/lvol0        /mnt/Store              reiserfs defaults        1 2
[root:~#] df -h /mnt/Store/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/Store-lvol0
                      31G  30G  1.6G  95% /mnt/Store
[root:~#] pvdisplay
  --- Physical volume ---
  PV Name              /dev/sda14
  VG Name              Home
  PV Size              32.88 GB / not usable 0
  Allocatable          yes
  PE Size (KByte)      4096
  Total PE              8418
  Free PE              177
  Allocated PE          8241
  PV UUID              NfTX8K-nJG0-xvCx-jyCm-l8Qu-5Wgk-gV7hpV

  --- Physical volume ---
  PV Name              /dev/sda13
  VG Name              Store
  PV Size              30.00 GB / not usable 0
  Allocatable          yes (but full)
  PE Size (KByte)      4096
  Total PE              7679
  Free PE              0
  Allocated PE          7679
  PV UUID              OV6q8V-UWgF-TCgn-n5Nh-gtza-Kk6i-T2ahtt

  --- Physical volume ---
  PV Name              /dev/hdd8
  VG Name              Store
  PV Size              30.31 GB / not usable 0
  Allocatable          yes (but full)
  PE Size (KByte)      4096
  Total PE              7759
  Free PE              0
  Allocated PE          7759
  PV UUID              8pWwhL-agyR-8lb8-07vj-BZHo-HOlN-JzNtjN

  --- Physical volume ---
  PV Name              /dev/sda12
  VG Name              Games
  PV Size              39.99 GB / not usable 0
  Allocatable          yes (but full)
  PE Size (KByte)      4096
  Total PE              10238
  Free PE              0
  Allocated PE          10238
  PV UUID              BIr2Bf-E1Fd-CcId-NoZY-1c4A-o74M-mgbPz4
[root:~#] lvdisplay
  --- Logical volume ---
  LV Name                /dev/Home/lvol0
  VG Name                Home
  LV UUID                QrIb5n-XkLB-OSdC-4arw-ko73-y61b-7Hv7zs
  LV Write Access        read/write
  LV Status              available
  # open                2
  LV Size                32.19 GB
  Current LE            8241
  Segments              1
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:0

  --- Logical volume ---
  LV Name                /dev/Store/lvol0
  VG Name                Store
  LV UUID                FOiqSr-Ld44-pAdD-CjUh-fwnL-erzd-VV6NnP
  LV Write Access        read/write
  LV Status              available
  # open                2
  LV Size                60.30 GB
  Current LE            15438
  Segments              2
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:1

  --- Logical volume ---
  LV Name                /dev/Games/lvol0
  VG Name                Games
  LV UUID                tXUGRf-alNS-NMmC-pIc0-RJbk-DbsE-sGku2x
  LV Write Access        read/write
  LV Status              available
  # open                2
  LV Size                39.99 GB
  Current LE            10238
  Segments              1
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:2

How do I get df to show the balance free to 60.3GB?

Jongi 10-08-2006 02:41 PM

I hadn't resized the partition so the below did the trick

# resize_reiserfs -f /dev/Store/lvol0

Which now gives:

Code:

[jongi:~#] df -h /mnt/Store/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/Store-lvol0
                      61G  30G  31G  49% /mnt/Store

I ran all the command line instructions from Kubuntu Dapper 64-bit.

EDIT: My only concern now (and it is a small one) is that free 708MB under Home.

Jongi 11-01-2006 01:43 PM

I can't remember now but I think I solved the last issue by running:

# pvextend -l +177 Home /dev/Home/lvol0


All times are GMT -5. The time now is 03:48 AM.