linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Jarkko Oranen <oranenj@iki.fi>
To: LVM general discussion and development <linux-lvm@redhat.com>
Subject: Re: [linux-lvm] Replace small drive with bigger, using LVM?
Date: Wed, 10 Sep 2014 13:13:47 +0300	[thread overview]
Message-ID: <1410344027.13625.51.camel@kurenai.local> (raw)
In-Reply-To: <5410138C.9010603@cemery.org.uk>

On Wed, 2014-09-10 at 10:02 +0100, Craig wrote:

<cut out a bunch of stuff>

> So I've got /boot in a primary partition and then swap and / come via 
> LVM in the extended.
> 
> So I'd love to do something like
> * dd /dev/sda1 to /dev/sdb1 or something like that and have my /boot 
> volume set up
> * install grub into the MBR of /dev/sdb
> 
> The if I can make the right LVM setup, get / from my live system copied 
> to the new drive, remove the old drive lv from the vg and then 
> physically swap the HDDs round.
> 
> Can someone help me with the finer details of this or isn't it doable?
> TIA
> -C

It's very much doable, but as always, the standard disclaimer applies:
back up your data etc.

As it is now, you might just as well move /boot to reside on an LV as
well; a recent enough GRUB2 (meaning: not ancient) will support booting
from it just fine. This way, you won't even need to partition your new
disk. Of course, you're free to use an actual boot partition if you
want.

to move a VG from one PV to another, you can do the following

Assuming source PV is sda2 and new disk is sdb and you don't partition
it:

pvcreate /dev/sdb

vgextend volume_group /dev/sdb

pvmove volume_group /dev/sda2 /dev/sdb

vgreduce volume_group /dev/sda2 # this removes the old PV from the VG.
it will only succeed if the PV is not actually in use, so it's safe.

GRUB2 supports being installed in the MBR of a disk that's an LVM2 PV.

You can keep your old disk with its boot partition and bootloader
installed until you've successfully booted off the new disk, so there's
little danger that you'd actually render your system completely
unbootable.

Remember to update fstab etc. to reflect the new boot partition as well.

I've been told that moving data off the VG with the root volume in it on
a running system may result in a deadlock due to the way the LV device
is temporarily suspended during copies, leading to trouble if the copy
operation requires a read from the LV. However, I've done it several
times with no issues. Still, using a live USB or CD is recommended. If
it does deadlock, you should just be able to reset and continue the
pvmove where it left off... it's quite resilient and won't lose your
data very easily.


--
Jarkko

  parent reply	other threads:[~2014-09-10 10:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10  9:02 [linux-lvm] Replace small drive with bigger, using LVM? Craig
2014-09-10  9:36 ` James Hawtin
2014-09-10  9:39 ` Joe Thornber
2014-09-10 12:35   ` Fran Garcia
2014-09-10 13:03     ` James Hawtin
2014-09-10 13:34       ` Michael D. Setzer II
2014-09-10 10:13 ` Jarkko Oranen [this message]
2014-09-11 10:54 ` Andreas Nastke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1410344027.13625.51.camel@kurenai.local \
    --to=oranenj@iki.fi \
    --cc=linux-lvm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).