Skip to contentSkip to conversation

Converting my Root file system to LVM

linux-lvm Rupert Heesom 10 participants 26 messages May 22, 2001 – May 24, 2001

lore
Share & tools
lore
#0 lore raw

I've been practicing LVM techniques on a spare 2nd disk which I'm adding to my root file system using LVM. I think I've got the hang of how LVs, PVs, and VGs work.

I've followed the lvm-howto on how to create a root filesystem.

I've created a partition on the 2nd disk (/dev/sdb1), converted it to a PV.

I've created a VG (/dev/vg) & LV (/dev/vg/root) on that disk.

I've copied the contents of my non-LVM root partition over to the LV - (find / -xdev | cpio -pvmd /mnt/tmp)

I've moved /etc/lilo.conf to my /boot partition, and created a symlink to /boot/lilo.conf in /etc.

I've created an initial RAMdisk on /boot - (/boot/initrd-lvm-2.4.3.gz). I created one RAM disk initially to see how it worked, then ran the "lvmcreate_initrd" again once my LVol was created (and the files copied across).

I've altered my lilo.conf to look like - .....

[rupert@localhost rupert]$cat /etc/lilo.conf
boot=/dev/sda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
linear
default=linux-2_4
message=/boot/message

image=/boot/vmlinuz-2.2.16-22

	label=linux-2_2
	initrd=/boot/initrd-2.2.16-22.img
	read-only
	root=/dev/sda5
	append="mem=384M"

image=/boot/vmlinuz-2.4.3

	label=linux-2_4
	read-only
	root=/dev/sda5
	append="mem=384M"

image=/boot/vmlinuz-2.4.3

	initrd=/boot/initrd-lvm-2.4.3.gz
	root=/dev/vg/root
	label=lvm
	append="mem=384M ramdisk_size=8192"

#image=/usr/src/linux/arch/i386/boot/bzImage
# label=linux_test
# read-only
# root=/dev/sda5
# append="mem=384M"

...... And I've run lilo of course.

Now, when I boot up into the LVM partition, I get the following error msgs -

lvm - Module successfully initialised.
/sbin/vgscan: sed: command not found.
/sbin/vgscan: /lib/lvm-iop10/: is a directory
/sbin/vgscan: exec: /lib/lvm-iop10/: cannot execute: permission denied.

/sbin/vgchange: <same msgs>

Obviously the kernel can't find the LVM tools. Would these not be included in the lvm initrd? If they are, and the kernel still can't find them, what do I change so that the kernel CAN find the LVM tools?

Tnx for any help.

I'M NEARLY THERE!!

Signature · 2 lines
regs
rupert
#1 lore raw

Having looked at another thread also with Root boot problems, I've had a look at my kernel (2.4.3) .config file options for the initrd. Since my lilo.conf file has the RAM disk size set to 8192, would the kernel setting (4096) get in the way of this?

CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_NBD=m
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=4096
CONFIG_BLK_DEV_INITRD=y

Quoted 18 lines · Rupert Heesom

I've been practicing LVM techniques on a spare 2nd disk which I'm adding to my root file system using LVM. I think I've got the hang of how LVs, PVs, and VGs work.

Now, when I boot up into the LVM partition, I get the following error msgs -

lvm - Module successfully initialised.
/sbin/vgscan: sed: command not found.
/sbin/vgscan: /lib/lvm-iop10/: is a directory
/sbin/vgscan: exec: /lib/lvm-iop10/: cannot execute: permission denied.

/sbin/vgchange: <same msgs>

Obviously the kernel can't find the LVM tools. Would these not be included in the lvm initrd? If they are, and the kernel still can't find them, what do I change so that the kernel CAN find the LVM tools?

Signature · 2 lines
regs
rupert
#2 lore raw
In reply to Rupert Heesom

AHA!
you too, huh?
You'll have to add sed to the initial ramdisk.

Its in /boot/initrd<something>.gz
unzip it and mount it with
mount -o loop /boot/initrd<something> /mnt/<somewhere>

then simply
cp /bin/sed /mnt/<somewhere>/bin/

then unmount it, re-gzip it and away you go!

And what *I'd* like to know is why isn't sed on the initrd in the first plade if the scripts need it??

Quoted 99 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Rupert Heesom
Sent: Wednesday, May 23, 2001 4:02 AM
To: [email protected]
Subject: [linux-lvm] Converting my Root file system to LVM

I've been practicing LVM techniques on a spare 2nd disk which I'm adding to my root file system using LVM. I think I've got the hang of how LVs, PVs, and VGs work.

I've followed the lvm-howto on how to create a root filesystem.

I've created a partition on the 2nd disk (/dev/sdb1), converted it to a PV.

I've created a VG (/dev/vg) & LV (/dev/vg/root) on that disk.

I've copied the contents of my non-LVM root partition over to the LV - (find / -xdev | cpio -pvmd /mnt/tmp)

I've moved /etc/lilo.conf to my /boot partition, and created a symlink to /boot/lilo.conf in /etc.

I've created an initial RAMdisk on /boot - (/boot/initrd-lvm-2.4.3.gz). I created one RAM disk initially to see how it worked, then ran the "lvmcreate_initrd" again once my LVol was created (and the files copied across).

I've altered my lilo.conf to look like - .....

[rupert@localhost rupert]$cat /etc/lilo.conf
boot=/dev/sda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
linear
default=linux-2_4
message=/boot/message

image=/boot/vmlinuz-2.2.16-22

	label=linux-2_2
	initrd=/boot/initrd-2.2.16-22.img
	read-only
	root=/dev/sda5
	append="mem=384M"

image=/boot/vmlinuz-2.4.3

	label=linux-2_4
	read-only
	root=/dev/sda5
	append="mem=384M"

image=/boot/vmlinuz-2.4.3

	initrd=/boot/initrd-lvm-2.4.3.gz
	root=/dev/vg/root
	label=lvm
	append="mem=384M ramdisk_size=8192"

#image=/usr/src/linux/arch/i386/boot/bzImage
# label=linux_test
# read-only
# root=/dev/sda5
# append="mem=384M"

...... And I've run lilo of course.

Now, when I boot up into the LVM partition, I get the following error msgs -

lvm - Module successfully initialised.
/sbin/vgscan: sed: command not found.
/sbin/vgscan: /lib/lvm-iop10/: is a directory
/sbin/vgscan: exec: /lib/lvm-iop10/: cannot execute: permission denied.

/sbin/vgchange: <same msgs>

Obviously the kernel can't find the LVM tools. Would these not be included in the lvm initrd? If they are, and the kernel still can't find them, what do I change so that the kernel CAN find the LVM tools?

Tnx for any help.

I'M NEARLY THERE!!

Signature · 7 lines
regs
rupert

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
#24 lore raw
In reply to Rupert Heesom
Quoted 8 lines · Rupert Heesom

Now, when I boot up into the LVM partition, I get the following error msgs -

lvm - Module successfully initialised.
/sbin/vgscan: sed: command not found.
/sbin/vgscan: /lib/lvm-iop10/: is a directory
/sbin/vgscan: exec: /lib/lvm-iop10/: cannot execute: permission denied.

Quoted 5 lines

/sbin/vgchange: <same msgs>

Obviously the kernel can't find the LVM tools. Would these not be included in the lvm initrd? If they are, and the kernel still can't find them, what do I change so that the kernel CAN find the LVM tools?

No, the problem is in the wrapper script for the LVM tools. It is using "sed" in the script, but that is not on the initrd. I don't see sed in my LVM wrapper script, so you must have a different one. Either fix the wrapper script (edit /sbin/vgscan should be enough), or add "sed" to the list of required files, INITRDFILES, in lvmcreate_initrd.

Cheers, Andreas

Signature · 3 lines
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
#3 lore raw
In reply to Steve Wray

Many thanks for the 2 replies!

Well, since I had the same problem as Steve, I implemented his solution.

Tnx, Steve for the easy howto of your's below. BTW, what on earth is that "mount -o loop" command?

As I tap on my keyboard, I am working inside of my new LVol, so it worked, guys!

Since my LVol is on my 2nd disk, next, I think I'll try extending my Lvol back to cover my 1st disk as well.

One more bit of help, if you can? -

I want to pvmove the file contents of my 2nd disk (/dev/sdb) to my 1st disk (/dev/sda). My 1st disk is nice & quiet! Now the lvm-howto specifies my next step (adding the "old partition" into the Lvol) as --

pvcreate /dev/sda <using my device names>
vgextend vg /dev/sda

--- Seeing as I want to do a pvmove of data from /dev/sdb to /dev/sda,
when would I do the pvmove? As I understand LVM, I need to have the PV
created and integrated into the VG before I can use pvmove - is this
correct? Then, once pvmove is used, I can then extend the LV & file
system to cover both PVs using e2fsadm, right?

Quoted 8 lines · Steve Wray

AHA!
you too, huh?
You'll have to add sed to the initial ramdisk.

Its in /boot/initrd<something>.gz
unzip it and mount it with
mount -o loop /boot/initrd<something> /mnt/<somewhere>

Quoted 7 lines

then simply
cp /bin/sed /mnt/<somewhere>/bin/

then unmount it, re-gzip it and away you go!

And what *I'd* like to know is why isn't sed on the initrd in the first plade if the scripts need it??

Well, it seems not all had the same problem, so I don't know!!??

Signature · 2 lines
regs
rupert
#4 lore raw
Quoted 5 lines

From: [email protected] [mailto:[email protected]]On Behalf Of Rupert Heesom

Tnx, Steve for the easy howto of your's below. BTW, what on earth is that "mount -o loop" command?

Glad to have helped!
the "-o loop" tells mount to mount the file on the loopback device. This allows ordinary files (not just block devices) to carry a filesystem. Its quite cool!
:)

Quoted 2 lines

Since my LVol is on my 2nd disk, next, I think I'll try extending my Lvol back to cover my 1st disk as well.

Just watch out for your /boot parition.
You might want to copy lilo.conf over to the /boot partition and make /etc/lilo.conf a symlink to it there.

Quoted 5 lines

One more bit of help, if you can? -

I want to pvmove the file contents of my 2nd disk (/dev/sdb) to my 1st disk (/dev/sda). My 1st disk is nice & quiet! Now the lvm-howto specifies my next step (adding the "old partition" into the Lvol) as --

phew... I have no idea about moving things from PV to PV, however, you may want to look at setting up a miniroot-in-a-ramdisk for this sort of thing. I suspect you need to have the VGs deactivated, and you can't do *that* when its in use as the root LV.

Check out;
http://innominate.org/~graichen/projects/miniroot

miniroot is fantastic, but it needs some work to make it useful for LVM.
Mainly, just unzip and mount it (like you did for the initrd file before) and copy over the lvm programs and libraries.

You'll need to set up a lilo entry too, of course. I think its well documented.

BTW; I'd *seriously* recommend this for anyone with LVM root. It can get you out of trouble!

#5 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

With pvmove-ing an lv, it's actually quite easy... and I've done it several times with the VG active... here's how:

pvcreate <new-pv>
vgextend <vg> <new-pv>
[make sure <new-pv> has at least as many pe's as <old-pv>] pvmove <old-pv> <new-pv> (may require a -f or something if the lv's are open)
vgreduce <vg> <old-pv> (unless you want to keep the old pv for expansion or something)

viola! all lv's that were on <old-pv> are now on <new-pv> :) This is also how I "defragment" the lv's if it gets too crazy with the allocation... although you really don't need to do this (i just like to keep the vgdisplay -v's easier to parse with scripts, etc :) )

- -----Original Message-----
From: [email protected] [mailto:[email protected]]On
Behalf Of Steve Wray
Sent: Wednesday, 23 May 2001 00:02
To: [email protected]
Subject: RE: [linux-lvm] Converting my Root file system to LVM

Quoted 5 lines

From: [email protected] [mailto:[email protected]]On Behalf Of Rupert Heesom

Tnx, Steve for the easy howto of your's below. BTW, what on earth is that "mount -o loop" command?

Glad to have helped!
the "-o loop" tells mount to mount the file on the loopback device. This allows ordinary files (not just block devices) to carry a filesystem.
Its quite cool!
:)

Quoted 2 lines

Since my LVol is on my 2nd disk, next, I think I'll try extending my Lvol back to cover my 1st disk as well.

Just watch out for your /boot parition.
You might want to copy lilo.conf over to the /boot partition and make /etc/lilo.conf a symlink to it there.

Quoted 7 lines

One more bit of help, if you can? -

I want to pvmove the file contents of my 2nd disk (/dev/sdb) to my 1st disk (/dev/sda). My 1st disk is nice & quiet! Now the lvm-howto
specifies my next step (adding the "old partition" into the Lvol) as --

phew... I have no idea about moving things from PV to PV, however, you may want to look at setting up a miniroot-in-a-ramdisk for this sort of thing. I suspect you need to have the VGs deactivated,
and you can't do *that* when its in use as the root LV.

Check out;
http://innominate.org/~graichen/projects/miniroot

miniroot is fantastic, but it needs some work to make it useful for LVM.
Mainly, just unzip and mount it (like you did for the initrd file before)
and copy over the lvm programs and libraries.

You'll need to set up a lilo entry too, of course. I think its well documented.

BTW; I'd *seriously* recommend this for anyone with LVM root. It can get you out of trouble!

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.1

iQA/AwUBOwtEhnC+DNfF0nVpEQLMOwCfazYeopl/VrVdNYDEn7rAnWlYqJEAn0Mj cZX/Oh9MBo5nxV6GBJlC08pT
=LSkE
-----END PGP SIGNATURE-----

#11 lore raw

Re: [linux-lvm] Is now: Resizing & LVM shutdown

In reply to Rupert Heesom
Quoted 31 lines · Rupert Heesom
Quoted 2 lines · Austin Gonyou

I'd say use reiser of XFS for your LVM partition. The grow utilities are pretty kick ass and seem to work really well.

Thanks for your advice.

However, right now I need more help getting LVM to properly shut down when the PC is unmounting the disks in the /etc/rc.d/init.d/halt script.

An extract from another post of mine:

I've discovered that my /etc/rc.d/init.d/halt script is set up incorrectly for LVM. When I previously installed LVM, I followed instructions, and put a "vgchange -an" into the halt script just after /proc is umounted.

What I'm finding now is that when I'm shutting the PC down, vgchange is complaining that it can't close the VG down because there's an active partition (something like that). I've had a look at the halt script, and I can't figure out exactly how umounting the LV & deactivating the VG would work.

I put a tentative line right above the "/sbin/vgchange -an" saying
"umount /dev/vg/root". However, if I'm unmounting root BEFORE
deactivating the VG, then the system won't find the /sbin/vgchange util will it?

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

I've tried shutting the PC down with that extra "halt" script line

Quoted 53 lines

in there. It doesn't help at all.

I do have /boot/initrd-lvm-2.4.3.gz which is used at boot time. This ramdisk does have /sbin/vgchange in it (which you probably know). If root is unmounted when /sbin/vgchange is called, will the system use the
ramdisk? If so, how does it know to use it? (I'm kinda new to
figuring out how ramdisks work, I just follow instructions and they work!)

Quoted 43 lines
Signature · 5 lines
Austin Gonyou
Systems Architect, CCNA
Coremetrics, Inc.
Phone: 512-796-9023
email: [email protected]
Quoted 12 lines · Rupert Heesom

As I write this, a new kernel is being compiled with the patch for online ext2resizing. According to xconfig, enabling the option was DANGEROUS!

As I think about it, since I've installed that root ramdisk (works great), I don't actually need to be able to resize my LVM partition mounted. Still, it's good to have a kernel with such a capability.

I'm not concerned now about UNMOUNTING / deactivating the LVM when shutting the PC down. That doesn't seem to be working at all. (See another post of mine re details there).

Quoted 16 lines

Perhaps you would know how to help me there? I'll experiment a bit myself, but I'm afraid of damaging the LV, since when I reboot my PC, the VG is not yet deactivated! However it _has_ happened twice now without a problem.

Quoted 8 lines · Andreas Dilger

If you patch your kernel with the online ext2 patches, you can resize your root partition while it is still mounted. You will still need a reboot to install the new kernel, however, but only the one time. See
http://sourceforge.net/projects/ext2resize/

It still isn't a bad idea to have a small non-LVM partition on one of your disks which has a kernel you can boot from, along with useful tools in /lib and /sbin. I guess miniroot is such a thing.

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

Try this:

Right before the line in your /etc/init.d/halt script (it may be named different than that however, like shutdown or maybe even reboot):

Before the line that remounts the root (/) partition read-only, put the line:

lsof >/lsof.output

Then reboot. There should be a file in / called lsof.output. Read that and it will let you know all files in use (which would be the reason that it can't unmount the partition).

Good luck!

Glenn Shannon

#13 lore raw

Re: [linux-lvm] Is now: Resizing & LVM shutdown

In reply to Ben Lutgens

I am sure you do...I was merely observing that it may be the same problem I had (due to me *improperly* copying the files from the physical partition to the new LVM partition) and these are the steps I took to resolve it.

I am betting he will see many files opened on /usr/lib.

Hopefully that is NOT the case however. I was lucky enough to have 2 identical RedHat installs at my disposal to create a script and create files that my other scripts could read to redo the symlinking.

If he requires those, the I will gladly let him have them provided he has another machine to create the linklists from.

One of many such tools I have found a necessity from time to time :)

Glenn

Quoted 112 lines · Ben Lutgens
Quoted 7 lines · Glenn Shannon
Quoted 5 lines · Rupert Heesom
Quoted 2 lines · Austin Gonyou

I'd say use reiser of XFS for your LVM partition. The grow utilities are pretty kick ass and seem to work really well.

I run it as my root device with reiserfs on it and don't bother with init / shutdown scripts. No problems.

Quoted 98 lines
Quoted 26 lines

Thanks for your advice.

However, right now I need more help getting LVM to properly shut down when the PC is unmounting the disks in the /etc/rc.d/init.d/halt script.

An extract from another post of mine:

I've discovered that my /etc/rc.d/init.d/halt script is set up incorrectly for LVM. When I previously installed LVM, I followed instructions, and put a "vgchange -an" into the halt script just after /proc is umounted.

What I'm finding now is that when I'm shutting the PC down, vgchange is complaining that it can't close the VG down because there's an active partition (something like that). I've had a look at the halt script, and I can't figure out exactly how umounting the LV & deactivating the VG would work.

I put a tentative line right above the "/sbin/vgchange -an" saying
"umount /dev/vg/root". However, if I'm unmounting root BEFORE
deactivating the VG, then the system won't find the /sbin/vgchange util will it?

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

I've tried shutting the PC down with that extra "halt" script line

Quoted 53 lines

in there. It doesn't help at all.

I do have /boot/initrd-lvm-2.4.3.gz which is used at boot time. This ramdisk does have /sbin/vgchange in it (which you probably know). If root is unmounted when /sbin/vgchange is called, will the system use the
ramdisk? If so, how does it know to use it? (I'm kinda new to
figuring out how ramdisks work, I just follow instructions and they work!)

Quoted 43 lines
Signature · 5 lines
Austin Gonyou
Systems Architect, CCNA
Coremetrics, Inc.
Phone: 512-796-9023
email: [email protected]
Quoted 12 lines · Rupert Heesom

As I write this, a new kernel is being compiled with the patch for online ext2resizing. According to xconfig, enabling the option was DANGEROUS!

As I think about it, since I've installed that root ramdisk (works great), I don't actually need to be able to resize my LVM partition mounted. Still, it's good to have a kernel with such a capability.

I'm not concerned now about UNMOUNTING / deactivating the LVM when shutting the PC down. That doesn't seem to be working at all. (See another post of mine re details there).

Quoted 16 lines

Perhaps you would know how to help me there? I'll experiment a bit myself, but I'm afraid of damaging the LV, since when I reboot my PC, the VG is not yet deactivated! However it _has_ happened twice now without a problem.

Quoted 8 lines · Andreas Dilger

If you patch your kernel with the online ext2 patches, you can resize your root partition while it is still mounted. You will still need a reboot to install the new kernel, however, but only the one time. See
http://sourceforge.net/projects/ext2resize/

It still isn't a bad idea to have a small non-LVM partition on one of your disks which has a kernel you can boot from, along with useful tools in /lib and /sbin. I guess miniroot is such a thing.

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

Try this:

Right before the line in your /etc/init.d/halt script (it may be named different than that however, like shutdown or maybe even reboot):

Before the line that remounts the root (/) partition read-only, put the line:

lsof >/lsof.output

Then reboot. There should be a file in / called lsof.output. Read that and it will let you know all files in use (which would be the reason that it can't unmount the partition).

Good luck!

Glenn Shannon

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

#25 lore raw
In reply to Andreas Dilger

Andreas Dilger wrote:
[]

Quoted 5 lines

No, the problem is in the wrapper script for the LVM tools. It is using "sed" in the script, but that is not on the initrd. I don't see sed in my LVM wrapper script, so you must have a different one. Either fix the wrapper script (edit /sbin/vgscan should be enough), or add "sed" to the list of required files, INITRDFILES, in lvmcreate_initrd.

Initrd intended to be used with exactly one version of kernel, so there should be NO sed there -- it is used to determine kernel iop version, but that known at an initrd creation time. Initrd should contain real utils, not wrappers.

Regards,
Michael.

#15 lore raw
In reply to Steve Wray
Quoted 11 lines · Steve Wray
Quoted 5 lines

From: [email protected] [mailto:[email protected]]On Behalf Of Rupert Heesom

Tnx, Steve for the easy howto of your's below. BTW, what on earth is that "mount -o loop" command?

Glad to have helped!
the "-o loop" tells mount to mount the file on the loopback device. This allows ordinary files (not just block devices) to carry a filesystem. Its quite cool!
:)

That IS pretty cool.

Quoted 8 lines
Quoted 4 lines

Since my LVol is on my 2nd disk, next, I think I'll try extending my Lvol back to cover my 1st disk as well.

Just watch out for your /boot parition.
You might want to copy lilo.conf over to the /boot partition and make /etc/lilo.conf a symlink to it there.

Yes, I've done that already. The suggestion was in the man page for "lvmcreate_initrd".

Quoted 4 lines
Quoted 4 lines

One more bit of help, if you can? -

Quoted 8 lines
Quoted 3 lines

I want to pvmove the file contents of my 2nd disk (/dev/sdb) to my 1st disk (/dev/sda). My 1st disk is nice & quiet! Now the lvm-howto specifies my next step (adding the "old partition" into the Lvol) as --

phew... I have no idea about moving things from PV to PV, however, you may want to look at setting up a miniroot-in-a-ramdisk for this sort of thing. I suspect you need to have the VGs deactivated, and you can't do *that* when its in use as the root LV.

I think the concept is covered (to a degree) in the lvm-howto under "removing an old disk" or something like that.

I've practiced this pvmove thing on my 2nd disk when it was spare. From what I remember, the both PVs had to be inside a VG. The pvmove itself wasn't a problem for me, but the LV had to be dismounted to resize it. I will have to extend my LV & resize the file system using e2fsadm, so I will have to dismount the root volume. It sounds like I DO need the root ram disk which you mention. I'll read up about it.

Quoted 21 lines

Check out;
http://innominate.org/~graichen/projects/miniroot

miniroot is fantastic, but it needs some work to make it useful for LVM.
Mainly, just unzip and mount it (like you did for the initrd file before) and copy over the lvm programs and libraries.

You'll need to set up a lilo entry too, of course. I think its well documented.

BTW; I'd *seriously* recommend this for anyone with LVM root. It can get you out of trouble!

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm

Signature · 2 lines
regs
rupert
#6 lore raw
In reply to S. Michael Denton

Hi Michael:

Thanks for the notes below.

Yes, I do want to keep the old PV active. My whole exercise here is to use LVM to expand my root partition to cover 2 disk. Therefore I've created a PV on my 2nd disk (new one I'm adding onto the PC) and that's up and running as my root currently. Now I'm trying to copy the file system to my orig disk (better disk) and expand the LV to cover both disks.

The expanding the LV & file system using e2fsadm is what I'm dithering
about now. I think it's necessary to umount the LV to change it's size
(my e2fsadm is using the resize2fs util). Since my current new root is already an LVM partition, I need some way of unmounting it, doing the LVM work on it, then remounting it.

I think the miniroot ramdisk which Steve Wray pointed out is probably my answer. However I do wonder whether it's possible to do this another
way? The miniroot ramdisk is still a great idea that I will implement.

Quoted 16 lines · S. Michael Denton

With pvmove-ing an lv, it's actually quite easy... and I've done it several times with the VG active... here's how:

pvcreate <new-pv>
vgextend <vg> <new-pv>
[make sure <new-pv> has at least as many pe's as <old-pv>] pvmove <old-pv> <new-pv> (may require a -f or something if the lv's are open)
vgreduce <vg> <old-pv> (unless you want to keep the old pv for expansion or something)

viola! all lv's that were on <old-pv> are now on <new-pv> :) This is also how I "defragment" the lv's if it gets too crazy with the allocation... although you really don't need to do this (i just like to keep the vgdisplay -v's easier to parse with scripts, etc :) )

Signature · 2 lines
regs
rupert
#17 lore raw

Re: [linux-lvm] Converting my Root file system to LVM [last question]

In reply to Andreas Dilger
Quoted 6 lines · Andreas Dilger

Rupert Heesom writes:

Yes, you can do that... However, once you have LVM you should start to think differently about "partitions" and such. You can create a lot of small partitions for different needs.

Quoted 6 lines

Why is this useful? Because it makes moving stuff around, updating the OS, etc easier. You can have multiple OS installs, but keep your /home and /mp3 data available to both. You can put /mp3 on a new disk and it will spin down when you are not listening to them. You can put /var/log and /var/spool/mail on different LVs so that lots of logs or lots of email don't make your system unusable.

Tnx for the advise here. I'll try to start thinking in those terms.

I've now got one more question which I'll post in this msg -

I've discovered that my /etc/rc.d/init.d/halt script is set up incorrectly for LVM. When I previously installed LVM, I followed instructions, and put a "vgchange -an" into the halt script just after /proc is umounted.

What I'm finding now is that when I'm shutting the PC down, vgchange is complaining that it can't close the VG down because there's an active partition (something like that). I've had a look at the halt script, and I can't figure out exactly how umounting the LV & deactivating the VG would work.

I put a tentative line right above the "/sbin/vgchange -an" saying
"umount /dev/vg/root". However, if I'm unmounting root BEFORE
deactivating the VG, then the system won't find the /sbin/vgchange util will it?

I do have /boot/initrd-lvm-2.4.3.gz which is used at boot time. This ramdisk does have /sbin/vgchange in it (which you probably know). If root is unmounted when /sbin/vgchange is called, will the system use the
ramdisk? If so, how does it know to use it? (I'm kinda new to
figuring out how ramdisks work, I just follow instructions and they work!)

Once I'm satisfied that my LVM setup is not good, then I'm going to try taking the plunge & extending the LV to my other disk.

BTW, since my other disk still has the old file system on it, is this filesystem wiped when I change partition type to "8e", or when I create a PV on it, or not at all? I can't think that anything but the e2fsadm extending the LV file system onto the other disk will wipe the previous contents out.

Signature · 2 lines
regs
rupert
#16 lore raw
In reply to Rupert Heesom
Quoted 4 lines · Rupert Heesom

I want to pvmove the file contents of my 2nd disk (/dev/sdb) to my 1st disk (/dev/sda). My 1st disk is nice & quiet! Now the lvm-howto specifies my next step (adding the "old partition" into the Lvol) as --

Quoted 8 lines

pvcreate /dev/sda <using my device names>
vgextend vg /dev/sda

--- Seeing as I want to do a pvmove of data from /dev/sdb to /dev/sda,
when would I do the pvmove? As I understand LVM, I need to have the PV
created and integrated into the VG before I can use pvmove - is this
correct? Then, once pvmove is used, I can then extend the LV & file
system to cover both PVs using e2fsadm, right?

Yes, you can do that... However, once you have LVM you should start to think differently about "partitions" and such. You can create a lot of small partitions for different needs.

Why is this useful? Because it makes moving stuff around, updating the OS, etc easier. You can have multiple OS installs, but keep your /home and /mp3 data available to both. You can put /mp3 on a new disk and it will spin down when you are not listening to them. You can put /var/log and /var/spool/mail on different LVs so that lots of logs or lots of email don't make your system unusable.

Cheers, Andreas

Signature · 3 lines
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
#18 lore raw

RE: [linux-lvm] Converting my Root file system to LVM [lastquestion]

In reply to Rupert Heesom
Quoted 2 lines

From: [email protected] [mailto:[email protected]]On Behalf Of Rupert Heesom

[snip]

Quoted 11 lines

What I'm finding now is that when I'm shutting the PC down, vgchange is complaining that it can't close the VG down because there's an active partition (something like that). I've had a look at the halt script, and I can't figure out exactly how umounting the LV & deactivating the VG would work.

I put a tentative line right above the "/sbin/vgchange -an" saying
"umount /dev/vg/root". However, if I'm unmounting root BEFORE
deactivating the VG, then the system won't find the /sbin/vgchange util will it?

Quoted 6 lines

I do have /boot/initrd-lvm-2.4.3.gz which is used at boot time. This ramdisk does have /sbin/vgchange in it (which you probably know). If root is unmounted when /sbin/vgchange is called, will the system use the
ramdisk? If so, how does it know to use it? (I'm kinda new to
figuring out how ramdisks work, I just follow instructions and they work!)

Hey thats a good point... maybe a halt-time ramdisk? :)

[snip]

#7 lore raw
In reply to Rupert Heesom
Quoted 9 lines · Rupert

The expanding the LV & file system using e2fsadm is what I'm dithering
about now. I think it's necessary to umount the LV to change it's size
(my e2fsadm is using the resize2fs util). Since my current new root is already an LVM partition, I need some way of unmounting it, doing the LVM work on it, then remounting it.

I think the miniroot ramdisk which Steve Wray pointed out is probably my answer. However I do wonder whether it's possible to do this another
way? The miniroot ramdisk is still a great idea that I will implement.

If you patch your kernel with the online ext2 patches, you can resize your root partition while it is still mounted. You will still need a reboot to install the new kernel, however, but only the one time. See
http://sourceforge.net/projects/ext2resize/

It still isn't a bad idea to have a small non-LVM partition on one of your disks which has a kernel you can boot from, along with useful tools in /lib and /sbin. I guess miniroot is such a thing.

Cheers, Andreas

Signature · 3 lines
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
#8 lore raw

[linux-lvm] Is now: Resizing & LVM shutdown

As I write this, a new kernel is being compiled with the patch for online ext2resizing. According to xconfig, enabling the option was DANGEROUS!

As I think about it, since I've installed that root ramdisk (works great), I don't actually need to be able to resize my LVM partition mounted. Still, it's good to have a kernel with such a capability.

I'm not concerned now about UNMOUNTING / deactivating the LVM when shutting the PC down. That doesn't seem to be working at all. (See another post of mine re details there).

Perhaps you would know how to help me there? I'll experiment a bit myself, but I'm afraid of damaging the LV, since when I reboot my PC, the VG is not yet deactivated! However it _has_ happened twice now without a problem.

Quoted 9 lines · Andreas Dilger

If you patch your kernel with the online ext2 patches, you can resize your root partition while it is still mounted. You will still need a reboot to install the new kernel, however, but only the one time. See
http://sourceforge.net/projects/ext2resize/

It still isn't a bad idea to have a small non-LVM partition on one of your disks which has a kernel you can boot from, along with useful tools in /lib and /sbin. I guess miniroot is such a thing.

Signature · 2 lines
regs
rupert
#10 lore raw

Re: [linux-lvm] Is now: Resizing & LVM shutdown

In reply to Austin Gonyou
Quoted 2 lines · Austin Gonyou

I'd say use reiser of XFS for your LVM partition. The grow utilities are pretty kick ass and seem to work really well.

Thanks for your advice.

However, right now I need more help getting LVM to properly shut down when the PC is unmounting the disks in the /etc/rc.d/init.d/halt script.

An extract from another post of mine:

I've discovered that my /etc/rc.d/init.d/halt script is set up incorrectly for LVM. When I previously installed LVM, I followed instructions, and put a "vgchange -an" into the halt script just after /proc is umounted.

What I'm finding now is that when I'm shutting the PC down, vgchange is complaining that it can't close the VG down because there's an active partition (something like that). I've had a look at the halt script, and I can't figure out exactly how umounting the LV & deactivating the VG would work.

I put a tentative line right above the "/sbin/vgchange -an" saying
"umount /dev/vg/root". However, if I'm unmounting root BEFORE
deactivating the VG, then the system won't find the /sbin/vgchange util will it?

Quoted 1 line
Quoted 1 line
Quoted 1 line

I've tried shutting the PC down with that extra "halt" script line

in there. It doesn't help at all.

I do have /boot/initrd-lvm-2.4.3.gz which is used at boot time. This ramdisk does have /sbin/vgchange in it (which you probably know). If root is unmounted when /sbin/vgchange is called, will the system use the
ramdisk? If so, how does it know to use it? (I'm kinda new to
figuring out how ramdisks work, I just follow instructions and they work!)

Quoted 45 lines
Signature · 5 lines
Austin Gonyou
Systems Architect, CCNA
Coremetrics, Inc.
Phone: 512-796-9023
email: [email protected]
Quoted 12 lines · Rupert Heesom

As I write this, a new kernel is being compiled with the patch for online ext2resizing. According to xconfig, enabling the option was DANGEROUS!

As I think about it, since I've installed that root ramdisk (works great), I don't actually need to be able to resize my LVM partition mounted. Still, it's good to have a kernel with such a capability.

I'm not concerned now about UNMOUNTING / deactivating the LVM when shutting the PC down. That doesn't seem to be working at all. (See another post of mine re details there).

Quoted 17 lines

Perhaps you would know how to help me there? I'll experiment a bit myself, but I'm afraid of damaging the LV, since when I reboot my PC, the VG is not yet deactivated! However it _has_ happened twice now without a problem.

Quoted 9 lines · Andreas Dilger

If you patch your kernel with the online ext2 patches, you can resize your root partition while it is still mounted. You will still need a reboot to install the new kernel, however, but only the one time. See
http://sourceforge.net/projects/ext2resize/

It still isn't a bad idea to have a small non-LVM partition on one of your disks which has a kernel you can boot from, along with useful tools in /lib and /sbin. I guess miniroot is such a thing.

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

Signature · 2 lines
regs
rupert
#9 lore raw

Re: [linux-lvm] Is now: Resizing & LVM shutdown

In reply to Rupert Heesom

I'd say use reiser of XFS for your LVM partition. The grow utilities are pretty kick ass and seem to work really well.

Signature · 5 lines
Austin Gonyou
Systems Architect, CCNA
Coremetrics, Inc.
Phone: 512-796-9023
email: [email protected]
Quoted 29 lines · Rupert Heesom

As I write this, a new kernel is being compiled with the patch for online ext2resizing. According to xconfig, enabling the option was DANGEROUS!

As I think about it, since I've installed that root ramdisk (works great), I don't actually need to be able to resize my LVM partition mounted. Still, it's good to have a kernel with such a capability.

I'm not concerned now about UNMOUNTING / deactivating the LVM when shutting the PC down. That doesn't seem to be working at all. (See another post of mine re details there).

Perhaps you would know how to help me there? I'll experiment a bit myself, but I'm afraid of damaging the LV, since when I reboot my PC, the VG is not yet deactivated! However it _has_ happened twice now without a problem.

Quoted 9 lines · Andreas Dilger

If you patch your kernel with the online ext2 patches, you can resize your root partition while it is still mounted. You will still need a reboot to install the new kernel, however, but only the one time. See
http://sourceforge.net/projects/ext2resize/

It still isn't a bad idea to have a small non-LVM partition on one of your disks which has a kernel you can boot from, along with useful tools in /lib and /sbin. I guess miniroot is such a thing.

#19 lore raw

Re: [linux-lvm] Converting my Root file system to LVM [lastquestion]

In reply to Steve Wray
Quoted 6 lines · Steve Wray
Quoted 4 lines

If root is unmounted when /sbin/vgchange is called, will the system
use the ramdisk? If so, how does it know to use it? (I'm kinda
new to figuring out how ramdisks work, I just follow instructions and they work!)

Hey thats a good point... maybe a halt-time ramdisk? :)

Actually, I posted a similar question to linux-kernel, but I think it was lost in the noise. Basically, it _is_ possible to have a "finitrd" for just this situation (at least on 2.4). You unmount all but root, set up a ramfs, and pivot_root into the ramfs. You can then unmount root (not just a read-only remount), and properly shutdown LVM/RAID/etc. Haven't tried it myself, but it should work.

Note that LVM doesn't actually write anything to disk with "vgchange -an", so there is no real need to do this.

Cheers, Andreas

Signature · 3 lines
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
#14 lore raw

Re: [linux-lvm] Is now: Resizing & LVM shutdown

In reply to Rupert Heesom
Quoted 3 lines · Rupert Heesom

As I write this, a new kernel is being compiled with the patch for online ext2resizing. According to xconfig, enabling the option was DANGEROUS!

It really is very safe, AFAIK. I have never had reports of people losing any data with ext2resize or ext2online. The only recent bug reports have been because the checking in the code has been too strict and it refused to resize someones strange filesystem layout when it should have...

The only reason that it is still marked dangerous is that anything which mucks with your filesystem has the _potential_ for causing problems. Don't let anyone tell you otherwise. Backups are always a good idea for all sorts of other reasons.

Once it is part of the official kernel, and has been running without problems for a while then I will remove the DANGEROUS designation. Until then, I don't really get much feedback on how widely it is used, so I would rather be cautious.

Cheers, Andreas

Signature · 3 lines
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
#20 lore raw

Re: [linux-lvm] Converting my Root file system to LVM [lastquestion]

In reply to Andreas Dilger
Quoted 10 lines · Andreas Dilger

Steve Wray writes:
Actually, I posted a similar question to linux-kernel, but I think it was lost in the noise. Basically, it _is_ possible to have a "finitrd" for just this situation (at least on 2.4). You unmount all but root, set up a ramfs, and pivot_root into the ramfs. You can then unmount root (not just a read-only remount), and properly shutdown LVM/RAID/etc. Haven't tried it myself, but it should work.

Note that LVM doesn't actually write anything to disk with "vgchange -an", so there is no real need to do this.

I guess that's the answer I was looking for.... no real need to do a "vgchange -an" at shutdown. I was sure that it was not healthy for LVM. But if it doesn't matter, then I'll just take out the shutdown command.

BTW, if the VG _isn't_ shut down, what happens to it, ie it was active, then it's suddenly activated again on bootup. Doesn't sound like clean functionality to me.

BTW, the finitrd sounds like a cool thing. I think I'll stick with simplicity right now (assuming it's safe).

Signature · 2 lines
regs
rupert
#12 lore raw

Re: [linux-lvm] Is now: Resizing & LVM shutdown

In reply to Glenn Shannon
Quoted 6 lines · Glenn Shannon
Quoted 4 lines · Rupert Heesom
Quoted 2 lines · Austin Gonyou

I'd say use reiser of XFS for your LVM partition. The grow utilities are pretty kick ass and seem to work really well.

I run it as my root device with reiserfs on it and don't bother with init / shutdown scripts. No problems.

Quoted 103 lines
Quoted 27 lines

Thanks for your advice.

However, right now I need more help getting LVM to properly shut down when the PC is unmounting the disks in the /etc/rc.d/init.d/halt script.

An extract from another post of mine:

I've discovered that my /etc/rc.d/init.d/halt script is set up incorrectly for LVM. When I previously installed LVM, I followed instructions, and put a "vgchange -an" into the halt script just after /proc is umounted.

What I'm finding now is that when I'm shutting the PC down, vgchange is complaining that it can't close the VG down because there's an active partition (something like that). I've had a look at the halt script, and I can't figure out exactly how umounting the LV & deactivating the VG would work.

I put a tentative line right above the "/sbin/vgchange -an" saying
"umount /dev/vg/root". However, if I'm unmounting root BEFORE
deactivating the VG, then the system won't find the /sbin/vgchange util will it?

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

I've tried shutting the PC down with that extra "halt" script line

Quoted 53 lines

in there. It doesn't help at all.

I do have /boot/initrd-lvm-2.4.3.gz which is used at boot time. This ramdisk does have /sbin/vgchange in it (which you probably know). If root is unmounted when /sbin/vgchange is called, will the system use the
ramdisk? If so, how does it know to use it? (I'm kinda new to
figuring out how ramdisks work, I just follow instructions and they work!)

Quoted 43 lines
Signature · 5 lines
Austin Gonyou
Systems Architect, CCNA
Coremetrics, Inc.
Phone: 512-796-9023
email: [email protected]
Quoted 12 lines · Rupert Heesom

As I write this, a new kernel is being compiled with the patch for online ext2resizing. According to xconfig, enabling the option was DANGEROUS!

As I think about it, since I've installed that root ramdisk (works great), I don't actually need to be able to resize my LVM partition mounted. Still, it's good to have a kernel with such a capability.

I'm not concerned now about UNMOUNTING / deactivating the LVM when shutting the PC down. That doesn't seem to be working at all. (See another post of mine re details there).

Quoted 16 lines

Perhaps you would know how to help me there? I'll experiment a bit myself, but I'm afraid of damaging the LV, since when I reboot my PC, the VG is not yet deactivated! However it _has_ happened twice now without a problem.

Quoted 8 lines · Andreas Dilger

If you patch your kernel with the online ext2 patches, you can resize your root partition while it is still mounted. You will still need a reboot to install the new kernel, however, but only the one time. See
http://sourceforge.net/projects/ext2resize/

It still isn't a bad idea to have a small non-LVM partition on one of your disks which has a kernel you can boot from, along with useful tools in /lib and /sbin. I guess miniroot is such a thing.

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

Try this:

Right before the line in your /etc/init.d/halt script (it may be named different than that however, like shutdown or maybe even reboot):

Before the line that remounts the root (/) partition read-only, put the line:

lsof >/lsof.output

Then reboot. There should be a file in / called lsof.output. Read that and it will let you know all files in use (which would be the reason that it can't unmount the partition).

Good luck!

Glenn Shannon

_______________________________________________
linux-lvm mailing list
[email protected]
http://lists.sistina.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://www.sistina.com/lvm/Pages/howto.html

Signature · 6 lines
Ben Lutgens		
Sistina Software Inc.	
MIS Geek
http://www.sistina.com/	<--- great software 
http://www.gentoo.org/  <--- great distro
Kernel panic: I have no root and I want to scream <--- perfect error message
#22 lore raw

Re: [linux-lvm] Converting my Root file system to LVM [lastquestion]

In reply to Andreas Dilger
Quoted 6 lines · Andreas Dilger

Actually, I posted a similar question to linux-kernel, but I think it was lost in the noise. Basically, it _is_ possible to have a "finitrd" for just this situation (at least on 2.4). You unmount all but root, set up a ramfs, and pivot_root into the ramfs. You can then unmount root (not just a read-only remount), and properly shutdown LVM/RAID/etc. Haven't tried it myself, but it should work.

I keep seeing this pivot_root thing. Is it actually implemented in 2.4, and if so, how does one go about doing it?

Thanks,

Signature · 15 lines
AJ Lewis
Sistina Software Inc.                  Voice:  612-638-0500
1313 5th St SE, Suite 111              Fax:    612-638-0500
Minneapolis, MN 55414                  E-Mail: [email protected]
http://www.sistina.com

Current GPG fingerprint = 3B5F 6011 5216 76A5 2F6B  52A0 941E 1261 0029 2648
Get my key at: http://www.sistina.com/~lewis/gpgkey
 (Unfortunately, the PKS-type keyservers do not work with multiple sub-keys)

-----Begin Obligatory Humorous Quote----------------------------------------
"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro help desk.
-----End Obligatory Humorous Quote------------------------------------------
#23 lore raw

Re: [linux-lvm] Converting my Root file system to LVM [lastquestion]

Quoted 10 lines · AJ Lewis
Quoted 6 lines · Andreas Dilger

Actually, I posted a similar question to linux-kernel, but I think it was lost in the noise. Basically, it _is_ possible to have a "finitrd" for just this situation (at least on 2.4). You unmount all but root, set up a ramfs, and pivot_root into the ramfs. You can then unmount root (not just a read-only remount), and properly shutdown LVM/RAID/etc. Haven't tried it myself, but it should work.

I keep seeing this pivot_root thing. Is it actually implemented in 2.4, and if so, how does one go about doing it?

according to docs pivot_root syscall is implemented since 2.3.41 i believe pivot_root command is in util-linux 2.10

you use pivot_root command like
mount /dev/vgRoot/lvRoot /Root #mount real root fs cd /Root
mkdir -p old_root
pivot_root . old_root #this swaps root and old_root exec chroot . /sbin/init

btw syscall is
int pivot_root(const char *new_root, const char *put_old);

L.

Signature · 6 lines
Luca Berra -- [email protected]
        Communication Media & Services S.r.l.
 /"\
 \ /     ASCII RIBBON CAMPAIGN
  X        AGAINST HTML MAIL
 / \
#21 lore raw

RE: [linux-lvm] Converting my Root file system to LVM [lastquestion]

In reply to Rupert Heesom
Quoted 11 lines

From: [email protected] [mailto:[email protected]]On Behalf Of Rupert Heesom
Sent: Thursday, May 24, 2001 10:53 PM
To: [email protected]
Subject: Re: [linux-lvm] Converting my Root file system to LVM [lastquestion]

Quoted 2 lines · Andreas Dilger

Steve Wray writes:
Actually, I posted a similar question to linux-kernel, but I

This is a mis-quote. I didn't write this.
Just thought I'd make sure the record was straight since this is being archived!

Quoted 5 lines
Quoted 5 lines

lost in the noise. Basically, it _is_ possible to have a "finitrd" for just this situation (at least on 2.4). You unmount all but root, set up a ramfs, and pivot_root into the ramfs. You can then unmount root (not just a read-only remount), and properly shutdown LVM/RAID/etc. Haven't tried it myself, but it should work.