|
From: Heiko Z. <hz...@pr...> - 2002-05-15 14:01:36
|
----- Forwarded by Heiko Zuerker/ITS/Propack Data Corporation on 05/15/= 2002 09:58 AM ----- |---------+-----------------------------------------------> | | "Walter Haidinger" | | | <wal...@gm...> | | | Sent by: | | | dev...@li...| | | ceforge.net | | | | | | | | | 05/15/2002 06:24 AM | | | | |---------+-----------------------------------------------> >--------------------------------------------------------------------= -----------------------------------------------------------------------= ---| | = = | | To: <dev...@li...> = = | | cc: (bcc: Heiko Zuerker/ITS/Propack Data Corporation) = = | | Subject: [Devil-Linux-discuss] Hack to install onto harddisk= instead of memory (low memory solution) = | >--------------------------------------------------------------------= -----------------------------------------------------------------------= ---| Hi! I've successfully installed Devil-Linux this weekend on an old machine (486/66) with just 24 MB of RAM. I think that even 16 MB would be sufficient. However, in order to do that I had to make Devil-Linux boot onto a harddisk partition instead of a ramdisk. I was forced to do this because _both_ of my 32MB SIMMs turned out to be defective... :-( Well, here's what I did. Perhaps it helps somebody who has a similar problem. How about adding a docs section like "installing Devil-Linux on machines with less than 64 MB RAM" ? This may have been done already but I didn't search the mailing-list archives when I did it because I had no internet access at that time. Anyways, here goes: With my setup, I used three partitions (on an old 200+ MB IDE drive): * /dev/hda1 - DOS (C:), about 50 MB Required because that old machine could not boot from CD-Rom and if I have to use a harddisk anyways we can as well use it for booting to= o. Please note that the floppy containing the config is still required any may have to configure the BIOS to boot from HD first. * /dev/hda2 - Linux SWAP, 64 MB I have free disk space so why not extend the already limited physical= memory and set up a swap partition? * /dev/hda3 - Linux ext2, about 100 MB Used as subsitute for the ramdisk. I've hacked the initrd to use this partition instead of /dev/shm (see below). After setting up a DOS partition to boot from (C:), I copied the boot directory from the CD (to C:\boot). Next, I had to modify to linuxrc script of initrd.gz. To do this, follow these steps (under Linux): 1. Copy the initrd.gz from the CD-Rom somewhere, e.g. > cp /cdrom/boot/initrd.gz /tmp 2. Unpack it > gunzip /tmp/initrd.gz 3. Mount the file using the loopback-device: > mount /tmp/initrd -o rw,loop=3D/dev/loop0 /mnt 4. Modify /mnt/linuxrc with your favourite editor according to the next section below. > your-editor /mnt/linuxrc 5. Copy your /sbin/swapon and /sbin/mkswap files to /mnt/sbin Make sure that the binaries run on your Devil-Linux Version. For me, binaries from SuSE-Linux 7.3 run on Devil-Linux 0.5. 6. Unmount again > umount /mnt 7. Pack the modified image > gzip initrd 8. Copy the new initrd.gz to the boot directory of the DOS partition (C:\boot) Now for the fun part: Howto modify linuxrc (I've modifed linuxrc v1.7 from the 0.5rc1 distribution) Here are the diffs in detail: 28a29,32 > SWAP_PART=3D/dev/hda2 > echo "Adding swapspace on $SWAP_PART" > /sbin/swapon $SWAP_PART && print_status success || print_status failu= re > Add the swap partition. You might add a /sbin/mkswap $SWAP_PART right before swapon but I doubt that this is necessary. Well, of course you need to create the swap-space _once_ ! 31a36,43 > DATA_PART=3D/dev/hda3 > echo "Using $DATA_PART as ramdisk substitute:" > test -d /hd || mkdir /hd > echo -n "Creating ext2 filesystem on $DATA_PART" > /sbin/mke2fs -q $DATA_PART print_status success || print_status failu= re > echo -n "Mounting $DATA_PART" > mount -t ext2 -o rw $DATA_PART /hd && print_status success || > print_status failure> Use partition set by DATA_PART as the ramdisk substitute. First create a mountpoint, then create the filesystem and mount it. *** WARNING: The partition is created _without_ question! Any previously stored data is lost! Actually, that is a good thing as it really simulates ramdisk behaviour and is therefore a security benefit. Also, you can simply turn off the machine without shutting down which is good if you have users power on/off the router without further knowledge.However, it can be *very* disastrous if you edit your partiti= on table and forget to assign the correct partition in DATA_PART. 33,35c45,49 < test -d /dev/shm || mkdir /dev/shm < echo -n "Mounting SHM FS on /dev/shm" < mount -t shm -o size=3D40g shmfs /dev/shm && print_status success || print_status failure--- > #test -d /dev/shm || mkdir /dev/shm > #echo -n "Mounting SHM FS on /dev/shm" > #mount -t shm -o size=3D40g shmfs /dev/shm && print_status success ||= > print_status failure> rm -rf /dev/shm > /dev/null 2>&1 > ln -s /hd /dev/shm 39c53,54 < ln -s /dev/shm /ram --- > #ln -s /dev/shm /ram > ln -s /hd /ram Remove (comment) the shared memory stuff and replace it by symlinks. This allows transparent usage of the partition instead of /dev/shm, i.e. not subsequent scripts need to be modified. That are all changes made to linuxrc. I've attached a context diff with the changes. To apply it, run (replacing step 4 above) in /mnt after saving the attachment (to, say, /tmp): patch < ../tmp/linuxrc.diff *** Security warning: If you store the boot files (kernel, initrd, ...) on the harddisk (i.e. if you do _not_ create a CD containing the new initrd.gz), that files _can_ be modified.Therefore, the integrity of the boot files _hav= e_ to be verified! e.g.: Use MD5 hashes! 1. Get md5sum.exe for DOS from http://etree.org/md5com.html and put it on your config floppy. 2. Create md5 checksums for all files that are on the harddisk, e.g. (write on one line): md5sum.exe C:\boot\initrd.gz C:\boot\loadlin.exe C:\boot\vmlinuz > A:\boot.md5 3. In autoexec.bat of your boot floppy, add the following 2 lines: md5sum -vc boot.md5 if errorlevel 1 exit 4. Don't forget to write-protect your floppy again! Now, if anyone modifies the files on the harddisk, md5sum fails the check and the autoexec.bat is aborted. That's finally it! I just hope that I forgot nothing as I wrote this mostly from memory... Anyways, comments *are* welcome! Regards, Walter PS: Yes, I know this is a (bad) hack and there are better ways (that is, more configurable) to do this. However, I had to get the system up and that is what did it. You're free to do it any other way you desire! ;-) -- Walter Haidinger <wal...@gm...> For contact information or PGP/GPG public key please refer to http://haidinger.webhop.org/contact.html (See attached file: linuxrc.diff) = |