Thursday, September 4, 2008

Install LFS Linux on file

Create a 2GB disk image

# heads: 255
# sectors per track: 63
# cylinders: 261
dd if=/dev/zero of=disk.img bs=512 count=4194304

Create disk partitions

There are two ways: A. fdisk can partion a file directly.

fdisk -H 255 -S 63 -C 261 disk.img

B. Associate disk.img file with a loopback device

/sbin/losetup -o 0 /dev/loop7 disk.img
fdisk -H 255 -S 63 -C 261 /dev/loop7

Select 'n' for new partion. Choose number 1. First cylinder 1. Last 261. Select 'a' to set active boot partion. Choose number 1. Select 'w' to write partion data. Select 'q' to quit.

Could now use this disk image in Bochs. Add these lines to bochsrc file:

ata0-master: type=disk, path="disk.img", mode=flat, cylinders=261, heads=255, spt=63
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
boot: disk

Create filesystem

Run mkfs on either disk.img file or on /dev/loop7. Running it on a file will give a warning, but seems to work

mkfs.ext3 disk.img


mkfs.ext3 /dev/loop7

Mount the filesystem

Use either loop device or loop option on mount

/sbin/losetup -o 0 /dev/loop7 disk.img
/bin/mount /dev/loop7 /mnt/loop

Set LFS environment variable. This is use many places during the build process.

export LFS=/mnt/loop

No comments:

Post a Comment