Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-20 Thread Matthias Julius
Craig Hagerman [EMAIL PROTECTED] writes:

 But sdb1 had ALREADY been set up. Actually I had formatted it with
 ext3, then followed the howto (pvcreate, vgcreate, lvcreate, mount) to
 set up LVM and then copied all my old data over. So I then set the
 partition type to LVM on a disc that already was set up with a VG, LV.

Changing the partition type does not touch the partition itself.  It
just sets a flag in the partition table.


 ...now vgdisplay gives me

 $ vgdisplay
   Couldn't find device with uuid 'ZHl4Ak-mGS4-wFlF-4neF-G1Ed-GxWB-C4Smj6'.
   Couldn't find all physical volumes for volume group media_vg.
   Couldn't find device with uuid 'ZHl4Ak-mGS4-wFlF-4neF-G1Ed-GxWB-C4Smj6'.
   Couldn't find all physical volumes for volume group media_vg.
   Volume group media_vg doesn't exist

 ...but pvdisplay gives me encouraging news. I just don't know what to
 do with this information to try to recover.

 $ pvdisplay
   Couldn't find device with uuid 'ZHl4Ak-mGS4-wFlF-4neF-G1Ed-GxWB-C4Smj6'.
   --- Physical volume ---
   PV Name   /dev/sdb1
   VG Name   media_vg
   PV Size   233.75 GB / not usable 0
   Allocatable   yes
   PE Size (KByte)   4096
   Total PE  59841
   Free PE   193
   Allocated PE  59648
   PV UUID   rlnV4y-B4eJ-Pyc0-RLJm-2Zbv-t04C-dxzU1A

sdb1 is OK.


   --- Physical volume ---
   PV Name   unknown device
   VG Name   media_vg
   PV Size   186.30 GB / not usable 0
   Allocatable   yes
   PE Size (KByte)   4096
   Total PE  47694
   Free PE   47694
   Allocated PE  0
   PV UUID   ZHl4Ak-mGS4-wFlF-4neF-G1Ed-GxWB-C4Smj6

LVM does not find sda2.  What does pvdisplay /dev/sda2 say?

I guess LVM only scans devices that have its type set to LVM.  So it
might be enough to just do that for sda2.

Matthias


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-20 Thread Craig Hagerman
On 10/20/05, Matthias Julius [EMAIL PROTECTED] wrote:
LVM does not find sda2.What does pvdisplay /dev/sda2 say?
% pvdisplay /dev/sda2
 No physical volume label read from /dev/sda2
 Failed to read physical volume /dev/sda2

I guess LVM only scans devices that have its type set to LVM.So itmight be enough to just do that for sda2.



Before, the partition type for /dev/sdb1 was ext3 (ie 82). Now it is
LVM (8e). So you are saying that just by changing the partition type
the data is not effected, right? If I now change it BACK to ext3, do
you suppose everything will be mount-able?

Right now sda2 is showing up as type Linux. It was previously set to
ext3 so this looks correct, but since I created the VG and LV, I can't
mount it with mount -t ext3  or mount -t auto.



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-20 Thread Goswin von Brederlow
Craig Hagerman [EMAIL PROTECTED] writes:

 On 10/20/05, Matthias Julius [EMAIL PROTECTED] wrote:


LVM does not find sda2.  What does pvdisplay /dev/sda2
  say?


 % pvdisplay /dev/sda2
   No physical volume label read from /dev/sda2
   Failed to read physical volume /dev/sda2
  


   I guess LVM only scans devices that have its type set to
  LVM.  So it
  might be enough to just do that for sda2.
  


 Before, the partition type for /dev/sdb1 was ext3 (ie 82). Now it is LVM
 (8e). So you are saying that just by changing the partition type the data is
 not effected, right? If I now change it BACK to ext3, do you suppose
 everything will be mount-able?
 Right now sda2 is showing up as type Linux. It was previously set to ext3 so
 this looks correct, but since I created the VG and LV, I can't mount it with
 mount -t ext3  or mount -t auto.

Mounting totaly ignores the partition type anyway. So that did
nothing. But running pvcreate will have overwritten some data.

Try mounting with an alternate superblock and mount read-only and save
whatever you can.

MfG
Goswin


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-20 Thread Lennart Sorensen
On Thu, Oct 20, 2005 at 03:54:12PM +0200, Goswin von Brederlow wrote:
 Mounting totaly ignores the partition type anyway. So that did
 nothing. But running pvcreate will have overwritten some data.

Well if pvcreate was run, and that is all, perhaps looking at the lvm
backup data in /etc can tell what the UUID used to be and pvcreate might
allow you to tell it what uuid you want used on that device.  Then lvm
should recognize it again.  pvcreate doesn't overwrite the data area of
a pv, just the block containing the size and uuid and such (and the size
shouldn't have changed).  Unless I am missing something in my
understanding of LVM that is.  If it was not previously an lvm device,
then year whatever was there is not hurt badly.

 Try mounting with an alternate superblock and mount read-only and save
 whatever you can.

Len Sorensen


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-20 Thread Craig Hagerman
On 10/20/05, Goswin von Brederlow [EMAIL PROTECTED] wrote:
 Mounting totaly ignores the partition type anyway. So that did
 nothing. But running pvcreate will have overwritten some data.

 Try mounting with an alternate superblock and mount read-only and save
 whatever you can.


What does it mean to mount with an alternate superblock. I don't get
this. Can you give me an example?


On 10/20/05, Lennart Sorensen [EMAIL PROTECTED] wrote:
 Well if pvcreate was run, and that is all, perhaps looking at the lvm
 backup data in /etc can tell what the UUID used to be and pvcreate might
 allow you to tell it what uuid you want used on that device.  Then lvm
 should recognize it again.  pvcreate doesn't overwrite the data area of
 a pv, just the block containing the size and uuid and such (and the size
 shouldn't have changed).  Unless I am missing something in my
 understanding of LVM that is.  If it was not previously an lvm device,
 then year whatever was there is not hurt badly.

Yes, I can open the file /etc/lvm/backup/media_vg. The IDs of the
physical volumes look OK. The PV UUID of each disc matches what is in
that file.

Craig



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-20 Thread Lennart Sorensen
On Thu, Oct 20, 2005 at 08:35:22PM +0200, Goswin von Brederlow wrote:
 If I read that very confusing mail right then he did run pvcreate on
 an ext3 filesystem. So the first superblock is probably wiped.

Oh on a disk he already had data on and didn't want to use for lvm?
Yeah taht would be bad.  I thought he just couldn't get the lvm started
because one of the PVs was missing.

Len Sorensen


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-20 Thread Matthias Julius
Craig Hagerman [EMAIL PROTECTED] writes:

 On 10/20/05, Matthias Julius [EMAIL PROTECTED] wrote:


 LVM does not find sda2. What does pvdisplay /dev/sda2 say?

 % pvdisplay /dev/sda2
 No physical volume label read from /dev/sda2
 Failed to read physical volume /dev/sda2

 I guess LVM only scans devices that have its type set to LVM. So it
 might be enough to just do that for sda2.


 Before, the partition type for /dev/sdb1 was ext3 (ie 82). Now it is LVM
 (8e). So you are saying that just by changing the partition type the data is
 not effected, right? If I now change it BACK to ext3, do you suppose
 everything will be mount-able?

There is no ext3 on your sdb1.  There is a PV with data in it.  From
the old ext3 fs is certainly not much left.  And the type of LVM is
appropriate.  And the data on there are probably OK.


 Right now sda2 is showing up as type Linux. It was previously set to ext3
 so this looks correct, but since I created the VG and LV, I can't mount it
 with mount -t ext3  or mount -t auto.

There is no partition type ext3.  All linux partitions with a
filesystem have the type Linux.  The type of your sda2 probably should
be set to LVM.

,[from man vgcfgrestore]
| REPLACING PHYSICAL VOLUMES
| vgdisplay --partial --verbose will show you the UUIDs and  sizes  of  any
| PVs  that  are no longer present.  If a PV in the VG is lost and you wish
| to substitute another of the same size, use pvcreate --restorefile  file-
| name --uuid uuid (plus additional arguments as appropriate) to initialise
| it with the same UUID as the missing PV.  Repeat for  all  other  missing
| PVs in the VG.  Then use vgcfgrestore --file filename to restore the vol-
| ume group's metadata.
`

I would try that.

If you did not extend the LV after adding sda2 you can also run
vgreduce --removemissing vg-name to get rid of the missing PV and to
get a clean VG.

Matthias


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT?] LVM questions

2005-10-19 Thread Goswin von Brederlow
Craig Hagerman [EMAIL PROTECTED] writes:

 Hi,

 I recently bought a new hard drive. I alread have another big hard
 drive for files so altogether they have 450 GB.  I decided to set up
 LVM on my system to make it easy to access both together and be able
 to add more space in the future, but I am a bit wary because I know
 little about LVM. This is strictly for data, not the root partition.
 (note- I HAVE read the howto and other things online but don't find
 any of them all that user-friendly for the newbie. Things like um...
 how to I actually access this LVM disc I have just created or how do
 I get the LVM discs to automatically show up on reboot are NOT
 obvious from the howto.)

LVM is dead simple:

1. Write the lvm label onto the disk/partition:
   pvcreate /dev/disk
2. Create a volume group with one or more physical volumes
   vgcreate vg-name /dev/disk
3. Create a logical volume (like a partition)
   lvcreate -L 1G -n lv-name vg-name
4. Format the LV
   mke2fs -j /dev/vg-name/lv-name
5. mount the filesystem
   mount /dev/vg-name/lv-name /mnt/whatever

That is realy all there is to it normaly. Debian has lvm all setup to
autodetect on boot and all.

 I am wondering if there is any downside about using LVM I should be
 aware of. Is my data any less safe? I ask because I didn't realizze
 (at first) how to get the LVM disc to show up on boot, so it appeared
 that everything just wasn't there. So I was thinking - what if I have
 some problem with my root partition in the future, is the data on an
 LVM share just as accessable as otherwise? (Stupid question perhaps,
 but I don't know much yet.)

If your lvm spans accross 2 disks the volume group won't be activated
when one of the disks fails. But you can manualy activate a partial
volume group (-P option) to recover as much of the data as is till
there. Any missing parts will be mapped to produce an I/O error when
read. Obviously any logical volume on the missing disk (even partialy)
will have data loss or is unreadable alltogether.

So yes, there is a downside to LVM. You loose a disk in the group and
you have problems. But if you would have a raid0 (striping) over the
disks you also have problems if one disks fails. That is just a result
of having multiple disks joined together.

 Also I am still uncertain about how to best make use of two discs with
 LVM. Do I HAVE to set up a RAID, or is it an option. Is there any
 benifit or danger to using a RAID or not with LVM. (I have never set
 up a RAID but my motherboard - ASUS Kv8 I think - can do that I
 think.) If I don't use a RAID how are the discs used? Does it just
 fill up one, and then start on the other or use space on both at the
 same time?

By default lvm will do linear raid, put one disk behind the other,
when creating logical volumes. You get the space benefit but no speed
gain.

But lvm can also do raid 0 (striping) of a logical volume over
multiple physical volumes. This gives you the extra speed from
accessing multiple drives in parallel just like raid0 would but
preserves the lvm abilities to grow/shrink or move a logical volume at
any time.

So if you think about doing linear raid or raid0 then LVM is always
superior.


The best use of 2 disks in my opinion is to use raid1 (mirroring) and
lvm. I would create 4 partitions:

sda1 + sdb1: 300Mb raid1 for /
sda2 + sdb2: 1GB raid1 for swap
sda3 + sdb3: 10GB raid1 with lvm (vg1) for /usr, /var, /home
sda4 + sdb4: rest with lvm (vg2) with less important data

This means that all the system files and your precious home directory
will be save from a single disk failure. You don't loose your system
configuration or your gpg key if a disk fails. Just plug in a new one,
partition it the same way and let the raid resync. 

But you also have less important data that utilizes the space of both
disks without any protection against disk failure. Put things on there
you can recover again, like a debian mirror. :)


Think carefully about the right sizes for the 3rd and 4th
partitions. Changing them later isn't the easiest.

 Apologies for my ignorance in advance.

 Craig

MfG
Goswin


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-19 Thread Craig Hagerman
Thanks for the reply and explanation. I understand better now. Are you
sure that Debian takes care of mounting the new LVM share on boot? It
didn't work for me. From what I have read online you have to create
your own startup script.

I had LVM set up successfully on my new HD, copied all the data over
from the old one and then tried to extend LVM to include the new one.
Unfortunately I made one typo and now I think I have screwed things
up. Here is what I did:
...
NOTE - sda = old HD, sdb = new HD set up with LVM
.

$ pvcreate /dev/sda2
  Physical volume /dev/sda2 successfully created

$ vgextend media_vg /dev/sda2
  Volume group media_vg successfully extended

 Then I tried to set up sda according to instructions on a web
site, but I wrote the wrong device without noticing

$ fdisk /dev/sdb

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 251.0 GB, 251000193024 bytes
255 heads, 63 sectors/track, 30515 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot  Start End  Blocks   Id  System
/dev/sdb1   1   30515   245111706   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device
or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.



So, am I totally screwed or can I recover the data and save
everything? The situation before, was that the data was mirrored on
both sda and sdb (sdb mounted as LVM at /mnt/media). But I now see
that I inadvertantly changed the partition type of sdb (when I
intended sda). So I assume that is a lost cause. (?)

Is there anything I can do now to recover?

Craig



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-19 Thread Matthias Julius
Craig Hagerman [EMAIL PROTECTED] writes:

 WARNING: Re-reading the partition table failed with error 16: Device
 or resource busy.
 The kernel still uses the old table.
 The new table will be used at the next reboot.
 Syncing disks.

This just means what is says.  The disk is in use and the kernel can
not reread the partition table.  You have to reboot to do that.


 So, am I totally screwed or can I recover the data and save
 everything? The situation before, was that the data was mirrored on
 both sda and sdb (sdb mounted as LVM at /mnt/media). But I now see
 that I inadvertantly changed the partition type of sdb (when I
 intended sda). So I assume that is a lost cause. (?)

 Is there anything I can do now to recover?

Actually I don't think there is anything you need to recover from.
You have set the partition type of sdb1 to LVM and that is what it
should be.  That is assuming that you used sdb1 as PV and not sdb.

Now you just need to do the same for sda2 and you should be fine.
Reboot after that.

Debian will activate the VG but it will not mount the LVs automatically.
You still have to add them to /etc/fstab.

Matthias


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-19 Thread Paul Brook
 Debian will activate the VG but it will not mount the LVs automatically.
 You still have to add them to /etc/fstab.

If you're using root-on-lvm you may also need to regenerate your initrd before 
rebooting.

Paul


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: [OT?] LVM questions - I have seriously screwed my system

2005-10-19 Thread Craig Hagerman
On 10/20/05, Matthias Julius [EMAIL PROTECTED] wrote:

 This just means what is says.  The disk is in use and the kernel can
 not reread the partition table.  You have to reboot to do that.

Unfortunately I did reboot before I noticed the typo. After the reboot
neither disc can be seen.


 Actually I don't think there is anything you need to recover from.
 You have set the partition type of sdb1 to LVM and that is what it
 should be.  That is assuming that you used sdb1 as PV and not sdb.

But sdb1 had ALREADY been set up. Actually I had formatted it with
ext3, then followed the howto (pvcreate, vgcreate, lvcreate, mount) to
set up LVM and then copied all my old data over. So I then set the
partition type to LVM on a disc that already was set up with a VG, LV.

...now vgdisplay gives me

$ vgdisplay
  Couldn't find device with uuid 'ZHl4Ak-mGS4-wFlF-4neF-G1Ed-GxWB-C4Smj6'.
  Couldn't find all physical volumes for volume group media_vg.
  Couldn't find device with uuid 'ZHl4Ak-mGS4-wFlF-4neF-G1Ed-GxWB-C4Smj6'.
  Couldn't find all physical volumes for volume group media_vg.
  Volume group media_vg doesn't exist

...but pvdisplay gives me encouraging news. I just don't know what to
do with this information to try to recover.

$ pvdisplay
  Couldn't find device with uuid 'ZHl4Ak-mGS4-wFlF-4neF-G1Ed-GxWB-C4Smj6'.
  --- Physical volume ---
  PV Name   /dev/sdb1
  VG Name   media_vg
  PV Size   233.75 GB / not usable 0
  Allocatable   yes
  PE Size (KByte)   4096
  Total PE  59841
  Free PE   193
  Allocated PE  59648
  PV UUID   rlnV4y-B4eJ-Pyc0-RLJm-2Zbv-t04C-dxzU1A

  --- Physical volume ---
  PV Name   unknown device
  VG Name   media_vg
  PV Size   186.30 GB / not usable 0
  Allocatable   yes
  PE Size (KByte)   4096
  Total PE  47694
  Free PE   47694
  Allocated PE  0
  PV UUID   ZHl4Ak-mGS4-wFlF-4neF-G1Ed-GxWB-C4Smj6