Archiving Data with Snapshots in LVM2
In some cases, it is advised to ensure that enough storage space is allocated for the snapshot or (as discussed below) a backup directory that will contain all of the archived snapshot data for restoring purposes. To extend an existing volume group, a new PV needs to be labeled. To do so, identify the physical storage device, and using fdisk, sfdisk or parted, create the desired partition size. Verify the partition by reading back the partition table. Then, continue to create the PV:
$ sudo sfdisk -l /dev/sde Disk /dev/sde: 261 cylinders, 255 heads, 63 sectors/track Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/sde1 0+ 260 261- 2096451 83 Linux /dev/sde2 0 - 0 0 0 Empty /dev/sde3 0 - 0 0 0 Empty /dev/sde4 0 - 0 0 0 Empty $ sudo pvcreate /dev/sde1 Physical volume "/dev/sde1" successfully created
Append a newly labeled PV to an existing VG with the vgextend command:
$ sudo vgextend VolGroup /dev/sde1 Volume group "VolGroup" successfully extended
If at some point the PV needs to be removed from a VG, use the vgreduce command followed by the names of the VG and the PV:
$ sudo vgreduce VolGroup /dev/sde1
If the VG is being extended for the purpose of creating a backups directory to archive routine snapshots, following the normal lvcreate procedure, define the name, size and VG for the desired LV. Then, format the LV with a filesystem, and for file I/O accessibility, mount it to a directory path:
$ sudo lvcreate --name backups --size 1G VolGroup Logical volume "backups" created $ sudo mke2fs -j /dev/VolGroup/backups $ sudo mkdir -p /mnt/VolGroup/backups $ sudo mount /dev/VolGroup/backups /mnt/VolGroup/backups
When the snapshot has been created, an archive can be made with the tar command, located in the newly created backups directory:
$ sudo tar -pczf /mnt/VolGroup/backups/rootsnapshot.tar.gz ↪/mnt/VolGroup/rootsnapshot
In an event of failure or if older revisions of files need to be retrieved, the archived snapshot can be used to restore the original data contents. This is an extremely ideal backup strategy when running a high-availability production environment. No downtime is required. Although this backup does not necessarily need to be written to a file, using the tar or dd commands, the snapshot can be written directly to another physical storage device, including a tape drive:
$ sudo tar -cf /dev/st0 /mnt/VolGroup/rootsnapshot
LVM2 comes prepackaged with some of the more common Linux-based distributions. In some cases, it even is used as part of the default filesystem layout. Its snapshot feature is one of those lesser-known treasures that really can be used to one's advantage, ranging from personal to larger-scale environments. All it takes is a little time, a little knowledge and a plan on design, deployment and configuration.
dmsetup(8) is a low-level tool used to manage logical devices that use the device-mapper driver. The LVM2 user-space toolset relies heavily on the device-mapper kernel module and support library.
LVM HOWTO: tldp.org/HOWTO/LVM-HOWTO/snapshotintro.html
Logical Volume Manager (Wikipedia): en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)
Snapshot (Wikipedia): en.wikipedia.org/wiki/Snapshot_(computer_storage)
LVM2 Project Page: sourceware.org/lvm2
LVM2 Wiki: sources.redhat.com/lvm2/wiki
Known lvremove Bug (original no.): https://bugzilla.redhat.com/show_bug.cgi?id=577798
Known lvremove Bug for RHEL 6: https://bugzilla.redhat.com/show_bug.cgi?id=638711
Petros Koutoupis is a full-time Linux kernel, device driver and application developer for embedded and server platforms. He has been working in the data storage industry for more than six years and enjoys discussing the same technologies.
Petros Koutoupis is currently a senior software developer at Cleversafe, an IBM Company. He is also the creator and maintainer of the RapidDisk Project. Petros has worked in the data storage industry for more than a decade.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- Google's SwiftShader Released
- SUSE LLC's SUSE Manager
- My +1 Sword of Productivity
- Interview with Patrick Volkerding
- Managing Linux Using Puppet
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Non-Linux FOSS: Caffeine!
- SuperTuxKart 0.9.2 Released
- Tech Tip: Really Simple HTTP Server with Python
- Parsing an RSS News Feed with a Bash Script
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide