LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Create initrd (http://www.linuxquestions.org/questions/linux-software-2/create-initrd-573529/)

namit 07-30-2007 07:37 PM

Create initrd
 
Hey all

I am trying to setup a custom initrd that does a dd of /hda/sda2 to images.back files on a samba share or nfs share.

How do i go about creating this initrd image for pxe boot, have found some tutorials but they say create image dir and then copy files to directory then compress. But not sure what files i should have.

Does anyone know how can i do this?

Thanks

beatupbilly 07-31-2007 12:37 PM

Surely there is a way to automate that process?

namit 07-31-2007 03:29 PM

yes but my question is how

gd2shoe 07-31-2007 07:53 PM

I haven't played with initrd to a large extent, so take everything I say with a huge grain of salt.

I'll assume your system is Debian (as per your user profile).

Look into the initramfs-tools (example `man initramfs-tools` and '/etc/initramfs-tools'). These are supposed to be used to make creating an initrd file easier. On my Debian system, these are already installed.

On many systems, Debian for example, the initrd will initially mount the root file system in read only mode. In that state, you can access all kernel modules and programs (though you may need to specify a path to /bin/dd). Also, an image can be easily made because the file system is entirely untouched. One of the scripts will change the root file system to read/write at a later stage.

In order to take advantage of that, I would recommend adding a brief script to /etc/initramfs-tools/local-bottom/ to mount your smb share, copy the dump, and unmount the smb share. Create the initrd, put it in place, and cross your fingers.

Let us know what you settle with, please.

namit 08-01-2007 12:42 PM

Thanks gd2shoe

will mess with this over weekend and let you know in detail how i do it, i have also come across with http://unattended.sourceforge.net/ that seams to do some what what i want to do.

Have also been told that ntfs support for dd ing of an image is not very well supported.

My main thing is that i want to install 10 windows laptops with exact same image but do not want to use ghost.

Thanks and will let you know soon

namit 08-01-2007 06:43 PM

Hey gd2shoe

So been messing around with mkinitrd and have been able to create that but not sure what i should use for kernel

i have as following

LABEL test1
kernel ... not sure what to put here
append vga=normal initrd=testinit/initrd ramdisk_size=10938 root=/dev/ram0 devfs=mount,dall rw --
What kernel should i use?

I tried using my /boot/vmlinuz-2.6.18-4-686 but i get following

Target filesystem doesn't have /sbin/init
Busy box v1.1.3 (debian 1:1.1.3-4) Build in shell (ash)
Enter help for a list of built in commands

This would suggest that the init is not loading

Please help


Thanks

gd2shoe 08-01-2007 08:24 PM

Quote:

Originally Posted by namit
Thanks gd2shoe
...
Have also been told that ntfs support for dd ing of an image is not very well supported.

My main thing is that i want to install 10 windows laptops with exact same image but do not want to use ghost.

Thanks and will let you know soon

Whoa, whoa! Overkill!

I have used Linux for this purpose and can tell you that you do not need to go anywhere near initrd to do it.

Instead, you will want to get your hands on a live CD. Knoppix is the original live CD and is a Debian fork. I highly recommend it, as it is what I have used in the past. DSL (D*** Small Linux) is a Knoppix fork that is trimmed down to fit on the mini CD discs; it may also be a good choice for this adventure (though I haven't used it as such).

Before I talk about the clone, you may want to investigate sysprep. sysprep is a tool from Microsoft that prepares a system to be cloned. It is useful for several reasons. (1) There is a unique identifier in the registry for each system. You can run into networking problems if multiple system claim the same ID. (2) If the hardware is different, windows does not automatically redetect, and will probably lock up. (3) If the partition is larger/smaller on the destination, you will need to resize.

sysprep does not actually clone the drive, but it does address each of these issues. After sysprep is run, the system will be shutdown. On next boot, Windows will run a part of the windows installer to touch up the new installation (only takes a few minutes per system; the partition resize is not default, you will need to set that yourself).

Oops, I need to go now. I'll finish this at first chance.

gd2shoe 08-01-2007 09:18 PM

Sorry about that. (sysprep can be found on the windows CD, at least on the xp pro version.)

The Linux software tools that I recommend you learn about for this project are ntfsutils (specifically ntfsclone and ntfsresize), smbmount, and possibly gzip, dd, tee, mkfifo, and md5sum.

It is to be noted that ntfsclone works well for this, but they explicitly disclaim this use. There are situations where ntfsclone can give you problems. In my case, when cloning the first partition of a drive on one system to the second partition in another system. This results in a system that will not boot. I found a solution, but it doesn't sound like you will be doing that.

The basic idea is to mount the file share and use ntfsclone to make an image and save it there. Going the other direction is basically the reverse. When I've done it in the past, I've always piped the image through gzip (to compress it, for storage) and mk5sum (for verification).

Other recomendations:

Defragment the partition from windows first. A chkdsk also cannot hurt. If this is a fresh install on a full format, then never mind.

Use sysprep. It may add some headache at this stage, but it will remove headaches later.

When booting knoppix use "boot: knoppix 2 toram". The '2' means start in runlevel 2, command line only. Normally knoppix will start in runlevel 5, and start X with KDE. The 'toram' will load the entire knoppix image into memory. This makes loading knoppix take much longer, but run faster. It also allows you to use only one disk while restoring multiple systems simultaniously. It does require 1GB of ram (unless using DSL, it will boot much faster as it has a much smaller image, and only require 128MB I belive; remember "boot: dsl 2 toram")

pipe the image through gzip. This will cut down on the space required to store the image. If you don't intend to store it long, skip this step. I recommend gzip over bzip2 only because the former seems to be faster although the latter seems to compress better (ymmv).

use mkfifo and tee to pipe the image through md5sum both before and after it is gziped. Then when the image is restored, you can verify that the image was recovered from storage and transmitted properly. This isn't as hard as it might sound, but it involves named pipes which are not familiar to most people. These steps have added to my peace of mind.

If you need step by step instructions, let me know.

(It's not recommended, but if you are particularly daring, you could ignore the file server entirely and use named pipes, screen, and netcat to image them all from the original.)

namit 08-12-2007 05:50 PM

So the outcome of this is i have used ntfsclone and recovery cd to do the lot.

here is part of instructions
http://alma.ch/blogs/bahut/2005/04/c...ntfsclone.html

Then added script to iso of
http://www.sysresccd.org/Sysresccd-m...SystemRescueCd
to do the restore depending on the machine.

Next step is to put http://www.sysresccd.org/ onto pxe boot and get it all working that way, but this will only be with time.

Thanks a lot for the help


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