* [linux-lvm] Replace small drive with bigger, using LVM?
@ 2014-09-10 9:02 Craig
2014-09-10 9:36 ` James Hawtin
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Craig @ 2014-09-10 9:02 UTC (permalink / raw)
To: linux-lvm
I have a workstation that can only take 2 hard drives.
The one that's in there is a 500GB drive and I'd like to bring a new 4TB
drive in and use LVMto migrate a live running system over to the new
drive, remove the old one from the setup, reboot and bing, have the
large drive running,without having to re-install my OS and set up
everything afresh.
It's an Ubuntu 14.04.1 install where I ticked the "Use LVM" tick box
# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0005d771
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 976771071 488134657 5 Extended
/dev/sda5 501760 976771071 488134656 8e Linux LVM
Disk /dev/sdb: 4000.8 GB, 4000787030016 bytes
255 heads, 63 sectors/track, 486401 cylinders, total 7814037168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xc73f6184
Device Boot Start End Blocks Id System
/dev/sdb1 2048 499711 248832 83 Linux
/dev/sdb2 499712 4294967294 2147233791+ 5 Extended
/dev/sdb5 501760 4294967294 2147232767+ 8e Linux LVM
Disk /dev/mapper/ubuntu--vg-root: 493.4 GB, 493363396608 bytes
255 heads, 63 sectors/track, 59981 cylinders, total 963600384 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/ubuntu--vg-root doesn't contain a valid partition table
Disk /dev/mapper/ubuntu--vg-swap_1: 6438 MB, 6438256640 bytes
255 heads, 63 sectors/track, 782 cylinders, total 12574720 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/ubuntu--vg-swap_1 doesn't contain a valid partition table
So /dev/sda is the original install disk and /dev/sdb in my shiny new WD
Black 4TB drive.
# vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 465.52 GiB
PE Size 4.00 MiB
Total PE 119173
Alloc PE / Size 119162 / 465.48 GiB
Free PE / Size 11 / 44.00 MiB
VG UUID tFSX8N-c3zG-j9BW-yqx2-Or63-AXMg-Sho5tD
root@home:~# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/root
LV Name root
VG Name ubuntu-vg
LV UUID rqvzFC-b1I2-sLRm-oq6w-fTEP-UGSe-7E7fwz
LV Write Access read/write
LV Creation host, time ubuntu, 2014-08-15 14:24:31 +0100
LV Status available
# open 1
LV Size 459.48 GiB
Current LE 117627
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
--- Logical volume ---
LV Path /dev/ubuntu-vg/swap_1
LV Name swap_1
VG Name ubuntu-vg
LV UUID y9fXgx-ceMm-lss0-ZZi8-d2us-KdGT-ipUQQ4
LV Write Access read/write
LV Creation host, time ubuntu, 2014-08-15 14:24:31 +0100
LV Status available
# open 2
LV Size 6.00 GiB
Current LE 1535
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [linux-lvm] Replace small drive with bigger, using LVM?
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
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: James Hawtin @ 2014-09-10 9:36 UTC (permalink / raw)
To: LVM general discussion and development
Ok this is such an easy bread and butter task, but its really easy to
get wrong so be careful! You have 7 tasks here, you will notice not all
your OS is on lvm a small part /boot is on its own partition and you
need to copy that as well to get you os to boot.
I am assuming here your second disk is called sdb.
Task 1) fdisk
fdisk /dev/sdb
c
p
1
2048
499711
a
1
c
p
2
<return>
<return>
t
8e
Task 2) Copying /boot
mkfs.ext3 /dev/sdb1
mkdir /boot2
mount /dev/sdb1 /boot2
cd /boot
tar -cPpSslf - . | ( cd /boot2 ; tar -xvPpSslf -)
umount /boot2
change /etc/fstab to us /dev/sda1 for how to reference /boot
Task 3) moving lvm... easy!
pvcreate /dev/sdb2
vgextend ubuntu-vg /dev/sdb2
swapoff -a
pvmove /dev/sda5 /dev/sdb2
vgreduce ubuntu-vg /dev/sda5
And now the tricky bit!
task4) Install grub on your new drive
Hopefully this is right... if not your need task 6.
grub-setup /dev/sdb
task5) Turn off your computer.
swap sda and sdb
and boot from your new drive.
check /boot is comming from the right device (/dev/sda1), if not unmount
and mount it, then install a new kernel. This is the easiest way to get
it to build a new initrd.
Shut down your computer remove /dev/sdb (old disk)
and you should be able to boot from just your new drive... SIMPLEZ!
Task 6) If you computer does no boot.
boot the ubuntu install disk and use rescue to install the grub boot
block and verify /boot is mounted and populated with data. If not ... fix.
Task 7) I have no new space. Yes you do use pvs its just unallocated,
use either lvextend or lvcreate to extend or create a new logical
volume, if you extend you will then need to use resize2fs for make he
filesystem bigger, personally I would create a new mount point and not
use / for everything.
James
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [linux-lvm] Replace small drive with bigger, using LVM?
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 10:13 ` Jarkko Oranen
2014-09-11 10:54 ` Andreas Nastke
3 siblings, 1 reply; 8+ messages in thread
From: Joe Thornber @ 2014-09-10 9:39 UTC (permalink / raw)
To: LVM general discussion and development
On Wed, Sep 10, 2014 at 10:02:04AM +0100, Craig wrote:
> 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
Use pvmove to move everything across to the new disk.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [linux-lvm] Replace small drive with bigger, using LVM?
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 10:13 ` Jarkko Oranen
2014-09-11 10:54 ` Andreas Nastke
3 siblings, 0 replies; 8+ messages in thread
From: Jarkko Oranen @ 2014-09-10 10:13 UTC (permalink / raw)
To: LVM general discussion and development
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [linux-lvm] Replace small drive with bigger, using LVM?
2014-09-10 9:39 ` Joe Thornber
@ 2014-09-10 12:35 ` Fran Garcia
2014-09-10 13:03 ` James Hawtin
0 siblings, 1 reply; 8+ messages in thread
From: Fran Garcia @ 2014-09-10 12:35 UTC (permalink / raw)
To: LVM general discussion and development
On Wed, Sep 10, 2014 at 11:39 AM, Joe Thornber <thornber@redhat> wrote:
> On Wed, Sep 10, 2014 at 10:02:04AM +0100, Craig wrote:
>> 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
>
> Use pvmove to move everything across to the new disk.
Also note you should be using parted rather than fdisk for sdb.
You'll need to enable GPT support to partition anything larger than
2Tb.
HTH
Fran
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [linux-lvm] Replace small drive with bigger, using LVM?
2014-09-10 12:35 ` Fran Garcia
@ 2014-09-10 13:03 ` James Hawtin
2014-09-10 13:34 ` Michael D. Setzer II
0 siblings, 1 reply; 8+ messages in thread
From: James Hawtin @ 2014-09-10 13:03 UTC (permalink / raw)
To: LVM general discussion and development
On 10/09/14 13:35, Fran Garcia wrote:
>
> Also note you should be using parted rather than fdisk for sdb.
> You'll need to enable GPT support to partition anything larger than
> 2Tb.
>
>
Very good point.
James
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [linux-lvm] Replace small drive with bigger, using LVM?
2014-09-10 13:03 ` James Hawtin
@ 2014-09-10 13:34 ` Michael D. Setzer II
0 siblings, 0 replies; 8+ messages in thread
From: Michael D. Setzer II @ 2014-09-10 13:34 UTC (permalink / raw)
To: James Hawtin, LVM general discussion and development
On 10 Sep 2014 at 14:03, James Hawtin wrote:
Date sent: Wed, 10 Sep 2014 14:03:00 +0100
From: James Hawtin <oolon@ankh.org>
To: LVM general discussion and development
<linux-lvm@redhat.com>
Subject: Re: [linux-lvm] Replace small drive with bigger, using
LVM?
Send reply to: LVM general discussion and development
<linux-lvm@redhat.com>
<mailto:linux-lvm-request@redhat.com?subject=unsubscribe>
<mailto:linux-lvm-request@redhat.com?subject=subscribe>
> On 10/09/14 13:35, Fran Garcia wrote:
> >
> > Also note you should be using parted rather than fdisk for sdb.
> > You'll need to enable GPT support to partition anything larger than
> > 2Tb.
> >
> >
> Very good point.
>
> James
Another issue that you may run into is that the grub boot menu uses the uuid
of the disk for mount instead of the older /dev/sda format, so you may have
to manually reset the grub.cfg or menu.lst depending on your setup.
In the past I have done clones of the smaller disk to larger, and then just
created new partition for the extra space. A bit level copy will also set the
uuid the same as the original disk. So, look at your current boot config file,
and see if it has uuid options.
>
> _______________________________________________
> linux-lvm mailing list
> linux-lvm@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-lvm
> read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
+----------------------------------------------------------+
Michael D. Setzer II - Computer Science Instructor
Guam Community College Computer Center
mailto:mikes@kuentos.guam.net
mailto:msetzerii@gmail.com
http://www.guam.net/home/mikes
Guam - Where America's Day Begins
G4L Disk Imaging Project maintainer
http://sourceforge.net/projects/g4l/
+----------------------------------------------------------+
http://setiathome.berkeley.edu (Original)
Number of Seti Units Returned: 19,471
Processing time: 32 years, 290 days, 12 hours, 58 minutes
(Total Hours: 287,489)
BOINC@HOME CREDITS
ROSETTA 19531221.297211 | SETI 32889183.808174
ABC 16613838.513356 | EINSTEIN 32404680.703230
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [linux-lvm] Replace small drive with bigger, using LVM?
2014-09-10 9:02 [linux-lvm] Replace small drive with bigger, using LVM? Craig
` (2 preceding siblings ...)
2014-09-10 10:13 ` Jarkko Oranen
@ 2014-09-11 10:54 ` Andreas Nastke
3 siblings, 0 replies; 8+ messages in thread
From: Andreas Nastke @ 2014-09-11 10:54 UTC (permalink / raw)
To: LVM general discussion and development
are you sure you want to work with a 4TB storage without any kind of
redundancy?
Craig schrieb:
> I have a workstation that can only take 2 hard drives.
> The one that's in there is a 500GB drive and I'd like to bring a new 4TB
> drive in and use LVMto migrate a live running system over to the new
> drive, remove the old one from the setup, reboot and bing, have the
> large drive running,without having to re-install my OS and set up
> everything afresh.
> It's an Ubuntu 14.04.1 install where I ticked the "Use LVM" tick box
>
> # fdisk -l
>
> Disk /dev/sda: 500.1 GB, 500107862016 bytes
> 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
> Units = sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0x0005d771
>
> Device Boot Start End Blocks Id System
> /dev/sda1 * 2048 499711 248832 83 Linux
> /dev/sda2 501758 976771071 488134657 5 Extended
> /dev/sda5 501760 976771071 488134656 8e Linux LVM
>
> Disk /dev/sdb: 4000.8 GB, 4000787030016 bytes
> 255 heads, 63 sectors/track, 486401 cylinders, total 7814037168 sectors
> Units = sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 4096 bytes
> I/O size (minimum/optimal): 4096 bytes / 4096 bytes
> Disk identifier: 0xc73f6184
>
> Device Boot Start End Blocks Id System
> /dev/sdb1 2048 499711 248832 83 Linux
> /dev/sdb2 499712 4294967294 2147233791+ 5 Extended
> /dev/sdb5 501760 4294967294 2147232767+ 8e Linux LVM
>
> Disk /dev/mapper/ubuntu--vg-root: 493.4 GB, 493363396608 bytes
> 255 heads, 63 sectors/track, 59981 cylinders, total 963600384 sectors
> Units = sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0x00000000
>
> Disk /dev/mapper/ubuntu--vg-root doesn't contain a valid partition table
>
> Disk /dev/mapper/ubuntu--vg-swap_1: 6438 MB, 6438256640 bytes
> 255 heads, 63 sectors/track, 782 cylinders, total 12574720 sectors
> Units = sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0x00000000
>
> Disk /dev/mapper/ubuntu--vg-swap_1 doesn't contain a valid partition table
>
> So /dev/sda is the original install disk and /dev/sdb in my shiny new WD
> Black 4TB drive.
>
> # vgdisplay
> --- Volume group ---
> VG Name ubuntu-vg
> System ID
> Format lvm2
> Metadata Areas 1
> Metadata Sequence No 7
> VG Access read/write
> VG Status resizable
> MAX LV 0
> Cur LV 2
> Open LV 2
> Max PV 0
> Cur PV 1
> Act PV 1
> VG Size 465.52 GiB
> PE Size 4.00 MiB
> Total PE 119173
> Alloc PE / Size 119162 / 465.48 GiB
> Free PE / Size 11 / 44.00 MiB
> VG UUID tFSX8N-c3zG-j9BW-yqx2-Or63-AXMg-Sho5tD
>
> root@home:~# lvdisplay
> --- Logical volume ---
> LV Path /dev/ubuntu-vg/root
> LV Name root
> VG Name ubuntu-vg
> LV UUID rqvzFC-b1I2-sLRm-oq6w-fTEP-UGSe-7E7fwz
> LV Write Access read/write
> LV Creation host, time ubuntu, 2014-08-15 14:24:31 +0100
> LV Status available
> # open 1
> LV Size 459.48 GiB
> Current LE 117627
> Segments 2
> Allocation inherit
> Read ahead sectors auto
> - currently set to 256
> Block device 252:0
>
> --- Logical volume ---
> LV Path /dev/ubuntu-vg/swap_1
> LV Name swap_1
> VG Name ubuntu-vg
> LV UUID y9fXgx-ceMm-lss0-ZZi8-d2us-KdGT-ipUQQ4
> LV Write Access read/write
> LV Creation host, time ubuntu, 2014-08-15 14:24:31 +0100
> LV Status available
> # open 2
> LV Size 6.00 GiB
> Current LE 1535
> Segments 1
> Allocation inherit
> Read ahead sectors auto
> - currently set to 256
> Block device 252:1
>
>
> 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
>
> _______________________________________________
> linux-lvm mailing list
> linux-lvm@redhat.com
> https://www.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:[~2014-09-11 10:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2014-09-11 10:54 ` Andreas Nastke
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.