全部博文(685)
分类: LINUX
2015-03-12 13:45:50
export LFS=/mnt/lfs mkdir -pv $LFS mount /dev/hda2 /mnt/lfs cd $LFS tar jcvpf ~/lfs-6.3.tar.bz2 ./*--exclude boot cd $LFS/boot tar jcvpf ~/boot.tar.bz2 ./*
export ISO=~/iso
mkdir $ISO
mkdir -pv $ISO/boot/grub
cp /boot/grub/stage2_eltorito $LFS/boot/grub
cat > $ISO/boot/grub/menu.lst <<EOF
default0
timeout30
color green/black light-green/black
title grub bootcd
root (cd)
kernel /boot/kernel
initrd /boot/initramfs.gz
EOF
cp arch/X86/boot/bzImage $ISO/boot/kernel
export INITFS=~/initfs
mkdir $INITFS{,/out}
cp /boot/initramfs.gz $INITFS
gunzip initramfs.gz
cd out
cpio -div <../initramfs
mkdir install
cp ~/lfs-6.3.tar.bz2 install
cp ~/boot.tar.bz2 install
cp ~/install.sh install
find .| cpio -H newc -o | gzip >../initramfs.gz
mv ../initramfs.gz $ISO/boot
cd $ISO
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4-boot-info-table \ -o liveCD-lfs-6.3.iso $ISO
#!/bin/bash
#find the disk DISK=`find /dev -type b | grep '.*[shv]d[a-d][0-9]' | sed -e 's/.$//' | head -1`&& echo "Your DISK is $DISK"&& DISK_PRE=`echo $DISK | sed -e 's/.$//'`&& #set the partition echo "Input Your SWAP Partition for a number:"&& read SWAP_NUM && DISK_SWAP=${DISK}${SWAP_NUM}&& echo "Input Your BOOT Partition for a number:"&& read BOOT_NUM && DISK_BOOT=${DISK}${BOOT_NUM}&& echo "Input Your ROOT Partition for a number:"&& read ROOT_NUM && DISK_ROOT=${DISK}${ROOT_NUM}&& #init swap partition mkswap $DISK_SWAP && #swapon $DISK_SWAP && #init root partition mkfs.ext3 $DISK_ROOT && mount $DISK_ROOT /mnt/lfs && cd /mnt/lfs && tar jxvpf /install/lfs-6.3.tar.bz2 && cp ${DISK_PRE}*/mnt/lfs/dev/-R && echo "install ROOT finished"&& #init boot partition mkfs -t ext3 $DISK_BOOT && mount $DISK_BOOT /mnt/boot && cd /mnt/boot && tar jxvpf /install/boot.tar.bz2 && echo "install BOOT finished"&& #init fstab echo "${DISK_ROOT} / ext3 defaults 1 1">/mnt/lfs/etc/fstab && echo "${DISK_SWAP} swap swap pri=1 0 0">>/mnt/lfs/etc/fstab && echo "${DISK_BOOT} /boot ext3 defaults 0 0">>/mnt/lfs/etc/fstab && echo "proc /proc proc defaults 0 0">>/mnt/lfs/etc/fstab && echo "sysfs /sys sysfs defaults 0 0">>/mnt/lfs/etc/fstab && echo "devpts /dev/pts devpts gid=4,mode=620 0 0">>/mnt/lfs/etc/fstab && echo "shm /dev/shm tmpfs defaults 0 0">>/mnt/lfs/etc/fstab && #init grub menu.lst if[ $BOOT_NUM =1];then GRUB_BOOT=0 else GRUB_BOOT=`expr $BOOT_NUM - 1` fi&& echo "default 0">/mnt/boot/grub/menu.lst && echo "timeout 30">>/mnt/boot/grub/menu.lst && echo "color green/black light-green/black">>/mnt/boot/grub/menu.lst && echo "">>/mnt/boot/grub/menu.lst && echo "title LFS 6.3">>/mnt/boot/grub/menu.lst && echo "root (hd0,$GRUB_BOOT)">>/mnt/boot/grub/menu.lst && echo "kernel /kernel-2.6.39.4 root=${DISK_ROOT} vga=788">>/mnt/boot/grub/menu.lst && #reset MAC address rm -f /mnt/lfs/etc/udev/rules.d/70-persistent-net.rules && #chroot and MBR cd /&& umount /mnt/boot && mount $DISK_BOOT /mnt/lfs/boot && chroot /mnt/lfs /bin/bash -c "echo -e 'root (hd0,$GRUB_BOOT)\nsetup (hd0)\nquit' | /usr/sbin/grub"&& echo "******************************************************************"&& echo "******************** install finish now reboot *******************"&& echo "******************************************************************"&& chroot /mnt/lfs/ /bin/bash -c "reboot"
#find the disk DISK=`find /dev -type b | grep '.*[shv]d[a-d][0-9]' | sed -e 's/.$//' | head -1`&&
#set the partition echo "Input Your SWAP Partition for a number:"&& read SWAP_NUM && DISK_SWAP=${DISK}${SWAP_NUM}&& echo "Input Your BOOT Partition for a number:"&& read BOOT_NUM && DISK_BOOT=${DISK}${BOOT_NUM}&& echo "Input Your ROOT Partition for a number:"&& read ROOT_NUM && DISK_ROOT=${DISK}${ROOT_NUM}&&
#init swap partition mkswap $DISK_SWAP && #swapon $DISK_SWAP &&
#init root partition mkfs.ext3 $DISK_ROOT && mount $DISK_ROOT /mnt/lfs && cd /mnt/lfs && tar jxvpf /install/lfs-6.3.tar.bz2 && cp ${DISK_PRE}*/mnt/lfs/dev/-R && echo "install ROOT finished"&&
#init boot partition mkfs -t ext3 $DISK_BOOT && mount $DISK_BOOT /mnt/boot && cd /mnt/boot && tar jxvpf /install/boot.tar.bz2 && echo "install BOOT finished"&&
#init fstab echo "${DISK_ROOT} / ext3 defaults 1 1">/mnt/lfs/etc/fstab && echo "${DISK_SWAP} swap swap pri=1 0 0">>/mnt/lfs/etc/fstab && echo "${DISK_BOOT} /boot ext3 defaults 0 0">>/mnt/lfs/etc/fstab && echo "proc /proc proc defaults 0 0">>/mnt/lfs/etc/fstab && echo "sysfs /sys sysfs defaults 0 0">>/mnt/lfs/etc/fstab && echo "devpts /dev/pts devpts gid=4,mode=620 0 0">>/mnt/lfs/etc/fstab && echo "shm /dev/shm tmpfs defaults 0 0">>/mnt/lfs/etc/fstab &&
#init grub menu.lst if[ $BOOT_NUM =1];then GRUB_BOOT=0 else GRUB_BOOT=`expr $BOOT_NUM - 1` fi&& echo "default 0">/mnt/boot/grub/menu.lst && echo "timeout 30">>/mnt/boot/grub/menu.lst && echo "color green/black light-green/black">>/mnt/boot/grub/menu.lst && echo "">>/mnt/boot/grub/menu.lst && echo "title LFS 6.3">>/mnt/boot/grub/menu.lst && echo "root (hd0,$GRUB_BOOT)">>/mnt/boot/grub/menu.lst && echo "kernel /kernel-2.6.39.4 root=${DISK_ROOT} vga=788">>/mnt/boot/grub/menu.lst &&
#reset MAC address rm -f /mnt/lfs/etc/udev/rules.d/70-persistent-net.rules &&
#chroot and MBR cd /&& umount /mnt/boot && mount $DISK_BOOT /mnt/lfs/boot && chroot /mnt/lfs /bin/bash -c "echo -e 'root (hd0,$GRUB_BOOT)\nsetup (hd0)\nquit' | /usr/sbin/grub"&& echo "******************************************************************"&& echo "******************** install finish now reboot *******************"&& echo "******************************************************************"&& chroot /mnt/lfs/ /bin/bash -c "reboot"
安装方法:以光驱或U盘启动载入liveCD后选择grub进入livecd中 ,用liveCD中的的fdisk对磁盘进行分区,分区完后执行/install/install.sh自动安装,安装完后会自动重启。
2. 进入grub引导界面,选择 grub bootcd,启动LiveCD中。
3. 用fdisk 将磁盘分区,应该至少有swap分区、boot分区和文件系统分区。
4. 执行 /install/install.sh 脚本文件,键入grub、boot、文件系统分区编号后自动安装,安装完自动重启,重启时选择硬盘启动进入grub,启动系统即可。