Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Accidently added a Second LVM to my Swap

  1. #1
    Join Date
    Jul 2008
    Location
    Woodstock Cape Town RSA
    Beans
    1,030
    Distro
    Ubuntu 20.04 Focal Fossa

    Unhappy Accidently added a Second LVM to my Swap

    If I lsblk

    Code:
    sda                8:0    0 223.6G  0 disk 
    └─sda1             8:1    0 223.6G  0 part 
      ├─ubuntu--vg-root
      │              253:0    0 252.2G  0 lvm  /
      └─ubuntu--vg-swap_1
                     253:1    0   980M  0 lvm  [SWAP]
    sdb                8:16   0  29.6G  0 disk 
    └─sdb1             8:17   0  29.6G  0 part 
      └─ubuntu--vg-root
    was in the process of adding a 30GB LVM and resizing my root according to steps over here

    I got as far as the following step:

    sudo lvm lvextend -l +100%FREE /dev/ubuntu-box-1-vg/root
    and issued this command:

    Code:
    sudo lvm lvextend -l +100%FREE /dev/ubuntu-vg/root
    but realise it should have been something like this:

    sudo lvm lvextend -l +100%FREE /dev/mapper/ubuntu--vg-root
    Not sure how to get out of this one, am busy studying my options, including, extend and reduce.

    Would appreciate any advice or assistance, since I don't want to destroy my primary LVM.

    Both LVMs are now root but the extra space has been allocated to my swap, it seems.

    Code:
    cat /proc/swaps
    Filename				Type		Size	Used	Priority
    /dev/dm-1                               partition	1003516	0	-2
    Last edited by afrodeity; September 28th, 2020 at 07:53 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    Woodstock Cape Town RSA
    Beans
    1,030
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Accidently added a Second LVM to my Swap

    If I comment out my swap in /etc/fstab

    reboot and attempt to turn swapoff, the command fails:

    Code:
    sudo swapoff ubuntu--vg-swap_1
    swapoff: ubuntu--vg-swap_1: swapoff failed: Invalid argument
    I guess I have to reduce the size of the LVM group, somehow
    Last edited by afrodeity; September 28th, 2020 at 08:23 PM.

  3. #3
    Join Date
    Jul 2008
    Location
    Woodstock Cape Town RSA
    Beans
    1,030
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Accidently added a Second LVM to my Swap

    I I make sure the disk is unmounted:

    Code:
    umount /dev/sdb1
    umount: /dev/sdb1: not mounted.
    Code:
    sudo vgreduce ubuntu-vg /dev/sdb1
    
      Physical volume "/dev/sdb1" still in use
    afropunk@afropunk:~$ sudo umount /dev/sdb1

    still fails. I guess I have to boot with a live disk, and try this when both disks are no longer in use?

    UYet, it still appears feasible to do this without using a live disk:

    According to this thread on ServerFault:

    Not for the faint-hearted, am going to have dinner and attend to the matter in the morning
    Last edited by afrodeity; September 28th, 2020 at 08:37 PM.

  4. #4
    Join Date
    Jul 2008
    Location
    Woodstock Cape Town RSA
    Beans
    1,030
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Accidently added a Second LVM to my Swap

    Code:
    sudo pvdisplay /dev/ubuntu-vg
      Failed to find device for physical volume "/dev/ubuntu-vg"
    doesn't display the physical disks that form the ubuntu-vg lvm group,

    nor does this:
    Code:
    sudo pvdisplay /dev/mapper/ubuntu--vg-root
      Failed to find device for physical volume "/dev/mapper/ubuntu--vg-root".

  5. #5
    Join Date
    Jul 2008
    Location
    Woodstock Cape Town RSA
    Beans
    1,030
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Accidently added a Second LVM to my Swap

    Code:
    sudo lvreduce -L 223.57G /dev/mapper/ubuntu--vg-root
      Rounding size to boundary between physical extents: 223.57 GiB.
      WARNING: Reducing active and open logical volume to 223.57 GiB.
      THIS MAY DESTROY YOUR DATA (filesystem etc.)
    Do you really want to reduce ubuntu-vg/root? [y/n]: y
      /dev/sdb1: BLKDISCARD ioctl at offset 1032847360 size 30693916672 failed: Input/output error.
      Size of logical volume ubuntu-vg/root changed from <252.16 GiB (64552 extents) to 223.57 GiB (57234 extents).
      Logical volume ubuntu-vg/root successfully resized.
    now to remove the second drive from the vg?

  6. #6
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Accidently added a Second LVM to my Swap

    /dev/ubuntu-vg/root == /dev/mapper/ubuntu--vg-root
    Those both point to the same DM device. They use symbolic links. Nothing special about them. They are 100% normal, symlinks, just like any others on the box.

    In general, you don't need lvm + lvextend as an option. Just use lvextend as the command.
    Be very careful using lvreduce or lvresize. Always have backups before using either.

    I'd like to see some facts before saying anything more.
    Code:
    sudo pvs
    sudo vgs
    sudo lvs
    lsblk -e 7 -o name,size,type,fstype,mountpoint
    commands + output, please. All wrapped in code tags.
    Might be helpful to see the ftab file contents too. Please.

    For swap, I'd like to see swapon -s.

    Then if you can clearly say what you'd like changed about each LV, someone can help.

    pvdisplay, vgdisplay and lvdisplay are the old-school commands that show way more detail that we need for stuff like this. Let's keep it short and to the point, unless you want specific striping across different PVs.

    LVM is the system name. Once we know LVM is involved, we generally don't need anything more that say "lvm" anywhere.
    LV is a logical volume.
    VG is a volume group.
    PV is a physical volume.
    There is nothing called an "lvm group." It is important to use the correct terms for the correct objects to prevent confusion in communications. Please.

    When I see the other commands you are throwing at the shell, it looks like you aren't using the manpages to get the correct options required for each command. When working with LVM, you'll need to lookup those options. The same applies to swapon and swapoff commands. Incorrect and partial options aren't sufficient.

    So ... here's one of my systems fstab files:
    Code:
    UUID=9CE4-930A  /boot/efi       vfat    utf8,umask=007,gid=46 0       1
    /dev/vgubuntu-mate/root /       ext4    errors=remount-ro 0 1
    /dev/vgubuntu-mate/home /home   ext4    errors=remount-ro 0 1
    /dev/vgubuntu-mate/swap_1 none  swap    sw      0       0
    See how the LVs are all in /dev/vgubuntu-mate/?
    Code:
    regulus:/dev/vgubuntu-mate$ ll
    total 0
    drwxr-xr-x  2 root root  100 Sep 28 15:51 ./
    drwxr-xr-x 20 root root 4120 Sep 28 15:51 ../
    lrwxrwxrwx  1 root root    7 Sep 28 15:51 home -> ../dm-2
    lrwxrwxrwx  1 root root    7 Sep 28 15:51 root -> ../dm-0
    lrwxrwxrwx  1 root root    7 Sep 28 15:51 swap_1 -> ../dm-1
    They are just symlinks to device-mapper objects in /dev/. I can also see symlinks in the /dev/mapper/ directory:
    Code:
    regulus:/dev/mapper$ ll
    total 0
    drwxr-xr-x  2 root root     120 Sep 28 15:51 ./
    drwxr-xr-x 20 root root    4120 Sep 28 15:51 ../
    crw-------  1 root root 10, 236 Sep 28 15:51 control
    lrwxrwxrwx  1 root root       7 Sep 28 15:51 vgubuntu--mate-home -> ../dm-2
    lrwxrwxrwx  1 root root       7 Sep 28 15:51 vgubuntu--mate-root -> ../dm-0
    lrwxrwxrwx  1 root root       7 Sep 28 15:51 vgubuntu--mate-swap_1 -> ../dm-1
    They use slightly different names, but also point to exactly the same dm-? objects. 100% normal symbolic links. When we run swapon/off or lvextend commands, we can use any of these three different file objects. The dm-? files can change from boot to boot, so it is best to use the generated /dev/mapper/ or /dev/{vg-name}/{lv-name} files. I prefer to use the 2nd option, since those make sense to my human brain and convey extra knowledge. But you can use whatever you like.
    My fstab was manually edited to use the /dev/{vg-name}/{lv-name} version for my sanity. When we use LVM, we get rebuilt symlinks in those directories when the storage gets scanned during boot. Those symlinks are guaranteed to be correct, just like the symlinks for UUIDs are. UUIDs are handy, if we don't have any other choice. They are just symlinks too, BTW. Look in /dev/disk/by-uuid/ and you'll see the UUID symlinks that point to the device-mapper files.

    Hopefully, this can clarify why you see different names used in different arguments for swap and LV commands. They are probably pointing at the same things, but there are multiple different answers possible. That's all. Without a firm understand of symlinks and how they are used under /dev/, it is easy to become confused.

  7. #7
    Join Date
    Jul 2008
    Location
    Woodstock Cape Town RSA
    Beans
    1,030
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Accidently added a Second LVM to my Swap

    This is what it looks like now after lvreduce. Would appreciate advice on what my options are. Not sure now what I did wrong per my first post, but yes, its possibly lack of a man page, modifier.

    Code:
    sudo pvs
      PV         VG        Fmt  Attr PSize    PFree  
      /dev/sda1  ubuntu-vg lvm2 a--  <223.57g      0 
      /dev/sdb1  ubuntu-vg lvm2 a--   <29.55g <28.59g
    Code:
    sudo vgs
      VG        #PV #LV #SN Attr   VSize   VFree  
      ubuntu-vg   2   2   0 wz--n- 253.11g <28.59g
    Code:
    sudo lvs
      LV     VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      root   ubuntu-vg -wi-ao---- 223.57g                                                    
      swap_1 ubuntu-vg -wi-a----- 980.00m
    Code:
    lsblk -e 7 -o name,size,type,fstype,mountpoint
    NAME                    SIZE TYPE FSTYPE      MOUNTPOINT
    sda                   223.6G disk             
    └─sda1                223.6G part LVM2_member 
      ├─ubuntu--vg-root   223.6G lvm  ext4        /
      └─ubuntu--vg-swap_1   980M lvm  swap        
    sdb                    29.6G disk             
    └─sdb1                 29.6G part LVM2_member 
      └─ubuntu--vg-root   223.6G lvm  ext4        /
    sr0                    1024M rom
    swapon -s
    shows no summary of swaps, so I assume the swap is off, since I removed it from my fstab?

    Not sure why the VG size is still 253G but lsblk reports an LV of 223G ...?
    Last edited by afrodeity; September 29th, 2020 at 06:07 AM.

  8. #8
    Join Date
    Oct 2005
    Location
    Lab, Slovakia
    Beans
    10,794

    Re: Accidently added a Second LVM to my Swap

    Hmm, in general, I find that using a swap file is less hassle and there is no speed difference.

  9. #9
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Accidently added a Second LVM to my Swap

    I was nearly complete with a reply, then firefox crashed. Something is really wrong with firefox since I patched Saturday. It has been crashing every few hours. Got an updated version this morning and it appears to still be crashing.

    I'm not going to re-write all of that. Sorry. The gist is I still don't know what you think is wrong or what you actually did. There are 2 PVs, but no command is shown where the 2nd PV was added to the VG, so that doesn't appear to have been a mistake. What is it you believe is wrong? I can't guess.

  10. #10
    Join Date
    Jul 2008
    Location
    Woodstock Cape Town RSA
    Beans
    1,030
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Accidently added a Second LVM to my Swap

    As you can see /dev/sdb1 is 29G ssd. When I expanded the root file system, it didn't add as an expansion of the main file system, but rather, it extended my swap.

    I can try to expand again so that the total will include the space on sdb1 which is still part of the LVM?

    But need guidance on the correct method to do so, since clearly I missed something?

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •