I have a Debian Wheezy
system with a couple of 500 GB HDDs in RAID-1 (mdadm
mirror), on top of which sits LVM
logical volumes with 5 partitions (boot
, root
, usr
, var
and tmp
), total size of 47.15 GiB. 418.38 GiB in the physical volume are free. GRUB
installed on both drives.
One of HDDs failed and now array is degraded, but data is intact.
What I want is to swap all of these 2 HDDs to 80 GB SSDs without the need to reinstall the system from scratch. The subtle point here is that I need to shrink LVM physical volume to match SSD's size, but logical volumes are not contiguous (there is a lot of a free space in the beginning), so I have to somehow move logical volumes within a physical one. And there is no lvmove
command in Debian.
How do I achieve this?
Some console output:
Versions:
root@wheezy:~# uname -a && mdadm --version && lvm version
Linux wheezy 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u1 x86_64 GNU/Linux
mdadm - v3.2.5 - 18th May 2012
LVM version: 2.02.95(2) (2012-03-06)
Library version: 1.02.74 (2012-03-06)
Driver version: 4.22.0
Array details:
root@wheezy:~# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Thu Dec 4 12:20:22 2014
Raid Level : raid1
Array Size : 488148544 (465.53 GiB 499.86 GB)
Used Dev Size : 488148544 (465.53 GiB 499.86 GB)
Raid Devices : 2
Total Devices : 1
Persistence : Superblock is persistent
Update Time : Thu Dec 4 13:08:59 2014
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0
Name : wheezy:0 (local to host wheezy)
UUID : 44ea4079:b3b837d3:b9bb2ca1:1b95272a
Events : 26
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 0 0 1 removed
LVM brief details:
root@wheezy:~# pvs && vgs && lvs
PV VG Fmt Attr PSize PFree
/dev/md0 system lvm2 a-- 465.53g 418.38g
VG #PV #LV #SN Attr VSize VFree
system 1 5 0 wz--n- 465.53g 418.38g
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
boot system -wi----- 152.00m
root system -wi----- 2.00g
tmp system -wi----- 10.00g
usr system -wi----- 20.00g
var system -wi----- 15.00g
Segmentation of the PV:
root@wheezy:~# pvs -v --segments /dev/md0
Using physical volume(s) on command line
PV VG Fmt Attr PSize PFree Start SSize LV Start Type PE Ranges
/dev/md0 system lvm2 a-- 465.53g 418.38g 0 89600 0 free
/dev/md0 system lvm2 a-- 465.53g 418.38g 89600 38 boot 0 linear /dev/md0:89600-89637
/dev/md0 system lvm2 a-- 465.53g 418.38g 89638 512 root 0 linear /dev/md0:89638-90149
/dev/md0 system lvm2 a-- 465.53g 418.38g 90150 5120 usr 0 linear /dev/md0:90150-95269
/dev/md0 system lvm2 a-- 465.53g 418.38g 95270 3840 var 0 linear /dev/md0:95270-99109
/dev/md0 system lvm2 a-- 465.53g 418.38g 99110 1280 0 free
/dev/md0 system lvm2 a-- 465.53g 418.38g 100390 2560 tmp 0 linear /dev/md0:100390-102949
/dev/md0 system lvm2 a-- 465.53g 418.38g 102950 16226 0 free
rsync
your files over. It's not online but likely to be faster than anything else.