Koozali.org: home of the SME Server

Obsolete Releases => SME Server 7.x => Topic started by: TaNk on August 31, 2006, 08:49:02 AM

Title: how to attach usb drive
Post by: TaNk on August 31, 2006, 08:49:02 AM
hey gang,

            here's my setup.

Standlone file server only
30gb hd runing sme

and now i just added 300gb usb maxtor drive. i ssh into the box and config the usb hd now it show's if i run the command df -k

[root@server /]# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/main-root
                      28866684   2273996  25126320   9% /
/dev/md1                101018     18750     77052  20% /boot
none                    126988         0    126988   0% /dev/shm
/dev/sda1            245051840        32 245051808   1% /mnt/usbdrive

but now my qes is.

1) how can i save stuff to this drive, since it dosn't show up in gui. i tryed to save some big file and it still save's in /dev/md1.

2)every time i boot usbhd is gone i have to mount it again, is it possible to edit a config where it mount it self on boot.

please help a n00bie

Thanks alot
TaNk
Title: how to attach usb drive
Post by: Jean-Philippe Pialasse on August 31, 2006, 10:19:04 AM
SME 7 is configured to auto mount USB drive when you plug it or when you reboot the SME to :
/media/usbdisk
then  if there's more than one partition on it or if you plug a second one
/media/usbdisk1
etc.


TH eway you can do is to do a symling in your ibay folder and create a folder with good right on you usb disk.

Another way would be to modify the script which auto mount or using udev to mount one usb disk (thanks to it's serial number to a different location like an ibay)

Thanks to developpers to tell us what is the script which is in charge of mount this drive.

I am actually searching for it to try theses modifications.
Title: how to attach usb drive
Post by: TaNk on August 31, 2006, 08:29:02 PM
thanks for reply "unnilennium"

but when i make ibay account it still save's stuff in my / folder.

also when i reboot it dosn't mount usbdisk in /media

thanks
Title: how to attach usb drive
Post by: TaNk on August 31, 2006, 09:46:18 PM
ok now i got it to mount on reboot but still when i connect a network drive thro xp and share my \\server\usbdisk folder and save some stuff it still goes to my / folder.

i did make and ibay account and put it in as usbdisk just like it say's in /media/usbdisk

thanks
Title: how to attach usb drive
Post by: Jean-Philippe Pialasse on August 31, 2006, 09:54:35 PM
didi you make an entry in fstab to mount /media/"usbdisk" to /home/e-smith/files/ibays/"myibay"/files

that's what i suggested
Title: how to attach usb drive
Post by: TaNk on August 31, 2006, 10:00:34 PM
thnx for quick reply again. im a pure n00b @ linux  :hammer:  just in learning process can you please tell me how can i make the entry.

ie:- if you can give me the commands.

Thanks alot
Title: how to attach usb drive
Post by: Jean-Philippe Pialasse on August 31, 2006, 11:31:44 PM
http://no.longer.valid/phpwiki/index.php/extra%20hard%20disk
Title: how to attach usb drive
Post by: TaNk on September 01, 2006, 10:25:13 PM
Quote from: "unnilennium"
http://no.longer.valid/phpwiki/index.php/extra%20hard%20disk


Hey unnilennium,

i tired that guide but when i get to step 6. i get few errors.

[root@server /]# mkdir /mnt/bigdisk
[root@server /]# pico /etc/fstab
[root@server /]# mount -a
[root@server /]# df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/mapper/main-root
              ext3    28866684   1306724  26093592   5% /
/dev/md1      ext3      101018     25203     70599  27% /boot
none         tmpfs      127584         0    127584   0% /dev/shm
/dev/sda1     ext3      247035      6176    228104   3% /mnt/bigdisk
[root@server /]# mkdir -p /mnt/bigdisk/ibays/mp3
[root@server /]#
[root@server /]# ls -l /home/e-smith/files/ibays
total 4
drwxr-xr-x  5 root root 4096 Aug 31 23:25 Primary
[root@server /]# chown admin:allstaff /mnt/bigdisk/ibays/mp3
chown: admin:allstaff': invalid group

please tell me if im doing somthing wrong.

Thanks
Title: how to attach usb drive
Post by: Jean-Philippe Pialasse on September 02, 2006, 12:08:16 AM
admin:allstaff was an example change it to the owner and group defined  to th eibay via the server manager.
 or you can check whose owner is for the folder thanks to midnight commender (mc)

JP
Title: how to attach usb drive
Post by: judgej on September 02, 2006, 07:14:17 PM
Quote from: "unnilennium"
didi you make an entry in fstab to mount /media/"usbdisk" to /home/e-smith/files/ibays/"myibay"/files

that's what i suggested


So what happens when fstab gets recreated by fstab-sync? Should the changes not be made in some templates somewhere in the HAL sub-system?

-- JJ
Title: how to attach usb drive
Post by: byte on September 02, 2006, 07:41:37 PM
Quote from: "judgej"
Quote from: "unnilennium"
didi you make an entry in fstab to mount /media/"usbdisk" to /home/e-smith/files/ibays/"myibay"/files

that's what i suggested


So what happens when fstab gets recreated by fstab-sync? Should the changes not be made in some templates somewhere in the HAL sub-system?

-- JJ


You can edit the fstab directly, thats the only rare file that doesn't need to be templated.
Title: how to attach usb drive
Post by: judgej on September 03, 2006, 12:50:14 AM
Quote from: "byte"
You can edit the fstab directly, thats the only rare file that doesn't need to be templated.


That's surprising to hear. The file I have, has warnings in it about fstab-sync overwriting it. I had the impression that the HAL daemon ran all the time, and updated fstabs whenever it detected a relevant change in the hardware. Or perhaps the HAL daemon is disabled in SME Server?

Updated: I see now that the entries added by fstab-sync have the option 'managed' on them. Without that option, they will not get touched by the fstab-sync.

I use entries such as this to auto-mount a disk with the label 'backup2' to the 'backup2' mount point:

LABEL=backup2 /media/backup2 ext3 auto,user,owner,pamconsole 0 0

It is handy being able to direct specific external disks to specific mount points like this. The same can be done using the serial number of the disks, but the labels are a bit easier to manage (i.e. I can apply the label to any other disk to have it mounted from there, but it is a bit more difficult to move serial numbers from one disk to another).

-- JJ
Title: how to attach usb drive
Post by: william_syd on October 31, 2006, 12:57:40 PM
I need some major help with this.

I've split a smeserver raid, taken the removed drive and placed a usb to ide adapter on it and plugged into another smeserver using a degraded raid array (single drive).

I wish to copy a few things that were once in the /home directory of the original smeserver.

The drive appears as sda1 and sda2.
Code: [Select]
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


I mounted /dev/sda1 fine and can see grub and the kernel images etc.

When I attempt to mount /dev/sda2 I get errors.
Code: [Select]
[root@c3 /]# mount -t ext3 /dev/sda2 /hd
mount: wrong fs type, bad option, bad superblock on /dev/sda2,
       or too many mounted file systems
[root@c3 /]#

Same command just changing /dev/sda1 to /dev/sda2 . I unmounted /dev/sda1 between attempts.

What am I doing wrong? Is it because the partion type is FD even though it did work for the first partition?

I also had the same results on a suse 10.1 laptop.
Title: how to attach usb drive
Post by: Gaston94 on November 01, 2006, 03:11:39 PM
Hi William,
the issue you encounter is just because you forgot your are dealing with a LVM2 based system. You have to address the correct structure ;)
(the /dev/sda1 == /boot partition is not under lvm that's why you where able to access)

You need to have an LVM2 capable system to access your data (most of the linux distribution and latest liveCD are now OK with that).

cross check you can see the partition and activate the partition
Code: [Select]
[root@centos ~]# pvscan
  PV /dev/md2    VG main         lvm2 [1.88 GB / 32.00 MB free]
  PV /dev/sda2   VG VolGroup00   lvm2 [1.69 GB / 0    free]
  PV /dev/sdc1   VG VolGroup00   lvm2 [992.00 MB / 0    free]
  Total: 3 [4.53 GB] / in use: 3 [4.53 GB] / in no VG: 0 [0   ]
[root@centos ~]# vgchange -ay main
  2 logical volume(s) in volume group "main" now active
[root@centos ~]# mount /dev/main/root /mnt/
[root@centos ~]# cat /mnt/etc/redhat-release
CentOS release 4.3 (Final) - SME Server 7.0
it's done ;)

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
Title: how to attach usb drive
Post by: william_syd on November 02, 2006, 07:57:47 AM
Quote from: "Gaston94"
Hi William,
the issue you encounter is just because you forgot your are dealing with a LVM2 based system. You have to address the correct structure ;)
(the /dev/sda1 == /boot partition is not under lvm that's why you where able to access)

You need to have an LVM2 capable system to access your data (most of the linux distribution and latest liveCD are now OK with that).

cross check you can see the partition and activate the partition
Code: [Select]
[root@centos ~]# pvscan
  PV /dev/md2    VG main         lvm2 [1.88 GB / 32.00 MB free]
  PV /dev/sda2   VG VolGroup00   lvm2 [1.69 GB / 0    free]
  PV /dev/sdc1   VG VolGroup00   lvm2 [992.00 MB / 0    free]
  Total: 3 [4.53 GB] / in use: 3 [4.53 GB] / in no VG: 0 [0   ]
[root@centos ~]# vgchange -ay main
  2 logical volume(s) in volume group "main" now active
[root@centos ~]# mount /dev/main/root /mnt/
[root@centos ~]# cat /mnt/etc/redhat-release
CentOS release 4.3 (Final) - SME Server 7.0
it's done ;)

Gaston


Thank you.
Title: how to attach usb drive
Post by: william_syd 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 ~]#
Title: how to attach usb drive
Post by: Gaston94 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 (http://www.linuxjournal.com/article/8874) in the Linux Journal.

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

Gaston
Title: how to attach usb drive
Post by: slords 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.
Title: how to attach usb drive
Post by: ldkeen 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