Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using Kubuntu 11.10 and before I upgrade to 12.04, I want to make snapshots of my filesystems. Coming to think of that, I realized that it can be very useful to create snapshots of logical volumes during boot before they are mounted. At that moment, the volume/filesystem should be clean and is perfect to be used for an image backup.

How can I create LV snapshots of my filesystems during boot, before the filesystems are being mounted by the kernel? I think this should be done in initrd, but unsure how.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Part of the purpose of LVM snapshots is that you can create them on the fly; there is no need to do it at boot time. LVM takes care to make sure the filesystem is in a consistent state when it creates the snapshot. One of, if not the most common use of LVM snapshots is to get a stable fs image you can make a backup of without having to shutdown the server.

share|improve this answer
    
Do you have a references stating LVM2 being sufficiently aware of the filesystem to always create snapshots with a consistent filesystem? –  jippie Apr 30 '12 at 15:39
    
This facility does require that the snapshot be made at a time when the data on the logical volume is in a consistent state - the VFS-lock patch for LVM1 makes sure that some filesystems do this automatically when a snapshot is created, and many of the filesystems in the 2.6 kernel do this automatically when a snapshot is created without patching. tldp.org/HOWTO/LVM-HOWTO/snapshotintro.html - But for a consisten file backup, applications must write their buffers to disk or be closed. –  jippie Apr 30 '12 at 15:49
    
@jippie, properly behaved applications are designed to recover from a system crash or power failure, which is what it looks like when you take a snapshot on the fly, back it up, and restore it later. Things like database servers and even web browser history work properly when this happens. There may be some poorly behaved applications that can not recover properly from a power failure, so yes, you will want to shut those down before taking the snapshot. –  psusi Apr 30 '12 at 18:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.