[sf-lug] LVM (& restoring, etc.)
Michael Paoli
Michael.Paoli at cal.berkeley.edu
Wed Mar 24 06:08:57 PDT 2010
> Date: Mon, 22 Mar 2010 08:11:37 -0800
> From: jim <jim at well.com>
> Subject: Re: [sf-lug] Partition resizing problem
>
> there are those who like LVM. i, myself, have some
> reservations about LVM, mainly to do with anxieties
> about restoring data if something happens to corrupt
> the LVM system itself.
Restoring with LVM is quite easy if you don't have / (root) filesystem
using LVM - and even if you do it's not all that horribly complex
(rescue/install CD/DVD or other boot media comes in quite handy - but
you probably need that anyway if the former hard drive turned itself
into a pile of e-waste). And of course, /boot filesystem needs to not
use LVM (at least for grub 2 - I haven't looked into grub 3 yet). I've
already done LVM restores at least twice due to hard drive failures.
Typical LVM restore scenario (onto bare hard drive):
initial non-LVM bits:
o partition
o restore /boot filesystem (or non-LVM / if one boots from that)
LVM bits:
o if / is LVM, use rescue media to create LVM /, then restore to it,
be sure to use suitable parameters for the PV(s) and VG for the above,
if one doesn't have that meta-data handy, examine it via the vg, etc.,
commands after /etc has been restored (and if one didn't create it
suitably, adjust if feasible, or repeat and do it again).
o reboot to single user mode onto restored / (one already has at that
point, from /etc, /bin and /sbin, what one needs to continue LVM
restore)
o use vgcfgrestore(8), etc. to reinitialize PV partitions for VG use
(target PVs must not be smaller than the backed up configuration ones
they're replacing) and activate VG(s)/LV(s). If / is LVM, don't
reinitialized PV(s) that it's already using.
o If there are any volumes(/filesystems) ones wants to restore as
smaller than they were when backed up, this would be the time to
shrink them (resize volume(s) as desired before creating filesystems,
etc.)
o initialize lvm volumes as appropriate (e.g. create filesystems,
reinitialize lvm swap devices, etc.)
o mount filesystems, activate any lvm swap
I didn't cover most all the stuff that's the same with or without LVM
(e.g. restore filesystem data, any md or encrypted device setup steps,
boot loader installation and configuration, etc.).
Although there's a bit of a learning curve with LVM, with LVM one does
have a much more configurable and generally manageable system - e.g.
grow filesystem on the fly - even if there's no free space immediately
following the filesystem's location on disk.
http://www.rawbw.com/~mp/linux/lvm/balug/
Here's are some example LVM setups:
# hostname
vicki
# mount | awk '/boot/;/mapper/'
/dev/mapper/vg00-root on / type ext3 (rw,errors=remount-ro)
/dev/md0 on /boot type ext3 (rw,nosuid,nodev,noatime)
/dev/mapper/vg00-home on /home type ext3 (rw,nosuid,nodev)
/dev/mapper/vg00-usr on /usr type ext3 (rw,nodev,noatime)
/dev/mapper/vg00-var on /var type reiserfs (rw,nosuid,nodev)
/dev/mapper/vg--balug-balug--var--local--balug on /var/local/balug
type reiserfs (rw,nosuid,nodev)
/dev/mapper/vg--balug-backup on /var/local/balug/backup type reiserfs
(ro,nosuid,nodev,noatime)
/dev/mapper/vg--sflug-sflug--disk--BACKUP on
/var/local/sflug/sflug-disk-BACKUP type ext3 (ro,nosuid,nodev)
# cat /proc/swaps
Filename Type Size Used
Priority
/dev/mapper/vg00-swap partition 2097144 0 -1
# df -k / /boot /home /usr /var /var/local/balug
/var/local/balug/backup /var/local/sflug/sflug-disk-BACKUP
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg00-root
1032088 287052 692608 30% /
/dev/md0 241036 57135 171457 25% /boot
/dev/mapper/vg00-home
2064208 872924 1086428 45% /home
/dev/mapper/vg00-usr 2064208 656796 1302556 34% /usr
/dev/mapper/vg00-var 4194172 3199144 995028 77% /var
/dev/mapper/vg--balug-balug--var--local--balug
204788 42376 162412 21% /var/local/balug
/dev/mapper/vg--balug-backup
19684768 9565348 10119420 49%
/var/local/balug/backup
/dev/mapper/vg--sflug-sflug--disk--BACKUP
276440 272632 0 100%
/var/local/sflug/sflug-disk-BACKUP
#
# hostname
balug-sf-lug-v2.balug.org
# mount | awk '{if(NR==1)print;};/boot/;/mapper/'
/dev/sda5 on / type ext3 (rw,errors=remount-ro)
/dev/sda1 on /boot type ext3 (ro,nosuid,nodev,noatime)
/dev/mapper/vg00-home on /home type reiserfs (rw,nosuid,nodev)
/dev/mapper/vg00-usr on /usr type reiserfs (rw,nodev,noatime)
/dev/mapper/vg00-var on /var type reiserfs (rw,nosuid,nodev)
/dev/mapper/vg01-backup on /var/local/tower type reiserfs (rw,nosuid,nodev)
# cat /proc/swaps
Filename Type Size Used
Priority
/dev/mapper/vg00-swap partition 1048568 73124 -1
# df -k / /boot /home /usr /var /var/local/tower
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda5 516040 319716 175356 65% /
/dev/sda1 241116 39309 189359 18% /boot
/dev/mapper/vg00-home
2097084 983260 1113824 47% /home
/dev/mapper/vg00-usr 2097084 564832 1532252 27% /usr
/dev/mapper/vg00-var 3145628 989848 2155780 32% /var
/dev/mapper/vg01-backup
10485436 8524236 1961200 82% /var/local/tower
#
http://www.rawbw.com/~mp/linux/lvm/balug/
More information about the sf-lug
mailing list