LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (http://www.linuxquestions.org/questions/fedora-35/)
-   -   Need LVM sanity check (http://www.linuxquestions.org/questions/fedora-35/need-lvm-sanity-check-569551/)

flashl 07-15-2007 03:20 PM

Need LVM sanity check
 
My plight is a long story, but I will try to make it short. I was running Fedora Core 6 when my MB died. After long conversation with local computer shop geek I bought best replacement for my configuration, it was the Intel DG965RY. After days of struggling, I used FC7 Live CD to get system up and realized the only way to keep system up was to bite the bullet and go with FC7. Because I was concern about saving FC6 disk, I purchased another disk to install FC7. I installed FC7 and thought that everything was fine, but somewhere during the install I had done something horribly wrong.

My new FC7 install is ONE LV! Meaning, although I thought I had installed FC7 on the new drive only and identified it only as the partition for FC7. I have managed to combined both drives into one LV. I have read LVM howtos. So, before I go any further and do more damage.

I was wondering IF there is some way to separate the two disks from the one LV without destroying both of the FC6 and FC7 installations?

PTrenholme 07-16-2007 09:13 AM

Yes, of course. Look at the pvchange and lvrename LVM commands.

But are you sure that you have the problem you mention? The most common problem with Fedora LVs is that your old and new default LV names are identical (by default). So, unless you changed the LV name of the F7 installation, you will have two PVs (one on each drive) with the same name, and the nash boot script will do a pvscan, find two LVs with the same name, and do a lvchange to activate one of the LVs -- usually the first of the PVs found.

Since only one of the PVs is activated, that's all you'll see.

Here's the sort of output you might see, although you'll notice that the Fedora I have on the USB drive does not use the default names.
Code:

$ su -
Password:
[root ~]# pvscan
  PV /dev/sdb3  VG USB_Fedora  lvm2 [79.28 GB / 32.00 MB free]
  PV /dev/sda5  VG VolGroup00  lvm2 [30.53 GB / 32.00 MB free]
  Total: 2 [109.81 GB] / in use: 2 [109.81 GB] / in no VG: 0 [0  ]
[root ~]# lvscan
  inactive          '/dev/USB_Fedora/Base' [77.31 GB] inherit
  inactive          '/dev/USB_Fedora/Swap' [1.94 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol00' [29.62 GB] inherit
  ACTIVE            '/dev/VolGroup00/LogVol01' [896.00 MB] inherit
[root ~]# fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *        894        5730    38853202+  7  HPFS/NTFS
/dev/sda2              1        893    7172991    b  W95 FAT32
/dev/sda3            5731        5743      104422+  83  Linux
/dev/sda4            5744        9729    32017545    5  Extended
/dev/sda5            5744        9729    32017513+  8e  Linux LVM

Partition table entries are not in disk order

Disk /dev/sdb: 160.0 GB, 160041885184 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1        9091    73023426  83  Linux
/dev/sdb2  *        9092        9104      104422+  83  Linux
/dev/sdb3            9105      19456    83152440  8e  Linux LVM
/dev/sdb4          19457      19457        8032+  83  Linux

Caution:If you use the lvrename command to change the name of a logical volume, and that volume contains a root file system that needs to be booted, you will need to edit the nash boot script (contained in the Initial RAM Disk image loaded by GRUB) to reference the changed name. (I don't think you can use the mkinitrd command for this since you can't boot to the LV to do it.) Here's a couple scripts I use to unpack and repack the initrd image:
Code:

$ cat Scripts/InitRD/DecompressInitRD
#!/bin/bash
boot="/boot"            # Boot directory
dir="Initial_RAM_Disk"  # Subdirectory of $boot into which the scripts should be decompressed
if [ -d "$1" ]; then
  boot="$1"
fi
echo cd $boot
cd $boot
[ -d $dir ] || sudo mkdir $dir
cd $dir
echo Enter the number corresponding to the image file you want expanded
select img in quit `ls ../*.img`; do
  [ $img == "quit" ] && break;
  sudo gunzip -c $img | sudo cpio -idmv;
done
$ cat Scripts/InitRD/RebuildInitRD
#!/bin/bash
boot="/boot"            # Boot directory
dir="Initial_RAM_Disk"  # Subdirectory of $boot into which the scripts should be decompresed
if [ -d "$1" ]; then
  boot="$1"
fi
sudo echo cd $boot/$dir
cd $boot/$dir
sudo find . | sudo cpio -c -o > /tmp/initrd
cd ../
sudo 'gzip -9 < /tmp/initrd > initrd.img'

Once you've changed the name of the LV (presumably your FC6 LV, you many want to access it from your F7 system. Here's a script I use to access the LV on my USB drive from my F7 system on this laptop:
Code:

$ cat Scripts/MountUsb
#! /bin/bash
# Mount /dev/sdb if it exists
if [ -b /dev/sdb ]; then
    sudo /sbin/vgchange -a y USB_Fedora
    sudo mount /usb
    sudo mount /usb/boot
    sudo mount /usb/shared
else
    echo Drive /dev/sdb was not found.
fi

and here's what the entries in /etc/fstab look like:
Code:

$ cat /etc/fstab | grep -i usb
# USB Drive
/dev/USB_Fedora/Base    /usb                    ext3  defaults,noauto  0 0
LABEL=/boot2            /usb/boot              ext3  defaults,noauto  0 0
LABEL=/shared          /usb/shared            ext3  defaults,noauto  0 0


flashl 07-16-2007 12:14 PM

Here's what I see:

#more /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0

# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [111.69 GB / 64.00 MB free]
PV /dev/sdb1 VG VolGroup00 lvm2 [298.06 GB / 0 free]
Total: 2 [409.75 GB] / in use: 2 [409.75 GB] / in no VG: 0 [0 ]

#lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [407.75 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit

# fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 14593 117113850 8e Linux LVM

Disk /dev/sdb: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 38913 312568641 8e Linux LVM

# pvdisplay /dev/sda2
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 111.69 GB / not usable 1018.00 KB
Allocatable yes
PE Size (KByte) 32768
Total PE 3574
Free PE 2
Allocated PE 3572
PV UUID zInJbL-Px23-0I97-QMtP-tFGj-95lA-kRfHd0

# pvdisplay /dev/sdb1
--- Physical volume ---
PV Name /dev/sdb1
VG Name VolGroup00
PV Size 298.09 GB / not usable 26.81 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 9538
Free PE 0
Allocated PE 9538
PV UUID uveJOk-4gyg-oof6-XKgf-tfh2-tWk3-MiuEcp

sda is where I hope the FC6 installation still resides. I also have available a 500G USB drive and was musing about pvmove and vgreduce.

PTrenholme 07-16-2007 04:10 PM

Well, that does look like the LV is on both PVs, and active. I do find it strange that the 300Gb drive is listed as "full," since a complete Fedora installation shouldn't need that much space.:scratch:

You could try the vgreduce command to remove the FC6 PV from the VG, but I'd try a tar or dump of everything (perhaps to the 500Gb USB drive, eh?) before mucking too much.

Note, however, that the installation of F7 to the merged PVs will probably have replaced all the FC6 information with the F7 stuff, and recreated most of the /etc files for use with F7. If this has been done, then you will not be able to boot your FC6 system. If you have not used any of the directories in /home that information should still be intact, and, in fact, most files in a user's home directory will be untouched by the F7 installation, so most user information should still be intact.

Do you have any idea of how you ended up with a LV spanning two PVs?:scratch: While that type of spanning is exactly what LVM was written to accomplish, I'm surprised to find out that anaconda could actually set up such a system.:)

flashl 07-16-2007 05:27 PM

I have been reviewing the steps that I have taken when installing FC7 and can only guess about what happened. 1) IDE (sda) & Sata (sdb) mixture? 2) Drivers for the DG965RY? and of course 3) OP error.

Here a snippet of anaconda log:
Code:

07:07:34 INFO    : using only installclass _Fedora
07:07:35 INFO    : anaconda called with cmdline = ['/usr/sbin/anaconda', '--method=livecd:///dev/live-osimg', '--lang', 'en_US.UTF-8']
07:07:35 INFO    : Display mode = g
07:07:35 INFO    : Method = livecd:///dev/live-osimg
07:07:35 INFO    : anaconda floppy device fd0
07:07:38 INFO    : Starting graphical installation...
07:07:39 INFO    : Detected 992M of memory
07:07:39 INFO    : Swap attempt of 992M to 1984M
07:07:39 WARNING : step installtype does not exist
07:07:39 WARNING : step complete does not exist
07:07:39 INFO    : moving (1) to step welcome
07:07:44 INFO    : moving (1) to step keyboard
07:07:46 INFO    : moving (1) to step partitionobjinit
07:07:46 INFO    : no /tmp/fcpconfig; not configuring zfcp
07:07:46 DEBUG  : starting mpaths
07:07:46 DEBUG  : self.driveList(): ['sda', 'sdb']
07:07:46 DEBUG  : DiskSet.skippedDisks: []
07:07:46 DEBUG  : DiskSet.skippedDisks: []
07:07:46 DEBUG  : starting all mpaths on drives ['sda', 'sdb']
07:07:46 DEBUG  : scanning for multipath on drives ['sda', 'sdb']
07:07:46 DEBUG  : mpaths: []
07:07:46 DEBUG  : done starting mpaths.  Drivelist: ['sda', 'sdb']
07:07:46 DEBUG  : starting dmraids
07:07:46 DEBUG  : self.driveList(): ['sda', 'sdb']
07:07:46 DEBUG  : DiskSet.skippedDisks: []
07:07:46 DEBUG  : DiskSet.skippedDisks: []
07:07:46 DEBUG  : starting all dmraids on drives ['sda', 'sdb']
07:07:46 DEBUG  : scanning for dmraid on drives ['sda', 'sdb']
07:07:46 DEBUG  : done starting dmraids.  Drivelist: ['sda', 'sdb']
07:08:09 INFO    : lv VolGroup00/LogVol00, attr is -wi-a-
07:08:09 INFO    : lv is VolGroup00/LogVol00, size of 113280
07:08:09 INFO    : lv is VolGroup00/LogVol01, size of 1024
07:08:11 INFO    : pv is /dev/sda2 in vg VolGroup00, size is 114368
07:08:11 INFO    : vg VolGroup00, size is 114368, pesize is 32768
07:08:11 INFO    : lv is VolGroup00/LogVol00, size of 113280
07:08:11 INFO    : lv is VolGroup00/LogVol01, size of 1024
07:08:11 INFO    : mdadm -E /dev/VolGroup00/LogVol00
07:08:11 INFO    : mdadm -E /dev/VolGroup00/LogVol01
07:08:11 INFO    : scd0 is a protected partition
07:08:11 INFO    : no request, probably a removable drive
07:08:11 INFO    : moving (1) to step parttype
07:08:58 INFO    : moving (1) to step autopartitionexecute
07:08:59 DEBUG  : used space is 2016
07:08:59 DEBUG  : actual space is 419520
07:08:59 DEBUG  : used space is 214080
07:08:59 DEBUG  : actual space is 419520
07:08:59 DEBUG  : used space is 215072
07:08:59 DEBUG  : actual space is 419520
07:08:59 DEBUG  : used space is 419520
07:08:59 DEBUG  : actual space is 419520
07:08:59 DEBUG  : used space is 419520
07:08:59 DEBUG  : actual space is 419520
07:08:59 DEBUG  : used space is 419520
07:08:59 DEBUG  : actual space is 419520
07:08:59 INFO    : moving (1) to step partition
07:10:02 INFO    : moving (1) to step partitiondone
07:10:02 INFO    : moving (1) to step bootloadersetup
07:10:02 INFO    : moving (1) to step bootloader
07:10:15 INFO    : moving (1) to step networkdevicecheck
07:10:15 INFO    : moving (1) to step network
07:10:57 INFO    : moving (1) to step timezone
07:13:10 INFO    : moving (1) to step accounts
07:13:26 INFO    : moving (1) to step reposetup
07:13:26 INFO    : moving (1) to step basepkgsel
07:13:26 INFO    : moving (1) to step postselection
07:13:26 INFO    : moving (1) to step confirminstall
07:13:31 INFO    : moving (1) to step install
07:13:31 INFO    : moving (1) to step enablefilesystems
07:13:32 INFO    : lv is VolGroup00/LogVol00, size of 113280
07:13:32 INFO    : lv is VolGroup00/LogVol01, size of 1024
07:13:32 INFO    : removing lv LogVol01
07:13:32 INFO    : removing lv LogVol00
07:13:32 INFO    : pv is /dev/sda2 in vg VolGroup00, size is 114368
07:13:32 INFO    : vgremove -v VolGroup00
07:13:32 INFO    : pvremove -ff -y -v /dev/sda2
07:13:32 INFO    : pvcreate -ff -y -v /dev/sda2
07:13:32 INFO    : disk.commit() for /dev/sda
07:13:32 INFO    : disk.commit() for /dev/sdb
07:13:34 INFO    : formatting swap as swap
07:13:34 INFO    : formatting / as ext3
07:13:34 INFO    : Format command:  ['mke2fs', '/dev/VolGroup00/LogVol00', '-i', '4096', '-j']

07:19:08 INFO    : formatting /boot as ext3
07:19:08 INFO    : Format command:  ['mke2fs', '/tmp/sda1', '-i', '4096', '-j']

07:19:13 INFO    : lv VolGroup00/LogVol00, attr is -wi-a-
07:19:13 INFO    : lv is VolGroup00/LogVol00, size of 417536
07:19:13 INFO    : lv is VolGroup00/LogVol01, size of 1984
07:19:15 DEBUG  : error reading swap label on /dev/VolGroup00: [Errno 21] Is a directory
07:19:15 DEBUG  : error reading xfs label on /dev/VolGroup00: [Errno 21] Is a directory
07:19:15 DEBUG  : error reading jfs label on /dev/VolGroup00: [Errno 21] Is a directory
07:19:15 DEBUG  : error reading reiserfs label on /dev/VolGroup00: [Errno 21] Is a directory


PTrenholme 07-16-2007 09:23 PM

Perhaps I'm reading that wrong, but it looks like anaconda found a LV on /dev/sda2 (07:08:11), removed it (07:13:32) , recreated it (also 07:13:32) and then reformatted it (again 07:13:32). If that reading is correct, your FC6 system went "poof" at 07:13:32, and all you've got are your off-line backups.

I note (at 07:08:58) that autopartition is to be used. (I think that, by default, that option will use all your available drive space for the Fedora system.) I suspect that this may be the source of your problem.

I still don't understand why the 300Gb drive is listed as "full." :scratch: Did you install every Fedora package?

flashl 07-16-2007 09:56 PM

I installed from the Live-CD and stopped when I saw the one LV.


All times are GMT -5. The time now is 10:10 AM.