linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
* [linux-lvm] Swapping LLVM drive
@ 2023-08-27 10:11 Roska Postit
  2023-08-28 14:53 ` Stuart D Gathman
  0 siblings, 1 reply; 8+ messages in thread
From: Roska Postit @ 2023-08-27 10:11 UTC (permalink / raw)
  To: linux-lvm


[-- Attachment #1.1: Type: text/plain, Size: 562 bytes --]

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]

btw. You don't need to give me step by step instructions just some
directions and ideas would be just fine.

[-- Attachment #1.2: Type: text/html, Size: 761 bytes --]

[-- Attachment #2: Type: text/plain, Size: 202 bytes --]

_______________________________________________
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/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-lvm] Swapping LLVM drive
  2023-08-27 10:11 [linux-lvm] Swapping LLVM drive Roska Postit
@ 2023-08-28 14:53 ` Stuart D Gathman
  2023-08-28 16:31   ` Roska Postit
  2023-08-28 22:31   ` Phillip Susi
  0 siblings, 2 replies; 8+ messages in thread
From: Stuart D Gathman @ 2023-08-28 14:53 UTC (permalink / raw)
  To: LVM general discussion and development

[-- Attachment #1: Type: text/plain, Size: 1862 bytes --]

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.

[-- Attachment #2: Type: text/plain, Size: 202 bytes --]

_______________________________________________
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/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-lvm] Swapping LLVM drive
  2023-08-28 14:53 ` Stuart D Gathman
@ 2023-08-28 16:31   ` Roska Postit
  2023-08-28 17:01     ` Roska Postit
  2023-08-28 22:31   ` Phillip Susi
  1 sibling, 1 reply; 8+ messages in thread
From: Roska Postit @ 2023-08-28 16:31 UTC (permalink / raw)
  To: LVM general discussion and development


[-- Attachment #1.1: Type: text/plain, Size: 2250 bytes --]

Thank you very much for your time. This was very very helpful.

ma 28. elok. 2023 klo 18.34 Stuart D Gathman (stuart@gathman.org) kirjoitti:

> 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/
>

[-- Attachment #1.2: Type: text/html, Size: 2964 bytes --]

[-- Attachment #2: Type: text/plain, Size: 202 bytes --]

_______________________________________________
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/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-lvm] Swapping LLVM drive
  2023-08-28 16:31   ` Roska Postit
@ 2023-08-28 17:01     ` Roska Postit
  2023-08-29 15:37       ` Stuart D Gathman
  0 siblings, 1 reply; 8+ messages in thread
From: Roska Postit @ 2023-08-28 17:01 UTC (permalink / raw)
  To: LVM general discussion and development


[-- Attachment #1.1: Type: text/plain, Size: 3119 bytes --]

After reading your answer more carefully I got the following idea:

How do you see if I boot the system (this is a desktop computer and the old
and the new drive are both NVMe SSD) from USB Linux and then just do a 'dd'
for the entire drive (in block level, bit-by-bit). Then I remove the old
disk out of the system. Shouldn't it boot normally now ?

Then I will create a new partition for the all unused space (1.5GB) on new
disk which I then will add to the LVM as a new Physical Volume (PV) in
pc3_vg group. Then I  just need to configure the Logical Volume to use that
new added storage space.

If this is possible I think it would be a bit simpler way to do this.

What do you think about this method ?

ma 28. elok. 2023 klo 19.31 Roska Postit (roskapostit99999@gmail.com)
kirjoitti:

> Thank you very much for your time. This was very very helpful.
>
> ma 28. elok. 2023 klo 18.34 Stuart D Gathman (stuart@gathman.org)
> kirjoitti:
>
>> 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/
>>
>

[-- Attachment #1.2: Type: text/html, Size: 4088 bytes --]

[-- Attachment #2: Type: text/plain, Size: 202 bytes --]

_______________________________________________
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/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-lvm] Swapping LLVM drive
  2023-08-28 14:53 ` Stuart D Gathman
  2023-08-28 16:31   ` Roska Postit
@ 2023-08-28 22:31   ` Phillip Susi
  2023-08-29 15:44     ` Stuart D Gathman
  1 sibling, 1 reply; 8+ messages in thread
From: Phillip Susi @ 2023-08-28 22:31 UTC (permalink / raw)
  To: Stuart D Gathman; +Cc: LVM general discussion and development


Stuart D Gathman <stuart@gathman.org> 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/


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-lvm] Swapping LLVM drive
  2023-08-28 17:01     ` Roska Postit
@ 2023-08-29 15:37       ` Stuart D Gathman
  0 siblings, 0 replies; 8+ messages in thread
From: Stuart D Gathman @ 2023-08-29 15:37 UTC (permalink / raw)
  To: LVM general discussion and development

On Mon, 28 Aug 2023, Roska Postit wrote:

> After reading your answer more carefully I got the following idea:

> How do you see if I boot the system (this is a desktop computer and the old
> and the new drive are both NVMe SSD) from USB Linux and then just do a 'dd'
> for the entire drive (in block level, bit-by-bit). Then I remove the old
> disk out of the system. Shouldn't it boot normally now ?

That would work, yes, but you don't expand /boot - which you really
should do.  Also, copying the entire filesystem is not only less
efficient, but involves needless writes to an SSD (where they are 
a more limited resource than on magnetic drives).

> Then I will create a new partition for the all unused space (1.5GB) on new
> disk which I then will add to the LVM as a new Physical Volume (PV) in

That is pointless when you can just expand the partition (which is
trivial when it is the last one).  You don't want more PVs 
unless they are actually physical volumes - or there is some special
circumstance that prevents just expanding the partition.

_______________________________________________
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/


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-lvm] Swapping LLVM drive
  2023-08-28 22:31   ` Phillip Susi
@ 2023-08-29 15:44     ` Stuart D Gathman
  2023-09-08 13:33       ` Phillip Susi
  0 siblings, 1 reply; 8+ messages in thread
From: Stuart D Gathman @ 2023-08-29 15:44 UTC (permalink / raw)
  To: Phillip Susi; +Cc: LVM general discussion and development

On Mon, 28 Aug 2023, Phillip Susi wrote:

> 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.

1. Unnecessary copying. 
2. You lose your free backup of the system on the old drive,
    which should be carefully labeled and kept handy for a year.
    (After that, SSDs start to run the risk of data retention issues.)

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

And that is the most important reason.  "Just reinstall grub" is a
much larger learning curve than "dd" IMO.

_______________________________________________
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/


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-lvm] Swapping LLVM drive
  2023-08-29 15:44     ` Stuart D Gathman
@ 2023-09-08 13:33       ` Phillip Susi
  0 siblings, 0 replies; 8+ messages in thread
From: Phillip Susi @ 2023-09-08 13:33 UTC (permalink / raw)
  To: Stuart D Gathman; +Cc: LVM general discussion and development


Stuart D Gathman <stuart@gathman.org> writes:

> 1. Unnecessary copying. 2. You lose your free backup of the system on
> the old drive,
>    which should be carefully labeled and kept handy for a year.
>    (After that, SSDs start to run the risk of data retention issues.)

You also have unnecessary copying with dd, but yea, partclone can save
on that.  If you want to keep the free backup with LVM, then instead of
pvmove you can lvconvert the volumes to mirrors, then split the
mirrors.  The nice thing about doing it with LVM is that it can happen
in the background while you still use the computer instead of having to
boot from removable media and wait hours and hours for the copy.

>> Don't forget you'll need to reinstall grub on the new drive for it to
>> boot.
>
> And that is the most important reason.  "Just reinstall grub" is a
> much larger learning curve than "dd" IMO.

Maybe a bit larger, but something that is always good to know and worth
learning.

_______________________________________________
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/


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-08 13:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-27 10:11 [linux-lvm] Swapping LLVM drive Roska Postit
2023-08-28 14:53 ` Stuart D Gathman
2023-08-28 16:31   ` Roska Postit
2023-08-28 17:01     ` Roska Postit
2023-08-29 15:37       ` Stuart D Gathman
2023-08-28 22:31   ` Phillip Susi
2023-08-29 15:44     ` Stuart D Gathman
2023-09-08 13:33       ` Phillip Susi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).