LFS -- Linux From Scratch

From Noah.org
Revision as of 13:54, 25 August 2008 by Root (Talk | contribs) (LFS moved to LFS -- Linux From Scratch)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Linux From Scratch

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
  1. or
 mkfs.ext3 /dev/loop7

Can alternatively create ext2 filesystem (older. not journaled)

 mke2fs /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
  1. or
 /bin/mount disk.img /mnt/loop -o loop

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

 export LFS=/mnt/loop

Make directories

 mkdir $LFS/tools
 ln -s $LFS/tools /