Step 2: the Volume Group
You don't currently have any volume groups, so create one using the two physical volumes you just made:
vgcreate my_volume_group /dev/sdb /dev/sdc
Hopefully the command is clear. You've created a volume group named
my_volume_group using the physical volumes /dev/sdb and /dev/sdc. As
with the physical volumes, if you want to check the current state
of LVM Volume Groups on your system, type
vgdisplay to get a listing:
$ sudo vgdisplay --- Volume group --- VG Name my_volume_group System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 20.8 GiB PE Size 4.00 MiB Total PE 9988 Alloc PE / Size 0 / 0 GiB Free PE / Size 9988 / 20.8 GiB VG UUID oVYiY6-bQp9-4CVO-QgrN-LGgB-1umR-ebJQo4
As you can see in the output, you've combined the available space of the two physical volumes (10.4GB each) into a total pool of 20.8GB. You could add more drives to the volume group or mix and match entire drives with partitions from other drives. LVM is very flexible. The large pool of available data does no good, however, until you create Logical Volumes to act as your usable disks.
Step 3: Logical Volumes
When you add a hard drive to your system, you don't really get to pick its name. You get /dev/sda, /dev/sdb and so on. When you create logical volumes, however, you decide what you want the devices to be called. You also get to decide how large each "drive" is as you carve it out of the larger volume group. It's good to note here that if you make your logical volumes too small, it's very easy to expand them later, so don't worry too much about planning for long-term potential needs. If you need more space later, you can just add it. To create your logical volumes, type:
$ sudo lvcreate -L 5G -n 5gig my_volume_group Logical volume "5gig" created
Then to see what happened behind the scenes, type:
$ sudo lvdisplay --- Logical volume --- LV Path /dev/my_volume_group/5gig LV Name 5gig VG Name my_volume_group LV UUID 3MxOB0-ce5o-yvBD-YORT-52qV-j8HJ-oDru2G LV Write Access read/write LV Status available # open 0 LV Size 5.0 GiB Current LE 5753 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:0
Notice how nice and clean the device-naming system is with LVM. It's
important to run the
lvdisplay command, however, to make sure you know
the mapped device name. Many systems use symbolic linking in an attempt
to make the device's virtual locations easier to find, but I think that
adds a layer of confusion for folks trying to understand what's really
Look, a New (Virtual) Hard Drive!
Once you've successfully created your logical volumes, it's just a matter of using them as block devices. If you need a filesystem to mount as your /home directory, just do this:
$ sudo mkfs.ext4 /dev/my_volume_group/5gig $ sudo mount -t ext4 /dev/my_volume_group/5gig /home
And, your /home directory will be a whopping 5GB in size, but fully expandable, thanks to LVM. (Obviously, if you really want to mount your logical volume as your home directory, you should add an entry to /etc/fstab so it mounts on boot.) From the standpoint of your Linux system, however, /dev/my_volume/5gig is a block device similar to any hard drive you might plug in. You can use it as swap, format it like you did above, or even encrypt it and mount it somewhere as an encrypted partition.
That Was a Lot of Work, Why Again?
I know, in this little example, you've done nothing but create a JBOD (Just a Bunch Of Disks) type system, which will completely fail if you lose even one drive. The power of LVM isn't fully realized until down the road when you want to expand your logical volumes without migrating data. Or, when you want to take an LVM snapshot of your drive so you can roll back to an instantaneous backup when an upgrade fails. Or, when you replace a small drive with a fast RAID array and want to migrate the data quietly to your new PV.
The Logical Volume Manager is a system that abstracts storage devices. It does add a layer of complexity to your system, I won't lie, but the trade-off is significant. It may complicate your system a bit more, but it also simplifies your work a great deal when you have to deal with storage in the future.
You Keep Talking about the Future...
Hopefully at this point, you see LVM isn't a complete waste of time. When the time comes, what sorts of advantages will LVM provide? Here's a quick off-the-top-of-my-head list you might want to check out:
Move Logical Volumes from old, slow PVs to new, fast PVs, on the fly.
Resize Logical Volumes, filling more space in the Volume Group.
Stripe data across PVs in a VG for increased performance.
Resize Volume Groups by adding or subtracting physical volumes.
Take a snapshot of any Logical Volume, which can be restored later.
One of my favorite uses for LVM in production is to take an LVM snapshot before an upgrade. If something goes wrong, I can just revert back to the snapshot. Once you start thinking about all the possibilities LVM offers, you'll wonder why you waited so long!
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!
- SUSE LLC's SUSE Manager
- My +1 Sword of Productivity
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Managing Linux Using Puppet
- Non-Linux FOSS: Caffeine!
- Doing for User Space What We Did for Kernel Space
- SuperTuxKart 0.9.2 Released
- Google's SwiftShader Released
- SourceClear Open
- 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