LVM: Logical Volume Manager

Summary

LVM was working fine, handling one big drive, video cyberspace. It's not currently used.

Software and guides

Installation history

Looking ahead to 2.6

I'm starting to get my video drives in order, and there may come a point where I'd like to use a LVM again. Here's the scoop on the changes for 2.6:

In 2.6.x there is just support for Device Mapper. From "Multi-device
support (RAID and LVM)" you can see:

  x x        <M>   Device mapper support
  x x        [*]     ioctl interface version 4

Both LVM2 and EVMS (from version 2.0.0) use Device Mapper. For LVM2 you just need to get updated userspace tools from your distro or http://www.sistina.com. For EVMS to work, see:
http://evms.sourceforge.net/install-2.0.html

September troubles

In late September 2002, I issued

hdparm -Y /dev/hdd (the IBM DeskStar drive)

and got a severe hang. I had to do a soft reset and the LVM volume was corrupt on boot.

Get information on the Logical Volume Manager setup.

vgdisplay -v

RAID information?

cat /proc/mdstat

Recovering a Lost Partition Table: http://www.oz.net/~trav/linux/lost_partition.html

Everyone should have a copy of their partition table data ahead of time. This is easy in Linux. Just type "fdisk -l" and it'll spit out a list of your partitions. What you really need to know is the starting and ending cylinder numbers for each partition, along with the partition type/ID.

I tried fdisk -l -- note that it took a while:

cyberspace:/mnt # fdisk -l

Disk /dev/hdd: 15 heads, 63 sectors, 255296 cylinders
Units = cylinders of 945 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hdd1 1 255296 120627328+ 83 Linux

So we see the DeskStar is fine -- the initial occasion for the problem has never misbehaved.

Disk /dev/hda: 255 heads, 63 sectors, 1240 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 2 16033+ 83 Linux
/dev/hda2 3 66 514080 82 Linux swap
/dev/hda3 67 1240 9430155 83 Linux

The main drive is also fine -- this is where the operating system is, and what I'm using now. A treat, really, to be able to worry about a problem disk with the full power of the operating system.

Disk /dev/hdb: 255 heads, 63 sectors, 14946 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 1 14947 120060832+ 8e Linux LVM
Partition 1 does not end on cylinder boundary:
phys=(1023, 15, 63) should be (1023, 254, 63)

Here's the problem -- the disk device has been correctly identified as having 14946 cylinders, 255 heads, and 63 sectors. But the file system partition "does not end on a cylinder boundary". It doesn't look like corrupt data.

Here's the harddrive output from dmesg:

Uniform Multi-Platform E-IDE driver Revision: 6.31
ide: Assuming 33MHz system bus speed for PIO modes; override with
idebus=xx
PIIX4: IDE controller on PCI bus 00 dev 39
PIIX4: chipset revision 1
PIIX4: not 100% native mode: will probe irqs later
ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:DMA, hdb:DMA
ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:DMA, hdd:DMA
hda: QUANTUM FIREBALLP LM10.2, ATA DISK drive
hdb: Maxtor 4G120J6, ATA DISK drive
hdc: TOSHIBA DVD-ROM SD-M1212, ATAPI CD/DVD-ROM drive
hdd: IC35L120AVVA07-0, ATA DISK drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
blk: queue c02fa8a0, I/O limit 4095Mb (mask 0xffffffff)
hda: 19925880 sectors (10202 MB) w/1900KiB Cache, CHS=1240/255/63, UDMA(33)
blk: queue c02fa9c8, I/O limit 4095Mb (mask 0xffffffff)
hdb: 240121728 sectors (122942 MB) w/2048KiB Cache, CHS=14946/255/63, UDMA(33)
blk: queue c02face4, I/O limit 4095Mb (mask 0xffffffff)
hdd: 241254720 sectors (123522 MB) w/1863KiB Cache, CHS=255296/15/63, UDMA(33)

Now, note that hdb, the /dev/sys/vc drive currently having problems, has the CHS=14946/255/63 -- that is to say, it has 255 heads. It only has one partition, hdb1, which is what is used in LVM as /dev/sys/vc.

So the guys says to get gpart: http://www.stud.uni-hannover.de/user/76201/gpart/

Gpart is a small tool which tries to guess what partitions are on a PC type harddisk in case the primary partition table was damaged.

I did make and make install and ran man gpart -- this has some really interesting information:

To save the master boot record (MBR) including the primary partition table to a file type

dd if=/dev/hda of=mbr bs=512 count=1

exchanging /dev/hda with the block device name of the disk in question. This should be done for all disks in the system. To restore the primary partition table without overwriting the MBR type

dd if=mbr of=/dev/hda bs=1 count=64 skip=446 seek=446

So why didn't you know this a long time ago? I tell you, Linux...

I then ran gpart /dev/sys/vc:

It just sits there for a long time, so I interrupt it. I try to mount the volume with mount /dev/sys/vc /mnt/vc -- it's not listed in fstab. It mounts fine. The files are there. I mount the IBM drive. It waits a bit and mounts. I issue a command to copy all the 66GB of files on /vc over to /vd -- at least I won't lose the stuff. I started around 3:15pm -- I wonder what speeds I'm getting -- it looks like something a bit less than a GB a minute.

http://www.r-tt.com/RLinux.shtml -- disk recovery for ext2 file systems:

R-Linux recovers files:

  • Removed by virus attack, power failure or system crash
  • After the partition with the files was reformatted, even for different file system
  • When the partition structure on a disk was changed or damaged. In this case, R-Linux can scan the disk trying to find previously existed partitions and restore files from found partitions.
  • From disks with bad sectors. In this case, R-Linux can first copy the entire disk or its part into an image file and then process the image file. This is especially useful when new bad sectors are constantly appearing on the disk, and remaining information must be immediately saved.

In the end, I just emptied the LVM volume and reformatted it as an ext3 drive. This is really better for my purposes anyway.

July installation

On 18 June 2002, I install a new 120GB drive on cyberspace; the first bootup detects it (see dmesg). I decide to define it using Logical Volume Manager. This is not useful right at the outset, but it allows me to learn how LVM works and prepares for running several disks on one machine with a flexible set of partitions.

In Yast2, I select Hardware and Partitioner. I then expressed an interest in using the Logical Volume Manager, or LVM. The response says,

If you intend to use LVM, at least one partition of type 0x8e (or 0x83) is required. Please change your partition tables accordingly. In most cases, this can be done in the following way: Click on Create, select 'Do not format' and set the partition ID to 0x8e.

I followed these instructions for the new 120GB /dev/hdb, setting the filesystem ID to 0x8e Linux LVM -- apparently its own format.

Here's some background on LVM from its home page, http://www.sistina.com/products_lvm.htm

The Logical Volume Manager, or LVM, is a subsystem for on-line disk storage management that has become a de-facto standard for storage management across Linux implementations.

LVM supports enterprise level volume management of disk and disk subsystems by grouping arbitrary disks into volume groups. The total capacity of volume groups can be allocated to logical volumes, which are accessed as regular block devices.

Further, LVM provides logical separation of storage, the ability to move data from one physical device to another while on-line, and dynamic block device resizing. LVM also enables system administrators to upgrade systems, remove failing disks, reorganize workloads, and adapt to changing system needs, through a minimum amount of time and effort.

We have a new LVM 1.0.4 release! This release provides NBD support and fixes a few bugs found in the LVM 1.0.3 release. The full list of changes can be found in the CHANGELOG.

Now, ftp://ftp.gwdg.de/pub/linux/misc/lvm/ -- which is the ftp server I use for SuSE 7.3 updates -- has a mirror updated daily of the main LVM site, so I may be able to get the update through a SuSE update.

Logical Volume Manager HOWTO http://www.tldp.org/HOWTO/LVM-HOWTO.html

Storage units from multiple drives can be pooled into a "logical volume", where they can be allocated to partitions. Additionally, units can be added or removed from partitions as space requirements change.

Kernel: Linux 2.4 will contain everything you need. It is expected that most distributions will release with LVM included as a module. If you need to compile, just tick off the LVM option when selecting your block devices.

Userspace: You need the tools available from the LVM site. Compiling them on glibc2.1 systems requires a tiny patch.

(I have glibc-1.20020505 -- it's just possible this could cause a problem).

I proceed through Yast2. I OK the creation of the LVM filesystem, which gets set at 114.5GB, identical to the detected drive. I then get this:

Now we have to create a volume group. Typically you don't have to change anything, but if you're an expert, feel free to change our defaults:

Volume group name: system Physical extent size: 4M

I change the group name to sys. I then get to the Logical Volume Manager -- Physical Volume Setup screen. I see Volume Group system (there are no other choices) at size 0 MB and a choice to add or remove group. I see a device column that lists /dev/hdb1 with a size of 114.5GB. The type is Linux LVM. The Volume Group is --. I have the choice to add or remove volume.

So it looks like Volume Group is a logical creation, and Volume is a physical resource.

When I click on "Add volume," the Volume Group column for /dev/hdb1 gets filled in with "sys." On top, the Volume Group size has now changed to 114.5GB. I click Next.

The screen shows Logical Volume Manager on top. Under Volume group it now lists -- against a blue background -- two lines: free and 114.5 GB.

Below is a table of all hard drives on the system -- in the case of cyberspace, just the partitions of /dev/hda, namely /hda1 for /boot, /hda2 for /swap, and /hda3 for /. At the bottom is a box checked that says, "View all mount points, not just the current volume group."

Should I add them all to LVM, or just /hda3? /hda3 has 9 GB -- I mark it and click Add. However, this is apparently not an option -- I only get asked what I want do do with /hdb. The heading reads Create Logical Volume.

The sidebar help says,

Here you create the logical volumes that are used to store your data.

Logical volumes are usable in almost every place where normal disk partitions can be used. You can create filesystems on logical volumes, use them as swap, use them as raw partitions for databases an so on.

If there is still unallocated physical storage in a volume group and you use reiserfs on your filesystems you can extend a logical volume and the underlying filesystem while it is mounted and in use.

Of course the logical volumes need to be large enough to hold all the files to be installed now, but you do not necessarily have to allocate all of your physical storage now. You are always able to increase your filesystems when your SuSE Linux system is online and you decide to install additional packages.

I believe that what this means is that you haven't yet created a partition -- you've just set up the logical volume manager. I simply click Max and put ext2 on the whole thing. Note that you can define "Stripes" -- in effect, a virtual RAID system? It looks like it. I don't give it a mount point -- this is just going to be a video drive, not interlacing with the existing drive on this machine. Presumably LVM will allow me later to create partitions if I want to. I don't even give it a volume name, though I was tempted to call it video. Hopefully this can also be changed later if it seems a good idea.

Even though I'd just clicked Max, I get an error: The size you have entered is too large. But this is a bug -- 114.5 GB is exactly right. I lower it to 114.49 GB and it accepts it as 114.4 GB, but now it demands a volume name; I give it video.

Back in the Logical Volume Manager -- Logical Volumes screen, I now have Volume group system listed as "used" and "114,4 GB". Below, the new drive is listed as /dev/lvm/video, the type is LV. I say Next and go into the Expert Partitioner. Here /dev/sys/video1 is given as 114.5 GB. I press OK and get the execute screen; I confirm and it formats the drive.

I get an error message: vgcreate -- volume group or file already exists. This is because I first allowed it to name the volume group "system". I say OK and reboot.

After the first attempt, aborted, I rebooted. I got this from dmesg:

Partition check:
hda: hda1 hda2 hda3
hdb: hdb1

LVM version 1.0.1-rc4(03/10/2001) module loaded

Then in /var/log/boot.msg I got this:

Run file system check on root for LVM activation
doneRemounting root file system (/) read/write for vgscan...
Scanning for LVM volume groups...
vgscan -- reading all physical volumes (this may take a while...)
vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created
vgscan -- WARNING: This program does not do a VGDA backup of your volume group

Activating LVM volume groups...
vgchange -- no volume groups found

I reenter Yast2. Since the LVM module is now loaded, I run an online system update, manual. This is getting to be a bit tricky, since I've now made lots of non-rpm modifications to the system. I see nothing of interest showing up and abort.

I name the logical volume group sys and the volume vc, for video cyberspace. So the new 115 GB drive can now be referred to as /dev/sys/vc -- nice and easy. This time it really formats.

I don't think I really had a name for the giant drive -- I change references to giant and call it vm, or video gubbio. This will be easy to change later.

I then modified the mount points on cyberspace and gubbio to be /mnt/vc and /mnt/vm for video cyberspace (the 120 GB drive) and video gubbio (the 160 GB drive). These modifications were made in /etc/fstab, /etc/exports, and in the directories /mnt and /home/steen/mnt (in the latter I added symlinks).

We should be all ready to go. I reboot cyberspace and fix the new drive with screws.

With a bit of fiddling -- gubbio has a hard time reloading /etc/exports -- I mount /mnt/vc and /mnt/vm on both gubbio and cyberspace, and I suddenly have another 100 or so gigabytes.

 

 

 

 

top
Debate
Evolution
CogSci

Maintained by Francis F. Steen, Communication Studies, University of California Los Angeles


CogWeb