LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-18-2009, 12:50 AM   #1
ACiD GRiM
LQ Newbie
 
Registered: Mar 2009
Posts: 17

Rep: Reputation: 0
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:
Code:
#pvcreate /dev/lvmsd1
#pvcreate /dev/sda1
#pvcreate /dev/sda2
Then create your volume group:

Code:
#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

Code:
#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

Code:
#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

Code:
(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?
 
Old 10-18-2009, 03:17 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by ACiD GRiM View Post
What is a decent size for a journal drive? What would be a safe minimum for say a 4TB ext4 volume?
I don't know how it's different for ext4 but for ext3 the journal sizes I've seen range from 4 to 128Mb. One post suggest that on a filesystem with 4k blocks (default IIRC) a journal maxes out at 400Mb and that this value would be good for terabyte-size storage with a lot of active processes. I haven't been able to find this in the available documentation, maybe you can (or check the linux-ext4 mailing list?). Journal size isn't only about performance: one thread on that mailing list shows that online resizing a ext3 filesystem failed due to the journal size being way too small.


Quote:
Originally Posted by ACiD GRiM View Post
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?
AFAIK there is no way you can dictate "reserved file space" allocation (or translate it to "don't write there") in that precise way by means of kernel sysctl or tune2fs option. At least not that I know of in ext3.
 
  


Reply

Tags
ext4, luks, lvm



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recovering data from WDMyBook 1 of 2 spanned HDDs using SystemRescueCD johnxcitizen Linux - Software 5 08-28-2009 02:48 AM
LVM Reducing LVs Without Data Loss centos82 Linux - Newbie 3 10-04-2008 01:58 AM
Reduce LVM Partition size without any data loss viral_Ahire Linux - Software 1 04-11-2008 03:42 PM
Need to mount LVM volume and save Data -- Recovering from power loss. chuckcom Linux - General 1 02-09-2008 07:57 PM
LVM - possible data loss zdenisl Linux - Software 0 05-11-2006 06:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration