LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   copy single hard drive install to a raid 0 array (https://www.linuxquestions.org/questions/linux-software-2/copy-single-hard-drive-install-to-a-raid-0-array-654452/)

pepsimachine15 07-08-2008 09:08 PM

copy single hard drive install to a raid 0 array
 
I currently have pclinuxos2007 installed on a 20 gig IDE drive. I also have two WD raptor sata drives in raid 0, with windows xp installed.

I've been dual booting linux/windows by means of going into the bios and changing my HD boot order. ghetto, i know, but i hardly use windows anymore. And since i really have no reason to use windows anymore, i'd like to use my raptors for my linux install.

So i'd like to wipe the two WD raptor drives, and copy over my linux partitions from my 20 gig ide to the Raid 0 array.

I've already got device mapper installed on my system, and I can mount the windows partition. But i'm pretty sure this isnt going to be as simple as formatting the /dev/mapper/nvraid device, copying the partitions over, and removing the 20 gig drive, is it? Don't I need something specific for grub to be able to read the raid array?

mostlyharmless 07-09-2008 11:20 AM

Raid 0 Linux install
 
Hi, hope I can help. I have a similar setup in slackware and have found the following thread to be very helpful:

http://www.linuxquestions.org/questi...k-12.0-586440/

Sorry though, I don't know how well pclinux2007 automates the process. There are numerous threads on howto do this for ubuntu and gentoo which you can probably find as well, such as:

http://www.linuxquestions.org/questi...ows-xp-409595/

and

http://gentoo-wiki.com/HOWTO_Install...D_using_dmraid

which are helpful..

GRUB 0.97 can certainly boot from the raid 0 device, as it uses BIOS; there is a dmraid patch you may need to use.

pepsimachine15 07-10-2008 08:55 PM

The first link deals with a slackware install, but i'm sure i can use the information. it also seems the most informative on what needs to be done, but it is quite confusing.

all three links deal with a brand new fresh install. but it seems the key is dmraid which I already have installed and enabled. I dont know if its compiled into the kernel though... is there a way to check this?

also... i have a question on what the major and minor numbers of my drives are and how to find them.

mostlyharmless 07-10-2008 11:57 PM

I think the Slackware thread is the most easily applicable, although you have to read through the whole thing and pick out the parts you need. You can certainly migrate over your system to the raid 0 system using rsync without a reinstall.

If I recall, after going to init 1, you can "rsync -avH -x /mnt/raid0 (or wherever) to /mnt/raid0" Or you can do a new install to the raid 0 and migrate things over afterwards.

Some of the last posts in the thread give a pretty good step by step process of using the system. If you already have a built system and are migrating you can skip a bunch of steps. Have a backup, as it's quite likely it won't work the first time!

dmraid isn't compiled into the kernel; you need an initrd (really it's an initramfs these days) Once you run dmraid -ay, it'll give you the name of your array. You can use dmraid -s to see it. man dmraid is helpful. In the example from the slackware thread it was "pdc_bbbffffihj" or "nvidia_bhfdead" I doubt that you'll need a kernel recompile. If you already have an initrd, it'll be easiset if you modify it.

To get the major and minor numbers type
ls -l /dev/mapper/*. (Post #21 in the thread)
The first number is the major, the next the minor. Typically like 253, 0 for the disk, 253, 1 for the first partition and so forth.

So, run dmraid, mount the disk, install the system or migrate it over. It is as simple as that But then build an initrd. Grub can read the raid 0 without any help actually, and therefore can read the kernel and initrd files, the initrd runs dmraid so that the kernel can read the raid 0 root filesystem and off you go. To verify that grub can see your raid 0, type root ( and use the tab at the grub prompt. You should see the original 20 gig disk and your raid array, not its components. You might have to use a boot grub disk to get that to work rather than usng grub within your running system.

pepsimachine15 07-11-2008 05:27 PM

A couple of things -

I've already got the system installed and configured the way i want it, so i definatly want to do a migration with rsync, or possibly with some backup software I use off a live cd. The backup software I use off my boot cd can do RAW data copy, to basically clone a drive, so I think that is what i'll try first. I just need to make sure my boot cd can recognize my raid 0, or i'll need to do it the rsync way, which ive never done.

As for the initrd and dmraid - I know I already have dmraid installed, and it is active at boot. When I first installed pclinuxos I never had to touch anything with it to recognize the disks and create a /dev/mapper/myraidname file, it did it all on its own. from what I understand, the initrd basically creates a ramdisk and moves dmraid there to run, to recognize the array, correct? if this is so, is the initrd only used if the raid array is the root partition? my root partition now is on a single ide drive, so dmraid is not needed to access the root fs, but when I migrate over, the root partition will be on the raid array, so I will need the initrd to load dmraid. basically my question is, how can I tell if I have an initrd set up, or will I need to do this before I migrate to the raid? also, I will need to make changes in various places in the system, such as fstab, where my root partition is /dev/hdb1, it will need to be changed to /dev/mapper/myraidname, or as stated in the links you posted, it can be sort of mapped to something like /dev/sdr1 to make things less complicated.

using a grub boot disk will be difficult, because i do not have a floppy drive in this machine. the only floppy drive i own is in my laptop and i dont know if it works, ive never used it. i dont have any floppy disks either. is there a grub boot cd?

mostlyharmless 07-13-2008 11:21 AM

Sounds like you're almost there
 
Quote:

from what I understand, the initrd basically creates a ramdisk and moves dmraid there to run, to recognize the array, correct? if this is so, is the initrd only used if the raid array is the root partition?
Basically, yes, the initrd (it is actually an initramfs for kernel 2.6) sets up a filesystem for the kernel to run dmraid in order to recognize the firmware raid 0. You can use an initrd for a number of things. If your kernel doesn't have support for your root filesystem or some of your hardware required at boot time, you can use an initrd to load the modular support prior to mounting the root filesystem.
Quote:

basically my question is, how can I tell if I have an initrd set up, or will I need to do this before I migrate to the raid?
There has to be a file in /boot or somewhere called initrd.gz or initramfs.gz or something like that which is explicitly called by grub; e.g. somewhere in your /boot/grub/menu.lst file will appear something like:
Code:

...
kernel /boot/vmlinuz
initrd /boot/initrd.gz
....

Each distro has its own way of generating or modifying an initramfs/initrd. Inside the filesystem for the initramfs (in slackware found in /boot/initrd-tree) there's a shell script called "init". You need to add the command "dmraid -ay" to the shell script, add the dmraid executables and librairies to the initrd-tree, rebuild the initrd.gz and call it with grub.
Quote:

also, I will need to make changes in various places in the system, such as fstab, where my root partition is /dev/hdb1, it will need to be changed to /dev/mapper/myraidname, or as stated in the links you posted, it can be sort of mapped to something like /dev/sdr1 to make things less complicated.
Exactly! In my setup, I actually have the dmraid raid 0 as part of an mdadm raid 1 array, so that my root is /dev/md0. In my initrd I run mdadm to assemble my raid 1 array AFTER I run dmraid -ay to assemble the raid 0 part of it. Using a device like /dev/sdr isn't necessary, but some shell scripts can get confused about the location of the dmraid devices when the system switches over from the initrd filesystem to the root filesystem.
Quote:

using a grub boot disk will be difficult, because i do not have a floppy drive in this machine. the only floppy drive i own is in my laptop and i dont know if it works, ive never used it. i dont have any floppy disks either. is there a grub boot cd?
Am I the only person left with a floppy disk? *sigh* Yes, I've never used it but I've read about a CD version, which everyone seems to like called the Super Grub Disk
http://www.supergrubdisk.org/

pepsimachine15 07-13-2008 03:53 PM

Thanks for your help mostlyharmless, i'm getting a very good understanding of how the boot process works now.

I'm considering using a knoppix boot disk to resize my NTFS partition as to be able to keep windows for dual boot, since I still havent been able to get a select few things running in linux that I had in windows, mainly call of duty 4 and battlefield 2. i've been able to get cod4 to run in single player, but there is a bug with the punkbuster software that will not allow me to join any punkbuster enabled servers in multiplayer. same goes for bf2. seeing as how that is a $100 investment in games, i'd like to still have the ability to play them every once in a while.

so after I am done resizing my windows partition down to 20 or so gigs, i'll still have another 50 gigs left over for my main OS (pclinuxos). right now i have a 2 gig swap partition and a 16-17gig / . is it easy to resize my root partition to fill up the entire 50 gigs after I migrate everything over? or would I be better off doing a fresh install and format the 50 gigs, and then migrate the files over? whichever would be less problematic would be the route i'd like to go, since it seems no matter what I ever do in linux I always run into at least one problem in doing it.

mostlyharmless 07-14-2008 10:46 AM

resizing
 
You're welcome, pepsimachine15. There are a few things which just won't run well under linux, unfortunately, which is why I dual boot as well.

Quote:

is it easy to resize my root partition to fill up the entire 50 gigs after I migrate everything over? or would I be better off doing a fresh install and format the 50 gigs, and then migrate the files over?
I think it is less problematic to do a fresh install if possible. But there are some advantages to migrating, although it might be more trouble: (1) You could use this as an opportunity to check your backup and restore method. (2) You could use this as an opportunity to learn more about rsync.

Quote:

since it seems no matter what I ever do in linux I always run into at least one problem in doing it.
As they say, problems are opportunities. You'll probably learn something if you do it the hard way...

pepsimachine15 07-14-2008 07:59 PM

Okay - I did end up using rsync, because my boot cd did not recognize my raid (i could have remastered the cd with the drivers, but i didnt feel like it). The rsync method worked quite well, actually.

http://www.linuxquestions.org/questi...20#post3041320
I'm stuck at the steps 12-13 area... Im not sure if i created the udev rules correctly, so i'll post what I have. Also, I cannot find which "init" file to modify for step 13. I've looked at all the files i could under /boot/ and I dont have anything even remotly similar to the file that guy has. could this be because i didnt install/compile grub sources?

Here's my udev rules I created. the first line I created long ago when setting up my ventrilo hotkey, so i didnt touch it. the second two are the entries for my hard disk paritions.
---------------------------------------
KERNEL=="event[0]", NAME="input/%k", GROUP="ventrilo", MODE="0660"
KERNEL=="dm-2", NAME="sdr2"
KERNEL=="dm-3", NAME="sdr3"
---------------------------------------
does the above look correct? I was guessing.

Heres my /boot and /boot/grub... which file is the "init" that i need to modify to build a new image?
----------------------------------------------------
[root@pc /]# ls -al /boot
total 3600
drwxr-xr-x 3 root root 4096 Jul 13 23:30 ./
drwxr-xr-x 20 root root 4096 Jul 13 23:30 ../
lrwxrwxrwx 1 root root 20 Jul 13 23:45 config -> config-2.6.18.8.tex5
-rw-r--r-- 1 root root 74282 May 9 2007 config-2.6.18.8.tex5
drwxr-xr-x 2 root root 4096 Jun 24 01:59 grub/
-rw-r--r-- 1 root root 651177 Jun 24 01:58 initrd-2.6.18.8.tex5.img
lrwxrwxrwx 1 root root 24 Jul 13 23:45 initrd.img -> initrd-2.6.18.8.tex5.img
lrwxrwxrwx 1 root root 28 Jul 13 23:45 kernel.h -> /boot/kernel.h-2.6.18.8.tex5
-rw-r--r-- 1 root root 1493 May 10 2007 kernel.h-2.6.18.8.tex5
-rw-r--r-- 1 root root 94600 Nov 8 2006 memtest-1.65.bin
-rw-r--r-- 1 root root 470820 Jun 24 01:58 message-graphic
lrwxrwxrwx 1 root root 24 Jul 13 23:45 System.map -> System.map-2.6.18.8.tex5
-rw-r--r-- 1 root root 755333 May 9 2007 System.map-2.6.18.8.tex5
-rw-r--r-- 1 root root 256 Jun 24 01:59 us.klt
lrwxrwxrwx 1 root root 21 Jul 13 23:45 vmlinuz -> vmlinuz-2.6.18.8.tex5
-rw-r--r-- 1 root root 1582984 May 9 2007 vmlinuz-2.6.18.8.tex5
----------------------------------------------------
[root@pc /]# ls -al /boot/grub
total 336
drwxr-xr-x 2 root root 4096 Jun 24 01:59 ./
drwxr-xr-x 3 root root 4096 Jul 13 23:30 ../
-rw-r--r-- 1 root root 49 Jun 24 01:59 device.map
-rw-r--r-- 1 root root 30 Jan 18 2007 device.map.backup
-rw-r--r-- 1 root root 45 May 10 2007 device.map.old
-rw-r--r-- 1 root root 7424 Jun 24 01:59 e2fs_stage1_5
-rw-r--r-- 1 root root 7296 Jun 24 01:59 fat_stage1_5
-rw-r--r-- 1 root root 6592 Jun 24 01:59 ffs_stage1_5
-rwxr-xr-x 1 root root 115 Jun 24 01:59 install.sh*
-rwxr-xr-x 1 root root 115 May 10 2007 install.sh.old*
-rw-r--r-- 1 root root 8128 Jun 24 01:59 iso9660_stage1_5
-rw-r--r-- 1 root root 8032 Jun 24 01:59 jfs_stage1_5
-rw-r--r-- 1 root root 410 Jun 24 01:59 menu.lst
-rw-r--r-- 1 root root 6720 Jun 24 01:59 minix_stage1_5
-rw-r--r-- 1 root root 9056 Jun 24 01:59 reiserfs_stage1_5
-rw-r--r-- 1 root root 3576 Jun 24 01:58 splash.xpm.gz
-rw-r--r-- 1 root root 512 Jun 24 01:59 stage1
-rw-r--r-- 1 root root 100522 Jun 24 01:59 stage2
-rw-r--r-- 1 root root 102058 Dec 19 2006 stage2_eltorito
-rw-r--r-- 1 root root 6944 Jun 24 01:59 ufs2_stage1_5
-rw-r--r-- 1 root root 6144 Jun 24 01:59 vstafs_stage1_5
-rw-r--r-- 1 root root 8776 Jun 24 01:59 xfs_stage1_5
----------------------------------------------------

I know i need to edit the device.map later on, but I havent gotten that far yet. I need to build my new initrd image with dmraid included.

mostlyharmless 07-15-2008 11:51 AM

It's not because you didn't compile grub. It's the distro difference.

That file system image link:
lrwxrwxrwx 1 root root 24 Jul 13 23:45 initrd.img -> initrd-2.6.18.8.tex5.img
contains the file "init". You have to find out how pclinux2007 generates its initrd file.

In slackware there is a command "mkinitrd" which sets up the initial filesystem and places it in /boot/initrd-tree, where you can easily modify it. However, there is a way to mount any initrd using mount -o loop for modification, but I'll have to look up how that works exactly, don't recall off the top of my head.

Check out:

http://www.pclinuxos.com/index.php?o...action=search2

The udev rules look good, but do "dm-2 and dm-3", sdr2 and sdr3 correspond to the dmraid partitions? Easy to check. Mount /dev/sdr2 and verify what's there, same with /dev/sdr3.

mostlyharmless 07-15-2008 04:45 PM

initrd-tree for pclinux2007
 
Looks like PCLinux2007 has the mkinitrd script according to the PCLinux forum link above; you'll have to read the man and look at the script, since it is almost certainly different from the slackware version I'm more familiar with. You can probably modify it or use an option to add dmraid automagically. OR you could mod your exitsing initrd manually the slackware way.

I was looking around and think I found the code I was looking for in this thread:
http://www.linuxquestions.org/questi...cpio+initramfs
in #36

To unpack your initrd:

Code:

cd /boot
mv initrd.gz initrd.gz.old
mkdir /boot/initrd-tree
cd /boot/initrd-tree
gunzip -c ../initrd.gz.old > initrd
cpio -vid < initrd
rm initrd

Add the dmraid files to /boot/initrd-tree/sbin and the command dmraid -ay to the init at this point according to the other thread, then goto the next code:

To remake initrd and clean up the initrd-tree if desired:
Code:

find | cpio -o -H newc | gzip -9 > ../initrd.gz
cd /boot; rm -fr /boot/initrd-tree

Hope that helps!

pepsimachine15 07-15-2008 08:57 PM

the command mkinitrd also exists in my distro. so you're saying i need to use mkinitrd to generate the init file for editing? how do i convert it back to the .img file for booting then?

http://www.linuxquestions.org/questi...67#post3040067
halfway down that post he talks about using mkinitrd, but mine doesnt seem to operate the same... mkinitrd with no options or parameters brings up the --help for usage of mkinitrd.

i dont know what dm-2 and dm-3 are, but i do know /dev/sdr2 is my linux root and /dev/sdr3 is my linux swap. i didnt create a /dev/sdr1 yet, that is my windows partition. i will probably need to create /dev/sdr1 when i need to edit my device.map to add a dual boot to windows.

mostlyharmless 07-16-2008 10:59 AM

Clarification
 
Hmm, I don't know accurate the timestamps are on these postings; looks like I answered some questions before you posted them! Or maybe I wasn't clear :)
Quote:

the command mkinitrd also exists in my distro. so you're saying i need to use mkinitrd to generate the init file for editing? how do i convert it back to the .img file for booting then?
Yes, see my remarks above. The commands given should allow you to use mkinitrd to make a new initrd.img. PCLinux calls it initrd.img not initrd.gz (as slackware does)

You *might* be able to just use your distro's mkinitrd command to include dmraid without any further modifications, although slackware's "mkinitrd" doesn't have that capability. mkinitrd is typically a shell script which is different in different distros. OR you can use your existing initrd.img and use the instructions above to unpack it, modify the "init" file, add the dmraid files and rebuild it. Hope that's clearer.
Quote:

i dont know what dm-2 and dm-3 are
When the device mapper assigns devices, it names them dm-1, dm-2 etc. If dmraid is the program to call on device mapper, then it will get the low numbers. If you use another program, say to encrypt your filesystem using the device mapper, it will also get dm-# names. The names can get reassigned if you add a new program ahead of the old ones. So if you configure your system with dmraid, then add root filesystem encryption using device mapper afterwards, you might need to change the udev rules to reflect the new dm-#'s.

pepsimachine15 07-17-2008 06:59 PM

ah, yes, that is a bit clearer. I figured i was missing something, since every other .img file in my /boot dir had a corresponding tex5 file with it, and only my initrd.img file didnt. I didnt know mkinitrd was used to unpack the image file as well, i thought it was only used to create it. i guess in my head i was comparing mkinitrd to something like a C compiler, rather than of something like gzip, for both packing and unpacking. I'll see if im able to automagically insert dmraid into my image as you said. if not i'll unpack it and do it the manual way.


i think dmraid is the only thing on my system that would be using device mapper. and my /dev/map partition looks like:

control
nvidia_ecccjggb
nvidia_ecccjggb1
nvidia_ecccjggb2
nvidia_ecccjggb3

so dm-2 and dm-3 should correspond to the correct partitions, right? ive got /dev/sdr 1 2 and 3 mapped to /dev/mapper/nvidia_ecccjggb 1 2 and 3 respectivly.

the timestamps are probably right. its more likely i read your post directly after mine and left the browser window open for 4 or 5 hours until i got back to my computer to write a reply, just forgot to hit refresh to check for new posts before i replied. lately thats the way the computers have been with me... 5 minute periods at the pc whenever i get some spare time.

pepsimachine15 07-19-2008 08:01 PM

ive been fooling with this for days now off and on still unable to get it to work.

ive managed to decompress my initrd.img, although i had to use mkinitrd first to create a brand new image for me to decompress. the default one didnt have an "init" file.

so I edited my init file - it does not look like the example one in the other post but it seems like where it should go. i copied dmraid to the /boot/initrd-tree/sbin folder (symlink to bin folder) and the libdevmapper.so.1.02 to the /boot/initrd-tree/lib folder. rebuilt my initrd.img file and copied back over to /boot, replacing the old one.

I booted off the supergrubcd i downloaded and installed grub to the mbr of my raid 0. i can now access the grub boot menu when I boot off the raid. i have 3 entires: pclinuxos (new raid install), windows x64, and pclinuxos 20 gig drive (old install). the latter two work, while pclinuxos still will not boot from the raid.

i removed my bootsplash from the decompressed initrd and rebuilt it, to see what was going on. I'm getting a kernel panic error, locking up the system. above it, i notice dmraid returns an error, its something to the tune of "failed in exec on /bin/dmraid". there are also a lot of other unable to mount errors while its trying to mount /dev and /proc and /sys, and others.

I've tried a few different options in my grub menu.list. I first had my root=/dev/sdr2, but i also tried /dev/mapper/nvidia_ecccjggb2 with no luck. I also tried root=/dev/ram0 and the option "dodmraid" as i had seen in another post of someone using dmraid, but none of that made any difference in the kernel panic.


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