Koozali.org: home of the SME Server

how to attach usb drive

Offline william_syd

  • ****
  • 1,608
  • +0/-0
  • Nothing to see here.
    • http://www.magicwilly.info
how to attach usb drive
« Reply #15 on: November 02, 2006, 10:47:41 AM »
Quote from: "Gaston94"

I have not been able, so far, to access one sme7 disk on another sme7, I guess the reason is linked to metadevice used (/dev/md2) : when I plugged one foreign disk it hides my other disk :cry: should any one have some clues .. :) let me know.

Gaston


SME disk back onto SME does not work as you say.

Code: [Select]
[root@c3 ~]# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 hda2[0]
      78043648 blocks [2/1] [U_]

md1 : active raid1 hda1[0]
      104320 blocks [2/1] [U_]

unused devices: <none>
[root@c3 ~]#

Code: [Select]
[root@c3 ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 36481.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 300.0 GB, 300069052416 bytes
255 heads, 63 sectors/track, 36481 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   fd  Linux raid autodetect
/dev/sda2              14       36481   292929210   fd  Linux raid autodetect

Command (m for help):

Code: [Select]
[root@c3 ~]# pvscan
  PV /dev/md2   VG main   lvm2 [74.41 GB / 32.00 MB free]
  Total: 1 [74.41 GB] / in use: 1 [74.41 GB] / in no VG: 0 [0   ]
[root@c3 ~]#
Regards,
William

IF I give advise.. It's only if it was me....

Offline Gaston94

  • ****
  • 184
  • +0/-0
how to attach usb drive
« Reply #16 on: January 20, 2007, 09:59:33 PM »
Hi,
I finally managed to access a SME7 LVM RAID on another SME7 server.
Process is not hard, but requires that you know why and what you are doing.
This is an emergency rescue procedure, and think about having a backup of the systeme you are working on.

Steps to follow are :

    * Retrieve the source RAID arry definition
Code: [Select]
[root@ixus ~]# mdadm --examine --scan /dev/sdc2
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=e8cd2148:6e9e3fb7:12e3c7d8:d5e2d146
   devices=/dev/sdc2
[root@ixus ~]#

    * Start the RAID array with a new metadevice ID (in the sample below it is renumbered from md2 to md3
:arrow: the "ARRAY" line only ends after the "missing" word.
Code: [Select]
[root@ixus ~]# cat >> /etc/mdadm.conf
DEVICE /dev/sdc2
ARRAY /dev/md3 level=raid1 num-devices=2 UUID=e8cd2148:6e9e3fb7:12e3c7d8:d5e2d146 devices=/dev/sdc2,missing
[root@ixus ~]#
[root@ixus ~]# mdadm -A --scan /dev/md3
mdadm: only specify super-minor once, super-minor=2 ignored.
mdadm: only specify super-minor once, super-minor=1 ignored.
mdadm: /dev/md3 has been started with 1 drive (out of 2).
[root@ixus ~]#

    * Retrieve the source VG definition
Code: [Select]
[root@ixus ~]# dd if=/dev/md3 bs=512 count=255 skip=1 of=/tmp/header_md3
255+0 records in
255+0 records out
[root@ixus ~]#

The resulting file is made of text and binaries informations. This part of the disk is used in a cyclic way so you might find more than once the informations. Check "man lvm.conf" for more details.
You have to edit this file and only keep the required informations to fill up the gaps in the below template :
Code: [Select]
main_1 { ...
        physical_volumes { ...
                pv0 { ...
        }
        logical_volumes { ...
                root { ...
                        segment1 { ...
                                stripes = [ ...
                        }
                }
                swap { ...
                        segment1 { ...
                                stripes = [ ...
                        }
                }
        }
}

Check the way the file has to look like with the /etc/lvm/backup/main one for instance. Double, triple check the syntax.
Do not forget to change the volume label. I change it from main to main_1 in the above sample.

    * Add the  VG definition to your new system
Code: [Select]
[root@ixus ~]# vgcfgrestore -f /tmp/header_md3 main_1
  Restored volume group main_1
[root@ixus ~]#
[root@ixus ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "main_1" using metadata type lvm2
  Found volume group "main" using metadata type lvm2
[root@ixus ~]#
[root@ixus ~]# vgchange -a y main_1
  2 logical volume(s) in volume group "main_1" now active
[root@ixus ~]#
[root@ixus ~]# mount /dev/main_1/root /mnt


    * that's all :P

The above informations are freely adapted from Richard Bullington-McGuire's article in the Linux Journal.

You are working with low level informations, so really think and care about what you are doing.

Gaston

Offline slords

  • ****
  • 235
  • +3/-0
how to attach usb drive
« Reply #17 on: January 27, 2007, 04:10:13 AM »
There is a slightly less dangerous way to do the above is to use the following commands.  It doesn't involve editing sectors or force restoring anything.  It also does its best to check things before changes so as to not kill the live system.

mdadm -AR /dev/md5 /dev/{device}
vgs -v (list all volume groups with uuid)
vgchange -a n {uuid of vg}
vgrename {uuid of vg} {new name}
pvs (ensure you renamed the one on md5)

If you are running a live system then if the vgchange command fails then you tried to stop the one your system is running from.  Try it with the other one.

After doing the above then you should be able to activate all volume groups (or reboot) and start mounting the logical volumes.

During these commands you will get warnings about duplicate volume groups with same name.  DUH!!  That is what we are trying to fix here.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs,
and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." -- Rich Cook

Offline ldkeen

  • *
  • 403
  • +0/-0
how to attach usb drive
« Reply #18 on: February 21, 2007, 11:37:50 AM »
Quote from: "slords"
mdadm -AR /dev/md5 /dev/{device}
vgs -v (list all volume groups with uuid)
vgchange -a n {uuid of vg}
vgrename {uuid of vg} {new name}
pvs (ensure you renamed the one on md5)

Shad,
We tried the above procedure today but couldn't get it to work. Here's what we tried:
Booted from a clean installed smeserver 7.1 with a single SCSI HDD (/dev/sda) then attached our old smeserver 7.0 drive to the server via a USB caddy (shows as /dev/sdb).
Code: [Select]
#mdadm -AR /dev/md5 /dev/sdb2
mdadm: /dev/md5 has been started with 1 drive (out of 2)

Code: [Select]
#vgs -v
This step does not show the old volume group - it only shows the current volume group. So we ran vgscan prior to running vgs -v:
Code: [Select]
#vgscan
which finds the old volume group and now "vgs -v" shows both the volume groups with uuid's.
Now we run the following command:
Code: [Select]
#vgchange -a n {uuid of /dev/md5 as listed above}
but get the following error: Volume group "uuid as above" not found. I have checked and double checked and triple checked the uuid of the old disk and I'm sure there are no typo's but keep getting the above error. Here is the procedure we ended up using to mount the old disk (almost identical to yours except we had to boot from the CD):
Boot from SME Server 7.1 install CD
press F5
type "sme rescue" at the command prompt and hit enter
Note: don't start the network and skip mounting the filesystem.
Code: [Select]
#mdadm -AR /dev/md5 /dev/sdb2
#lvm vgscan
#lvm vgs -v
#lvm vgchange -a n
#lvm vgrename orig_vg_name new_vg_name
#exit

Now remove the CD and reboot
Code: [Select]
#mdadm -AR /dev/md5 /dev/sdb2
#vgscan
#vgchange -a y new_vg_name
#mkdir /mnt/tmp
#mount /dev/new_vg_name/root /mnt/tmp

Regards, Lloyd & David