LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-20-2011, 02:14 PM   #1
smilemukul
Member
 
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292

Rep: Reputation: 34
LVM


Hi,
How kernel/OS recognizes the LVM volumes when the system bootes up ?

Thanks
 
Old 01-20-2011, 07:55 PM   #2
tommylovell
Member
 
Registered: Nov 2005
Distribution: Raspbian, Debian, Ubuntu
Posts: 380

Rep: Reputation: 103Reputation: 103
Take a look at http://en.wikipedia.org/wiki/Initrd. It's a pretty good overview of how initrd or initramfs works.

This code in /init in the initrd file of my Fedora 10 system is probably what you are asking about.

Code:
echo Scanning logical volumes
lvm vgscan --ignorelockingfailure
echo Activating logical volumes
lvm vgchange -ay --ignorelockingfailure  vgz00
resume UUID=b827e20f-db5b-47b2-be38-17489895a0ad
echo Creating root device.
mkrootdev -t ext3 -o defaults,ro UUID=54716048-c91b-4f48-b37e-fb09ce21e412
echo Mounting root filesystem.
mount /sysroot
I'm no expert (I'm always hoping that one will chime in before I do, or at least correct me after the fact), but in my experience there are variations of this between distros and sometime between releases in the same distro, but this is the general approach they take.

You'd have to explode your initrd/initramfs and look to see how it's done on your system.

For reference, here is the entire /init file.
Code:
#!/bin/nash

mount -t proc /proc /proc
setquiet
echo Mounting proc filesystem
echo Mounting sysfs filesystem
mount -t sysfs /sys /sys
echo Creating /dev
mount -o mode=0755 -t tmpfs /dev /dev
mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
mkdir /dev/shm
mkdir /dev/mapper
echo Creating initial device nodes
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/fb c 29 0
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty10 c 4 10
mknod /dev/tty11 c 4 11
mknod /dev/tty12 c 4 12
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/ttyS3 c 4 67
/lib/udev/console_init tty0
daemonize --ignore-missing /bin/plymouthd
plymouth --show-splash
echo Setting up hotplug.
hotplug
echo Creating block device nodes.
mkblkdevs
echo Creating character device nodes.
mkchardevs
echo "Loading raid1 module"
modprobe -q raid1
echo "Loading raid456 module"
modprobe -q raid456
echo "Loading sata_nv module"
modprobe -q sata_nv
echo "Loading pata_acpi module"
modprobe -q pata_acpi
echo "Loading ata_generic module"
modprobe -q ata_generic
echo Making device-mapper control node
mkdmnod
modprobe scsi_wait_scan
rmmod scsi_wait_scan
mkblkdevs
mdadm -As --auto=yes --run /dev/md0
echo Scanning logical volumes
lvm vgscan --ignorelockingfailure
echo Activating logical volumes
lvm vgchange -ay --ignorelockingfailure  vgz00
resume UUID=b827e20f-db5b-47b2-be38-17489895a0ad
echo Creating root device.
mkrootdev -t ext3 -o defaults,ro UUID=54716048-c91b-4f48-b37e-fb09ce21e412
echo Mounting root filesystem.
mount /sysroot
cond -ne 0 plymouth --hide-splash
echo Setting up other filesystems.
setuproot
loadpolicy
plymouth --newroot=/sysroot
echo Switching to new root and running init.
switchroot
echo Booting has failed.
sleep -1
Hope that helps.

Last edited by tommylovell; 01-20-2011 at 07:57 PM.
 
Old 01-20-2011, 08:05 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Here's a couple of good articles on LVM:
HOWTO: http://tldp.org/HOWTO/LVM-HOWTO/
In depth(!) details: http://sunoano.name/ws/public_xhtml/lvm.html
 
Old 01-21-2011, 12:23 AM   #4
smilemukul
Member
 
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292

Original Poster
Rep: Reputation: 34
Thanks but I am using Redhat.
Also how lvmmeta data help in recognising the lvm volumes at boot.

Thanks
 
Old 01-21-2011, 07:54 AM   #5
tommylovell
Member
 
Registered: Nov 2005
Distribution: Raspbian, Debian, Ubuntu
Posts: 380

Rep: Reputation: 103Reputation: 103
Well, RHEL5 and Fedora10 do the initrd the same way (if you are on RHEL5 or older - you should update your profile here to indicate distro and level, or state that in your posts... you'll get better replies). So, you would have in your /init within your ramdisk a 'vgscan' and a 'vgchange' very similar to mine.

The 'vgscan' is what locates the volume groups using the metadata that is within all of the eligible LVM volumes on your system.

See the 'vgscan' man page. 'vgscan' uses the filter parameter in /etc/lvm/lvm.conf to decide which volumes to look at and which ones to exclude.

Then do 'vgscan -vv' and it'll tell you which devices on your system that it is scanning, and of those, which ones actually have metadata.

Also, try a 'vgchange -ay -vv' to see what processing that does.

ps. don't ask me where the 'pvscan' is done. that part eludes me. it's either done prior to /init being evoked, or possibly vgscan somehow causes it to be done internally (no proof and i doubt it, just wild speculation). maybe someone else knows the answer.

Last edited by tommylovell; 01-21-2011 at 08:02 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LVM REDUCE HOW TO UNMOUNT /dev/volumegroup/lvm crahuldba@gmail.com Linux - Newbie 3 10-29-2010 07:49 AM
Adding an LVM hard disk to a system already running/using LVM firewiz87 Linux - Hardware 5 08-15-2010 12:59 AM
lvm ontop of raid10 or combine two raid1 via lvm? okar Linux - Server 3 09-11-2009 02:37 PM
LVM and multiple iSCSI disks performance of LVM xxx_anuj_xxx Linux - Server 4 05-01-2008 12:26 PM
LXer: Back Up (And Restore) LVM Partitions With LVM Snapshots LXer Syndicated Linux News 0 04-17-2007 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:30 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