Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Technical

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 18th September 2009, 07:57
ACiD GRiM ACiD GRiM is offline
Junior Member
Join Date: Mar 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Draft data loss mitigation method for spanned LVM (would like suggestions)

I have an LVM volume that is made up of two 500GB HDDs because I like the ability to add to a volume as it expands. Unfortunately, since there is zero redundancy if a drive fails catastrophic data loss will occur. This stems from the fact that the LVM and LUKS metadata are stored on the original drive in the volume group, and that FS Journals such as ext4 move around as space is used. After having some questions answered on reddit.com/r/linux and some googling, I've drafted a dataloss resistant mitigation method for LVM/ext4 (and LUKS).

You'll need at least 4 seperate storage block devices. I'm using a 256MB SD (lvmsd), a 4GB SD (jrnlsd), and two 500GB HDDs (sda & sdb).

First create your Physical Volumes:
#pvcreate /dev/lvmsd1
#pvcreate /dev/sda1
#pvcreate /dev/sda2
Then create your volume group:

#vgcreate array /dev/lvmsd1 -s 4M
#vgextend array /dev/sda1
#vgextend array /dev/sdb1
#lvcreate array /dev/lvmsd1 -l 100%FREE -n storage
#lvextend /dev/array/storage /dev/sda1 -l 100%FREE
#lvextend /dev/array/storage /dev/sdb1 -l 100%FREE
(Optional) Create a LUKS volume on top of LVM

#vgchange -ay array
#cryptsetup  --verify-passphrase --key-size 256 luksFormat /dev/array/storage
#cryptsetup luksOpen /dev/array/storage luks-storage
\\If you do create a LUKS volume, use /dev/mapper/luks-storage instead of /dev/array/storage for the remaining steps

Next, create an external journal, and filesystem

#vgchange -ay array
#mkfs.ext4 -O journal_dev /dev/jrnlsd1
#ls -l /dev/disk/by-uuid/
\\Find the symbolic link that points to your external journal device
#mkfs.ext4 /dev/array/storage -L storage -J device=UUID=h3xuu1dt-0y0u-rd3v1c3
Finally, close everything and backup your lvmsd

(Optional)#cryptsetup luksClose luks-storage
#vgchange -an array
dd if=/dev/lvmsd of=/root/lvmsd.bak bs=512
\\You should do this every time you change the volume group

I don't make any guarantees to the reliability to this method, and as I said, it's only a draft method and still doesn't replace regular back ups (you do that right?)

The advantage of this method, is that if one of the secondary physical drives fail, the journal is external, so you can mount the volume read-only and backup what you need (Possibly still use the volume until the failed drive is recovered, but I wouldn't recommend it). It also protects against the metadata being lost or corrupted, because you should have a regular backup of the primary physical drive (and maybe even the journal drive) and can quickly make a clone and drop in a replacement.

I still have some questions that would make this method more effective:

What is a decent size for a journal drive? What would be a safe minimum for say a 4TB ext4 volume?

What would be the best way to set ext4 to not store anything in the first 256MB? I know the reserved file space can be changed from 5%, but is that 5% of the originally created file system, or does it increase if the filesystem is extended?

If the first 256MB can be blocked off, what negative effects would be a problem during normal use if the "lock" switch on the SD was turned on? I can tell that the lock would have to be disabled to add LVM PVs, but other than that, what would need to write to it?
Reply With Quote
Sponsored Links


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to recover deleted data from LVM on top of RAID 5 SoftDux Technical 0 7th February 2008 13:53
Help with Bluetooth PAND josto HOWTO-Related Questions 1 7th August 2007 20:53
On: Recover Data From RAID1 LVM Partitions With Knoppix Linux LiveCD saracen HOWTO-Related Questions 1 11th May 2007 09:57

All times are GMT +2. The time now is 00:09.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.