LVM question
Hello,
I'm trying to make a script to mount all filesystems that could have a VG. The /etc/fstab does not have the info about filesystems, I must guest from the info of the VG. I can run 'lvs' to see what lv's are opened, I can run a 'mount' to see where is it mounted, and so on. But if the filesystems are not mounted and they have never been in the machine, I can't run 'lsvg -l volume_group' like I can do in AIX, and list the lv's and fs's and mount them. Do you know any flag or command that could show me that info? Thank you. |
I'm not entirely sure which distro you are speaking of, but from a Red Hat stand point.
vgdisplay - will list all Volumegroups lvdisplay - will list all Logical VGs mount -a will mount all filesystems listed in /etc/fstab Any Logical Volume must either be listed in /etc/fstab or mounted manually. Using mount or viewing /etc/mtab file will list currently mounted devices. Hopefully this is helpful. If not then disregard. |
Yes, I know I can mount filesystems listed in fstab but my question is about moving vg from a machine to another.
Maybe into my vg which I want to move from machine A to machine B, when it was in machine A, maybe I could have create a new lv and fs. In this case, the fstab in machine B will be obsolete. How can I see what new filesystems are there in the VG which I've imported into machine B and create mount point and mount it later? Again, if someone has worked with AIX, it is very simple to do. When you import a vg into a machine, the /etc/filesystems (the /etc/fstab in AIX OS) is updated and you can list lv's and the filesystems they have associated. And then, mount them, if you want. Or let a script do ir for you. It doesn't mind if the vg has new fs or not, you can list all of them and do whatever you want. |
IIRC, the command vgchange -a y will activate all available logical volumes and volume groups. You can then do a ls /dev/mapper to see what's available.
I no longer use LVM, but my rc.local file includes this code: Code:
############################################################################# Note that not all the functions (e.g., define_colors, sucmd) are defined in that snippit, but the function's purpose should be obvious in the context. |
So, are all of you saying that I can't mount any filesystem if it is not defined in my fstab?
Can't I list the filesystems available in one vg ? |
Hi
Quote:
Code:
mount -t filesystem_type -o mount_options /dev/vgname/lvname /path/to/mount/point Quote:
LVs from active VGs will show as /dev/mapper/vgname-lvname and as /dev/vgname/lvname Cheers |
cendryon, I know I can do that.
But, what will you do if you will have to mount every filesystem that contains a vg on a machine that does not have the mount point and that machine have never mount that filesystems? How do you know where to mount a lv with the only information that provides the lvs ? I'm trying to demonstrate that I can do the same with Linux than with AIX, talking about LVM |
Hi
I would write a shell script. Whenever I plug a drive (or several, depending of the physical volume involved) containing a volume group, I'd run that script. Along the lines of PTrenholme script, I would start with "vgchange -ay" to activate the VG and its LVs. Then, I'd use vgs and lvs to list all the LVs. I'll then compare it to the content of /etc/fstab and /etc/mtab to ignore already mounted LVs, and to mount known LVs relying on fstab. Then, with the remaining unknown LVs, I'd use blkid to have the device (/dev/mapper/vgname-lvname), its UUID, and above all its filesystem type. With that, I'd create the mount point with "mkdir -p /path/to/mount/point/vgname-lvname/" for instance, and issue the full mount command. As an alternative, I would auto-add previously unknown LVs to fstab, to be mounted with the short form of the mount command. That is for starters. I would then look into udev to have it do all that for me a la USB thumbdrive, but I don't known yet if it is possible. Cheers |
I'm starting to think I can not do what I do with AIX.
So, I think I will compare fstab of machine A with fstab of machine B and I will add (or not) the necessary filesystems entries, and then mount them. Thank you every one. I'll post the results ;) |
All times are GMT -5. The time now is 09:04 AM. |