LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   partitions/making room for LFS (https://www.linuxquestions.org/questions/linux-from-scratch-13/partitions-making-room-for-lfs-216910/)

silverback011 08-12-2004 07:33 PM

partitions/making room for LFS
 
I know I am missing something basic here. I have a single hard drive.

On the first part of the hard drive I have M$ Win2k Pro. On the second half I have linux installed (Mandrake 10.0). I shrank the windows partition by 5GB to make room for the LFS project.

Then I run 'cfdisk' to partition it off. This renumbers my linux partitions. So I change my /etc/fstab to reflect the changes, but not adding the new 5GB portion, since it is not formatted yet. Then I changed the boot loader GRUB to look at the correct partition. When I reboot to make sure things are still good. I get an error message saying it can't find init on /dev/hda5. However with the modifications the unformatted partition I just made for LFS is now /dev/hda5. The changes I made to grub and my /etc/fstab say look at /dev/hda6.

So I remove the partition without changing anything else and linux boots up fine. That includes the numbers in GRUB and my /etc/fstab. I am confused as to why this is. I know I am missing something really basic here.

Output of fisk -l:

omitting empty partition (5)

Disk /dev/hda: 40.0 GB, 40020664320 bytes
16 heads, 63 sectors/track, 77545 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 30786 15516112+ 7 HPFS/NTFS
/dev/hda2 30787 77545 23566536 5 Extended
/dev/hda5 40945 53133 6143224+ 83 Linux
/dev/hda6 53134 54148 511528+ 82 Linux swap
/dev/hda7 54149 77545 11792056+ 83 Linux

Output of cat < /etc/fstab:

none /dev/pts devpts mode=0620 0 0
/dev/hda5 / ext2 defaults 1 1
/dev/hda6/ swap swap defaults 0 0
/dev/hda7 /home ext2 defaults 1 2
/dev/hdc /mnt/cdrom auto umask=0,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec 0 0
none /mnt/floppy supermount dev=/dev/fd0,fs=ext2:vfat,--,umask=0,iocharset=iso8859-1,sync,codepage=850 0 0
/dev/hda1 /mnt/windows ntfs umask=0,nls=iso8859-1,ro 0 0
none /proc proc defaults 0 0

osvaldomarques 08-12-2004 10:10 PM

Hi silverback011,
You need to do 2 changes in grub when you change the partition:
Code:

kernel (hd0,4)/boot/vmlinuz ro root=/dev/hda5
Did you do both?

osvaldomarques 08-12-2004 10:39 PM

It's me again!
I remembered one more trick. If you use "initrd", it will always mount "/dev/hda5" even if you make all the changes in grub. In this case you need to create another initrd containing the proper device and script to boot when the partition number changes.
I would suggest you the following steps before the boot trial:
- uncompress the initrd to a temp file, mount it and cd to it:
Code:

gunzip -c /boot/initrd-XXX >/tmp/initrd.tmp
mkdir /mnt/tmpinitrd
mount -o loop /tmp/initrd.tmp /mnt/tmpinitrd
cd /mnt/tmpinitrd

, where "/boot/initrd-XXX" is your real initrd.
- Edit the file "linuxrc", changing all partition references from "hda5" to "hda6".
- copy the "hda6" device to this image or create it:
Code:

cp -a /dev/hda6 /mnt/tmpinitrd/dev
- unmount it:
Code:

cd
umount /mnt/tmpinird

- compress it to create a new initrd
Code:

gzip -c /tmp/initrd.tmp >/boot/inirtd-hda6.img
Now, edit grub, creating a new kernel entry, pointing to hda6 and giving this inirtd.

silverback011 08-13-2004 07:24 PM

I thank you for the help. Everything you said makes sense to me except when I look at the 'linuxrc' file.

Output of cat < linuxrc:

#!/bin/nash

echo "Loading jbd.ko module"
insmod /lib/jbd.ko
echo "Loading ext3.ko module"
insmod /lib/ext3.ko
echo Mounting /proc filesystem
mount -t proc /proc /proc
echo Creating device files
mkdevices /dev
echo Mounting sysfs
mount -t sysfs none /sys
echo Creating root device
mkrootdev /dev/root
umount /sys
echo 0x0100 > /proc/sys/kernel/real-root-dev
echo Mounting root filesystem
mount -o defaults --ro -t ext3 /dev/root /sysroot
pivot_root /sysroot /sysroot/initrd
echo Remounting devfs at correct place if necessary
handledevfs
umount /initrd/proc

I don't see anywhere where it refers to /dev/hda#. I guess Mandrake cutomizes things quite a lot.

osvaldomarques 08-13-2004 09:06 PM

HI silverback011,
I'm doing some research since I received your post. Basically, your script does a lot of work to determine which is your root file system.
Quote:

mkdevices path
Creates device files for all of the block devices
listed in /proc/partitions in the directory spec-
fied by path.

mkrootdev path
Makes path a block inode for the device which
should be mounted as root. To determine this device
nash uses the device suggested by the root= kernel
command line argument (if root=LABEL is used
devices are probed to find one with that label).
If no root= argument is available, /proc/sys/ker-
nel/real-root-dev provides the device number.
So, at first glance, this script does not need to be modified. If you want to force "/dev/hda6", you need to replace "/dev/root" on the mount command with it. I found some links which may help you on your chalenge: initrd is a initrd manual and The Answer Gang has a discussion on a problem on mounting scsi raids.
Good luck!

silverback011 08-14-2004 08:20 AM

Once again thanks for you help. I will do some reading. I'll let you know how it comes out.

silverback011 08-15-2004 11:22 AM

I am able to boot up now with the added partition.

I installed the Lilo boot loader. Then I added:

image=/boot/vmlinuz
label="Primary"
root=/dev/hda6
initrd=/boot/initrd.img
append="root=/dev/hda6" #tells initrd to use this instead of old
vga=788
read-only

In addition to this I editied my /etc/fstab to change the partition numbers to the correct ones.

I have already learned a bit doing this project. Discovered I have been running for awhile without any swap. Hasn't been mounting on boot up.

Thanks a lot osvaldomarques for pointing me in the correct direction.


All times are GMT -5. The time now is 11:21 AM.