Re: [linux-lvm] Swapping LLVM drive

2023-08-28 Thread Stuart D Gathman

On Sun, 27 Aug 2023, Roska Postit wrote:


What is the most proper way to swap my 500GB SSD drive to the bigger 2TB SSD
drive in the following LLVM configuration ?

nvme0n1            259:0    0 465,8G  0 disk  
├─nvme0n1p1        259:1    0   512M  0 part  /boot/efi
├─nvme0n1p2        259:2    0   488M  0 part  /boot
└─nvme0n1p3        259:3    0 464,8G  0 part  
  ├─pc3--vg-root   254:0    0 463,8G  0 lvm   /
  └─pc3--vg-swap_1 254:1    0   980M  0 lvm   [SWAP]


Since you are not mirroring, just add the new drive.

If this is a laptop, and you can only have one drive, then I suggest
you mount the new drive via USB (note there are at least 2 kinds of
nvme interface and you have to get a matching USB enclosure).

Use dd to copy the partition table (this also often contains boot code)
to the new disk on USB.
Then use dd to copy the smaller partitions (efi,boot). 
Now use cfdisk to delete the 3rd partition. 
Expand the boot partition to 1G (you'll thank me later).

Allocate the entire rest of the disk to p3.
Create a new vg with a different name.  Allocate root and swap on
new VG the same sizes.
Take a snapshot of current root (delete swap on old drive since you
didn't leave yourself any room), and use partclone to efficiently
copy the filesystem over to new root.

Either a) edit grub and fstab on new drive to use new vg name  or
   b) boot from a live media to rename old and new vg or
   c) rename vg just before shutting down to remove drive -
  I think LVM can operate with dup VG name, but I've never
  navigated the details.

Swap drives after powerdown.

A modern filesystem like ext2, xfs, btrfs, etc can expand as you expand
the root LV.  Leave yourself some working room in the VG.___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/


Re: [linux-lvm] indistinguishable column names ( BA Start Start Start Start )

2023-08-28 Thread matthew patton
use json output and familiarize yourself with JQ.On Wednesday, August 23, 
2023 at 02:53:23 AM EDT, Roland  wrote:  
 
  
Hi, 
 
 > Hi Roland, is `lvs --reportformat json` or `lvs --nameprefixes` good enough?
 
 good when using scripting / automated processing - but not good, when we need 
it human readable.
 
 i'd even would call it a bug, when using same strings for "translated" names.
 
 would anybody accept something like this (just for saving column space) ?  ok, 
that's a little bit over the top - but i wand to underline what i mean
 
 getpersondetails -o forename, surname, streetname, cityname
 
 name        name    name            name
 john          doe  highstreet     washington    
 
 
 roland
 
 
 
 
 
 Am 21.08.23 um 18:00 schrieb Marian Csontos:
  
 
Hi Roland, is `lvs --reportformat json` or `lvs --nameprefixes` good enough? 
  On Sat, Aug 19, 2023 at 6:06 PM Roland  wrote:
  
 > furthermore, it's a little bit weird that some columns being printed 
 by default when using -o, is
  > there an easier way to remove those besides explictly removing them 
 one by one with several -o options ? "-o-opt1,-opt2,..." doesn't work
 
 sorry for this noise, i was too dumb for that , "-o+opt1,opt2 
 -o-opt3,opt4" works as desired (as documented in manpage)
 
  > themselves,and there also seems no way to add separators in between 
 (like with printf) for separation/formatting
 
 also sorry for this, as we can use --separator=","   (apparently did 
 have too much coffee and had overseen that in the manpage)
 
 the question regarding native column headers/description remains
 
 roland
 
 Am 19.08.23 um 17:20 schrieb Roland:
 > hello,
 >
 > does somebody know how we can have native (i.e. non translated) column 
 > field names in first line of output of pvs ?
 >
 > in its current implementation, output is hard to read , difficult to 
 > distinguish and also not scriptable/parseable, as whitespace is used 
 > for field separator and there are fields which also contain whitespace 
 > themselves,and there also seems no way to add separators in between 
 > (like with printf) for separation/formatting
 >
 > # pvs --units s -o+pv_ba_start,seg_start,seg_start_pe,pvseg_start
 >   PV VG    Fmt  Attr PSize    PFree BA Start Start    
 > Start Start
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S   0S 
 > 2097152S 1 0
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S   0S 
 > 2097152S 1 1
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S 0S 0S 0  5309
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S 0S 0S 0  5587
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S 0S 0S 0  5588
 >
 > i mean like this:
 >
 > # pvs --units s -o+pv_ba_start,seg_start,seg_start_pe,pvseg_start
 >   PV VG    Fmt  Attr PSize    PFree pv_ba_start 
 > seg_start seg_start_pe pvseg_start
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S      0S 
 > 2097152S    1   0
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S  0S 
 > 2097152S            1   1
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S 0S 0S            0 
 >        5309
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S 0S 0S            
 > 0    5587
 >   /dev/sdb   VGrecycle lvm2 a--  11720982528S    0S 0S 0S    
 > 0    5588
 >
 > furthermore, it's a little bit weird that some columns being printed 
 > by default when using -o, is there an easier way to remove those 
 > besides explictly removing them one by one with several -o options ? 
 > "-o-opt1,-opt2,..." doesn't work
 >
 > # pvs --units s -o+pv_ba_start,seg_start,pvseg_start,seg_start_pe 
 > -o-vg_name -o-pv_name -o-pv_fmt -o-attr -o -pv_size -o -pv_free
 >   BA Start Start    Start Start
 >     0S 2097152S 0 1
 >     0S 2097152S 1 1
 >     0S   0S  5309 0
 >     0S   0S  5587 0
 >     0S   0S  5588 0
 >
 > roland
 >
 ___
 linux-lvm mailing list
 linux-lvm@redhat.com
 https://listman.redhat.com/mailman/listinfo/linux-lvm
 read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
 
  
  ___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
 ___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
  ___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/


[linux-lvm] Swapping LLVM drive

2023-08-28 Thread Roska Postit
What is the most proper way to swap my 500GB SSD drive to the bigger 2TB
SSD drive in the following LLVM configuration ?

nvme0n1259:00 465,8G  0 disk
├─nvme0n1p1259:10   512M  0 part  /boot/efi
├─nvme0n1p2259:20   488M  0 part  /boot
└─nvme0n1p3259:30 464,8G  0 part
  ├─pc3--vg-root   254:00 463,8G  0 lvm   /
  └─pc3--vg-swap_1 254:10   980M  0 lvm   [SWAP]

btw. You don't need to give me step by step instructions just some
directions and ideas would be just fine.
___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/


Re: [linux-lvm] Swapping LLVM drive

2023-08-28 Thread Phillip Susi


Stuart D Gathman  writes:

> Use dd to copy the partition table (this also often contains boot code)
> to the new disk on USB.
> Then use dd to copy the smaller partitions (efi,boot). Now use cfdisk
> to delete the 3rd partition. Expand the boot partition to 1G (you'll
> thank me later).
> Allocate the entire rest of the disk to p3.
> Create a new vg with a different name.  Allocate root and swap on
> new VG the same sizes.
> Take a snapshot of current root (delete swap on old drive since you
> didn't leave yourself any room), and use partclone to efficiently
> copy the filesystem over to new root.

Why would you use dd/partclone instead of just having LVM move
everything to the new drive on the fly?

Partition the new drive, use pvcreate to initialize the partition as a
pv, vgextend to add the pv to the existing vg, pvmove to evacuate the
logical volumes from the old disk, then vgreduce to remove it from the
vg.

Don't forget you'll need to reinstall grub on the new drive for it to
boot.

___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/



[linux-lvm] vgchange acquire an exclusive VG lock for refresh

2023-08-28 Thread wangzhiqiang (Q)
I've got an issue while execute vgchange --refresh concurrently, process 
vgchange and systemd-udevd
enters the D state.
root2933  0.0  1.0  54216 31344 pts/1D] dm_wait_for_bios_completion+0x298/0x340 [dm_mod]
[<0>] dm_wait_for_completion+0xfe/0x110 [dm_mod]
[<0>] __dm_suspend+0xd0/0x310 [dm_mod]
[<0>] dm_suspend+0x133/0x180 [dm_mod]
[<0>] dev_suspend+0x115/0x150 [dm_mod]
[<0>] ctl_ioctl+0x320/0x4c0 [dm_mod]
[<0>] dm_ctl_ioctl+0x26/0x40 [dm_mod]
[<0>] __se_sys_ioctl+0xeb/0x120
[<0>] do_syscall_64+0x30/0x40
[<0>] entry_SYSCALL_64_after_hwframe+0x61/0xc6
[root@localhost ~]# cat /proc/2935/stack
[<0>] dm_suspend+0x2b/0x180 [dm_mod]
[<0>] dev_suspend+0x115/0x150 [dm_mod]
[<0>] ctl_ioctl+0x320/0x4c0 [dm_mod]
[<0>] dm_ctl_ioctl+0x26/0x40 [dm_mod]
[<0>] __se_sys_ioctl+0xeb/0x120
[<0>] do_syscall_64+0x30/0x40
[<0>] entry_SYSCALL_64_after_hwframe+0x61/0xc6
[root@localhost ~]# cat /proc/2951/stack
[<0>] __lock_page+0x25a/0x7a0
[<0>] truncate_inode_pages_range+0xc52/0x1370
[<0>] __blkdev_put+0x15b/0x3f0
[<0>] blkdev_close+0x49/0x60
[<0>] __fput+0x1b9/0x480
[<0>] task_work_run+0xad/0xf0
[<0>] do_exit+0x47f/0x810
[<0>] do_group_exit+0x77/0x150
[<0>] get_signal+0x2a2/0xa60
[<0>] arch_do_signal_or_restart+0x1c6/0x310
[<0>] exit_to_user_mode_loop+0xdb/0x100
[<0>] exit_to_user_mode_prepare+0x7e/0x90
[<0>] syscall_exit_to_user_mode+0x12/0x40
[<0>] entry_SYSCALL_64_after_hwframe+0x61/0xc6

I recommend get an exclusive lock when vgchange --refresh.

>From 7ddadf2bbbe0383893ab8f5b7cb8d51ebf7a5ed4 Mon Sep 17 00:00:00 2001
From: wangzhiqiang 
Date: Tue, 29 Aug 2023 10:28:15 +0800
Subject: [PATCH] vgchange acquire an exclusive VG lock for refresh.

Let's run the following test cases, we've got hungtask.
P2 or P3 can't suspend snap and udevd also can't read
device info because real or cow has been suspend.

P1(vgchange)  P2(vgchange)  P3(vgchange)

suspend real
suspend cow
  suspend snap
suspend snap
suspend snap

function query()
{
while true
do
vgchange --refresh
done
}

query 1 &> /dev/null &
query 2 &> /dev/null &
query 3 &> /dev/null &

[  247.250669] INFO: task vgchange:2934 blocked for more than 122 seconds.
[  247.251935] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this 
message.
[  247.252619] task:vgchangestate:D stack:0 pid: 2934 ppid:  2930 
flags:0x0080
[  247.252626] Call Trace:
[  247.252633]  __schedule+0x547/0xe80
[  247.252640]  ? io_schedule_timeout+0xb0/0xb0
[  247.252647]  ? _raw_spin_lock+0x7a/0xd0
[  247.252652]  schedule+0x6f/0x130
[  247.252658]  schedule_preempt_disabled+0xa/0x10
[  247.252664]  __mutex_lock.constprop.0+0x311/0x700
[  247.252673]  ? kernel_text_address.part.0+0xb9/0xc0
[  247.252678]  ? ww_mutex_unlock+0x50/0x50
[  247.252685]  ? unwind_get_return_address+0x33/0x50
[  247.252692]  ? cred_has_capability.isra.0+0x14b/0x220
[  247.252698]  ? check_nnp_nosuid.isra.0+0x170/0x170
[  247.252704]  mutex_lock+0x114/0x130
[  247.252710]  ? __mutex_lock_slowpath+0x10/0x10
[  247.252716]  ? rwsem_down_write_slowpath+0x830/0x830
[  247.252733]  ? dm_get+0x40/0x70 [dm_mod]
[  247.252752]  ? dm_get_md+0xb3/0x120 [dm_mod]
[  247.252770]  dm_suspend+0x2b/0x180 [dm_mod]
[  247.252788]  dev_suspend+0x115/0x150 [dm_mod]
[  247.252805]  ctl_ioctl+0x320/0x4c0 [dm_mod]
[  247.252823]  ? dev_set_geometry+0x290/0x290 [dm_mod]
[  247.252841]  ? copy_params+0x2e0/0x2e0 [dm_mod]
[  247.252846]  ? locks_dispose_list+0xa0/0xd0
[  247.252851]  ? locks_remove_posix+0x24f/0x340
[  247.252856]  ? locks_remove_flock+0x1e6/0x250
[  247.252865]  ? ioctl_fiemap.isra.0+0x110/0x1e0
[  247.252872]  ? vfs_write+0x2a5/0x440
[  247.252877]  ? selinux_file_ioctl+0x89/0x1c0
[  247.252895]  ? ctl_ioctl+0x4c0/0x4c0 [dm_mod]
[  247.252912]  dm_ctl_ioctl+0x26/0x40 [dm_mod]
[  247.252918]  __se_sys_ioctl+0xeb/0x120
[  247.252923]  do_syscall_64+0x30/0x40
[  247.252929]  entry_SYSCALL_64_after_hwframe+0x61/0xc6

[  247.252967] INFO: task vgchange:2935 blocked for more than 122 seconds.
[  247.254242] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this 
message.
[  247.254909] task:vgchangestate:D stack:0 pid: 2935 ppid:  2931 
flags:0x0080
[  247.254922] Call Trace:
[  247.254929]  __schedule+0x547/0xe80
[  247.254935]  ? io_schedule_timeout+0xb0/0xb0
[  247.254942]  ? _raw_spin_lock+0x7a/0xd0
[  247.254947]  schedule+0x6f/0x130
[  247.254953]  schedule_preempt_disabled+0xa/0x10
[  247.254959]  __mutex_lock.constprop.0+0x311/0x700
[  247.254965]  ? kernel_text_address.part.0+0xb9/0xc0
[  247.254976]  ? ww_mutex_unlock+0x50/0x50
[  247.254981]  ? unwind_get_return_address+0x33/0x50
[  247.254988]  ? cred_has_capability.isra.0+0x14b/0x220
[  247.254995]  ? check_nnp_nosuid.isra.0+0x170/0x170
[  247.255000]  mutex_lock+0x114/0x130
[  247.255006]  ? __mutex_lock_slowpath+0x10/0x10
[