- 论坛徽章:
- 0
|
1、用livecd启动光盘,启动系统
2、安装网络
net-setup
3、启动ssh服务
/etc/rc.d/init.d/sshd start
4、设置root密码
passwd
根据提示输入你设置的密码
5、通过远程的ssh客户端连接到机器
6、创建3个路径
mkdir -v /livehd
mkdir -v /livecd
mkdir -v /sources
7、为空硬盘分区
使用cfdisk或fdisk ,建议使用cfdisk
建一个主分区加挂/ 存放系统及程序, 设置boot标志,意思可以启动,不小于40G
建一个交换分区 2G
剩下空间建一扩展分区,用来建其它逻辑分区,用于存放数据
建一个逻辑分区加挂/sources 存放源码
8、对分区进行格式化
这里对磁盘使用xfs格式
# mkfs.xfs /dev/sda1
meta-data=/dev/sda1 isize=256 agcount=16, agsize=610344 blks
= sectsz=512 attr=0
data = bsize=4096 blocks=9765504, imaxpct=25
= sunit=0 swidth=0 blks, unwritten=1
naming =version 2 bsize=4096
log =internal log bsize=4096 blocks=4768, version=1
= sectsz=512 sunit=0 blks, lazy-count=0
realtime =none extsz=4096 blocks=0, rtextents=0
创建交换分区
# mkswap /dev/sda5
Setting up swapspace version 1, size = 2048057 kB
no label, UUID=3e1a0984-a272-48e7-b3bc-e26c429b35f5
# mkfs.xfs /dev/sda6
meta-data=/dev/sda6 isize=256 agcount=16, agsize=305234 blks
= sectsz=512 attr=0
data = bsize=4096 blocks=4883744, imaxpct=25
= sunit=0 swidth=0 blks, unwritten=1
naming =version 2 bsize=4096
log =internal log bsize=4096 blocks=2560, version=1
= sectsz=512 sunit=0 blks, lazy-count=0
realtime =none extsz=4096 blocks=0, rtextents=0
# mkfs.xfs /dev/sda7
meta-data=/dev/sda7 isize=256 agcount=16, agsize=363846 blks
= sectsz=512 attr=0
data = bsize=4096 blocks=5821536, imaxpct=25
= sunit=0 swidth=0 blks, unwritten=1
naming =version 2 bsize=4096
log =internal log bsize=4096 blocks=2842, version=1
= sectsz=512 sunit=0 blks, lazy-count=0
realtime =none extsz=4096 blocks=0, rtextents=0
9、加挂上livecd和要安装系统的硬盘/dev/sda1
我使用的是lfslivecd-x86-6.7,光盘启动好后,已经被挂载了/上。
光盘镜像在/dev/shm/.cdrom/root.ext2
mount -o loop /dev/shm/.cdrom/root.ext2 /livecd
mount /dev/sda1 /livehd
10、系统复制到硬盘再做设置
cp -Rv /livecd/* /livehd
11、加挂上设备
把dev设备挂上
mount -t proc proc /livehd/proc
mount -t sysfs sysfs /livehd/sys
mount -t devpts devpts /livehd/dev/pts
mount -t tmpfs tmpfs /livehd/dev/shm
mount --bind /dev /livehd/dev
挂上交换分区
swapon /dev/sda5
# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 2000052 0 -1
12、切换到新的环境
chroot /livehd
创建boot目录
mkdir /boot
加挂sources分区
mount /dev/sda6 /sources/
13、编译一个新的内核
通过scp将linux内核linux-2.6.32.28.tar.bz2源码
tar -xvf linux-2.6.32.28.tar.bz2
cd linux-2.6.32.28
make mrproper //清理配置
make menuconfig //配置内核
General setup
<*> Kernel .config support
BSD Process Accounting version 3 file format
<*> Kernel .config support
Enable access to .config through /proc/config.gz
enable deprecated sysfs features which may confuse old userspace tools
这些必须要选则
[ ] Optimize for size 默认是选中状态,必须去掉,不需要为点启动优化内核大小
xfs的内容必须全部创建进内核 使用*选中相关项,分区类型必须全部选择,否则启动时无法加挂root系统
file system
=>
<*> XFS filesystem support
XFS Quota support
XFS POSIX ACL support
XFS Realtime subvolume support
[] XFS Debugging support (EXPERIMENTAL)
Partition Types全选为了保险
Advanced partition selection
Acorn partition support
Cumana partition support
EESOX partition support
ICS partition support
Native filecore partition support
PowerTec partition support
RISCiX partition support
Alpha OSF partition support
Amiga partition table support
Atari partition table support
Macintosh partition map support
PC BIOS (MSDOS partition tables) support
BSD disklabel (FreeBSD partition tables) support
Minix subpartition support
Solaris (x86) partition table support
Unixware slices support
Windows Logical Disk Manager (Dynamic Disk) support
Windows LDM extra logging
SGI partition support
Ultrix partition table support
Sun partition tables support
Karma Partition support
EFI GUID Partition support
SYSV68 partition table support
由于使用是scsi接口硬盘所以所有scsi的驱动都创建到内核
device driver
--- Fusion MPT device support
<*> Fusion MPT ScsiHost drivers for SPI
<*> Fusion MPT ScsiHost drivers for FC
<*> Fusion MPT ScsiHost drivers for SAS
(12 Maximum number of scatter gather entries (16 - 12 (NEW)
<*> Fusion MPT misc device (ioctl) driver
Fusion MPT logging facility
------ SCSI device support --->
<*> RAID Transport Class
-*- SCSI device support
<*> SCSI target support
legacy /proc/scsi/ support
*** SCSI support type (disk, tape, CD-ROM) ***
<*> SCSI disk support
<*> SCSI tape support
<*> SCSI OnStream SC-x0 tape support
<*> SCSI CDROM support
Enable vendor-specific extensions (for SCSI CDROM)
<*> SCSI generic support
<*> SCSI media changer support
Probe all LUNs on each SCSI device
Verbose SCSI error reporting (kernel size +=12K)
SCSI logging facility
Asynchronous SCSI scanning
SCSI Transports --->
SCSI low-level drivers --->
PCMCIA SCSI adapter support --->
<*> SCSI Device Handlers --->
<*> OSD-Initiator library
<*> OSD Upper Level driver
网络设备驱动必须选择你的网卡
保存配置
make
时间相当长,需要耐心
make modules_install
cp -v arch/x86/boot/bzImage /boot/vmlinux-2.6.32.28-lfs-6.7
cp -v System.map /boot/System.map-2.6.32.28
cp -v .config /boot/config-2.6.32.28
cd ..
install -v -m755 -d /etc/modprobe.d
cat > /etc/modprobe.d/usb.conf << "EOF"
# Begin /etc/modprobe.d/usb.conf
install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true
install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true
# End /etc/modprobe.d/usb.conf
EOF
15、安装grub1.8
tar xvf grub-1.98.tar.gz
cd grub-1.98
./configure --prefix=/usr \
--sysconfdir=/etc \
--disable-grub-emu-usb \
--disable-grub-fstest \
--disable-efiemu
make
make install
cd ..
rm -rf grub-1.98
16、fstab配置
cat > /etc/fstab << "EOF"
# Begin /etc/fstab
# file system mount-point type options dump fsck
#
/dev/sda1 / xfs defaults 1 1
/dev/sda5 swap swap pri=1 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devpts /dev/pts devpts gid=4,mode=620 0 0
shm /dev/shm tmpfs defaults 0 0
# End /etc/fstab
EOF
16、grub配置
这里要根据具体情况调整你安装的硬盘分区
grub-install --grub-setup=/bin/true /dev/sda1
grub-mkconfig -o /boot/grub/grub.cfg
grub-setup /dev/sda
17、linux-from scratch bootscrpt安装
tar xvf lfs-bootscripts-20100627.tar.bz2
cd lfs-bootscripts-20100627
make install
cd ..
rm -rf lfs-bootscripts-20100627
18、设置bash下的键盘功能键设置
cat > /etc/inputrc << "EOF"
# Begin /etc/inputrc
# Modified by Chris Lynn <roryo@roryo.dynup.net>
# Allow the command prompt to wrap to the next line
set horizontal-scroll-mode Off
# Enable 8bit input
set meta-flag On
set input-meta On
# Turns off 8th bit stripping
set convert-meta Off
# Keep the 8th bit for display
set output-meta On
# none, visible or audible
set bell-style none
# All of the following map the escape sequence of the value
# contained in the 1st argument to the readline specific functions
"\eOd": backward-word
"\eOc": forward-word
# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
# for Konsole
"\e[H": beginning-of-line
"\e[F": end-of-line
# End /etc/inputrc
EOF
19、时间设置(Configuring the setclock Script)
cat > /etc/sysconfig/clock << "EOF"
# Begin /etc/sysconfig/clock
UTC=1
# Set this to any options you might need to give to hwclock,
# such as machine hardware clock type for Alphas.
CLOCKPARAMS=
# End /etc/sysconfig/clock
EOF
20、设置DNS
根据实际情况
cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf
nameserver 61.139.2.69
# End /etc/resolv.conf
EOF
重启系统,ok一切都在硬盘上
请看原文:http://www.greewater.com/view.asp?id=2 |
|