通过grub-install命令把grub安装到u盘-总结
通过grub-install命令把grub安装到u盘
②把u盘格式化(我把u盘格式化成FAT、fat32格式了,最后证明也是成功的)。
③开启linux系统,打开命令行终端,进入root模式,然后输入命令行:
mount /dev/sdb3 /tmp/boot
grub-install --root-directory=/tmp/boot --no-floppy /dev/sdb
注意:上面/dev/sdb是我的u盘,在linux系统里的盘符吧,那个/dev/sdb3为什么是“3”,这个因不同的实际情况而不同吧。
总的来说,/dev/sdb就是我的u盘的名字,/dev/sdb3就是我的u盘的一个分区。
④这个时候,你会发现,你的u盘,已经多了一个boot目录,里面有一些内容,这个时候,boot目录的路径是/dev/sdb3/boot/。
⑤把“/boot/grub/grub.conf”和“/boot/grub/splash.xpm.gz”,复制到“/dev/sdb3/boot/grub/”下面(也就是“u盘/boot/grub/”)。
⑥然后把/dev/sdb3/boot/grub/grub.conf修改成以下内容:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/sda1
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Red Hat Enterprise Linux Server 1280*1024(3.4.0)
root (hd0,0)
kernel /boot/vmlinuz-3.4.0 root=/dev/sda1 selinux=0 init=/sbin/init vga=795 fb:on
initrd /boot/initrd.img-3.4.0
title Red Hat Enterprise Linux Server 1600*1200(3.4.0)
root (hd0,0)
kernel /boot/vmlinuz-3.4.0 root=/dev/sda1 selinux=0 init=/sbin/init vga=858 fb:on
initrd /boot/initrd.img-3.4.0
⑦重启计算机,在BIOS里,设置为从u盘启动,即可。
set default=0
set timeout=5
set gfxmode=1280x1024
menuentry 'Red Hat Enterprise Linux Server 1280*1024(3.4.0)' {
set gfxpayload=1280x1024x32,1024x768x32,800x600x32,800x600x16,800x600,640x480
linux /boot/vmlinuz-3.4.0 root=/dev/sda1 selinux=0 init=/sbin/init vga=795
initrd /boot/initrd.img-3.4.0
}
制作步骤:
先用cfdisk 在U盘中,创建个两个分区,第二个一会儿作为boot分区。
0:mkfs.ext3 /dev/sdc5
1:mount /dev/sdc5 /tmp/boot
2:grub-install --root-directory=/tmp/boot --no-floppy /dev/sdc(*注意*)
自己修改一下menu.lst文件吧。这个简单。
主板+USB,均引导内核成功,系统未作复杂裁剪,未作压缩镜像
1. linux内核编译:
具体步骤:
# tar zxvf linux-2.6.tar.gz -C /usr/src
# cd /usr/src/linux2.6
# make menuconfig
# make
# make modules_install
# cp arch/x86/boot/bzImage /boot/vmlinuz-2.6
# make install
对比/boot/grub/grub.cfg文件的改动
2. 安装启动盘(U盘、硬盘)
# Fdisk /dev/sdb
#mkfs.ext2 /dev/sdb1
# mkdir /tmp/boot ; mount /dev/sdb1/tmp/boot
# grub-install--root-directory=/tmp/boot --no-floppy /dev/sdb
# cp /boot/grub/grub.conf /tmp/boot/boot/grub/
# cp /boot/grub//boot/grub/splash.xpm.gz /tmp/boot/boot/grub/
# cp /boot/vmlinuz-2.6.34/mnt/boot/vmlinuz
# cp /boot/initramfs-2.6.34.img/mnt/boot/initramfs.img
3. 构建系统目录
# mkdir dev proc etc sbin bin lib mntusr
# cp /bin /tmp/boot/
# cp –dpr /dev/{console,fd0.hda,hda8,hda9,hda10,initctl,initrd,kmem,mem,null,ram,ram0,ramdisj,sda,tty1,tty} /tmp/boot/
# cp/etc/{default,ld.so.cache,ld.so.conf,login.defs,fstab,groub,init.d,inittab,issue,modules.conf,mtab,nsswitch.conf,pam.d,profile,rc.d} /tmp/boot/
4. 编辑grub.conf
Default为默认启动项
Grub2 grub.cfg
set default=0
set timeout=5
set gfxmode=1280x1024
menuentry 'Red Hat EnterpriseLinux Server 1280*1024(3.4.0)' {
setgfxpayload=1280x1024x32,1024x768x32,800x600x32,800x600x16,800x600,640x480
linux/boot/vmlinuz-3.4.0 root=/dev/sda1selinux=0 init=/sbin/init vga=795
initrd/boot/initrd.img-3.4.0
}
5. 添加必要的命令
例如:ls
Ldd ls,添加对应的依赖库文件;ldd ls > 1.txt
6. 修改initrd
重新编译内核后,可能加入了自定义的模块,就有可能需要修改init文件,而init文件就在initrd中,这里记录下操作步骤,以防遗忘。
1. cp /boot/initrd-3.2.img /tmp/mylinux/initrd-3.2.img.gz
这里之所以进行改名,是因为initrd-3.2.img是经过gzip压缩过的,所以需要对其解压,但是gzip对解压的文件的文件后缀名又有要求,所以就先进行改名。
2. gunzip initrd-3.2.9.img.gz
3. cpio -id < initrd-3.2.9.img
经过以上三步,就在当前目录下解压了initrd文件,从而得到了init文件。
根据自己的需求修改init文件后,通过下面命令重新生成initrd文件。
4. find . | cpio -H newc -o | gzip -9 > /boot/initrd-3.2.9.img
find . | cpio -H newc -o | gzip -9>../initrd.img-3.4.0
7. 内核添加fb0
mknod /dev/fb0 c 29 0
Device Drivers --->
Graphics support --->
<*> Support for frame buffer devices--->
318 31b 35a
1024 1280 1600
8. 添加网络驱动
# initrd,img/init
echo "0: linuxrunning on initrd.img"
echo "1: linuxrunning on usb ext2 filesystem"
read -p "select:" data
if [ $data ="0" ]; then
echo "0: linux running oninitrd.img selected"
uname -r
insmod lib/modules/3.4.0/kernel/drivers/net/mii.ko
insmod lib/modules/3.4.0/kernel/drivers/net/ethernet/realtek/r8169.ko#添加网络
insmod lib//modules/3.4.0/kernel/drivers/usb/storage/usb-storage.ko#添加USB
sleep 1
mkdir usb
mount /dev/sda1usb
ifconfig -a
ifconfig eth0192.168.1.88
sleep 1
sh
else
echo "1: linux running on usb ext2filesystem selected"
sleep 1
fi
通过grub-install命令把grub安装到u盘-总结的更多相关文章
- 通过grub-install命令把grub安装到u盘
通过grub-install命令把grub安装到u盘 ①准备一个u盘,容量不限,能有1MB都足够了. ②把u盘格式化(我把u盘格式化成FAT.fat32格式了,最后证明也是成功的).③开启linux系 ...
- Windows恢复Grub引导,用grub安装ubuntu
http://www.linuxidc.com/wap.aspx?nid=18027&p=&cp=&cid=http://m.blog.chinaunix.net/uid-22 ...
- Linux(Ubuntu)使用 sudo apt-get install 命令安装软件的目录在哪?(已解决)
Linux(Ubuntu)使用 sudo apt-get install 命令安装软件的目录在哪? bin文件路径: /usr/bin 库文件路径: /usr/lib/ 其它的图标啊什么的路径 ...
- 【adb命令】在cmd窗口中使用adb install命令安装 中文名字apk报错的解决办法
1.在cmd窗口中使用adb install命令安装中文名字apk报错,安装英文名字apk就正常,详细报错如下图: 2.查看adb版本号:adb version 3.怀疑是adb版本的原因,尝试换个最 ...
- Linux软件安装install命令
install 1.作用 install命令的作用是安装或升级软件或备份数据,它的使用权限是所有用户. 2.格式 (1)install [选项]... 来源 目的地 (2)install [选项]. ...
- npm install 命令。默认会找到当前路径下的package.json。然后安装其中的依赖
npm install 命令.默认会找到当前路径下的package.json.然后安装其中的依赖 By default, npm install will install all modules li ...
- 用命令行来安装mac应用
今天看了下唐巧的博客,发现了这样一种宝贝呀,哈哈,分享一下 命令行工具,brew cask是一个用命令行管理Mac下应用的工具,它是基于homebrew的一个增强工具. brew cask insta ...
- linux命令——mutt的安装和使用【转】
linux命令--mutt的安装和使用[转] 首先介绍一下mutt这个软件,它是一款基于文字界面的邮件客户端,非常小巧,但功能强大,可以用它来读写,回复保存和删除你的邮件,能在linux命令行模式下收 ...
- install 命令用法详解
install 命令用法详解 http://man.linuxde.net/install install命令的作用是安装或升级软件或备份数据,它的使用权限是所有用户.install命令和cp命令类似 ...
随机推荐
- FC经典游戏还原之:松鼠大作战2
版权声明:本文原创发布于博客园"优梦创客"的博客空间(id:raymondking123) 原帖地址:http://www.cnblogs.com/raymondking123/p ...
- dubbo调用负载均衡
dubbo负载均衡的地址:http://dubbo.io/books/dubbo-user-book/demos/loadbalance.html 随机策略: public class RandomL ...
- Java设计模式——模板方法模式
转载自:https://www.cnblogs.com/zplogo/p/6428593.html 用抽象基类定义算法框架 RefreshBeverage package com.pattern.te ...
- Linux内核链表-通用链表的实现
最近编程总想着参考一些有名的开源代码是如何实现的,因为要写链表就看了下linux内核中对链表的实现. 链表是一种非常常见的数据结构,特别是在动态创建相应数据结构的情况下更是如此,然而在操作系统内核中, ...
- CDN设置回源host的意义
CDN设置回源host的意义 如果CDN后端用户的的源站web服务上没有绑定加速域名,只绑定了其他域名,未限制域名访问(比如通过服务器IP可以访问到默认网站),可以在CDN控制台填写回源host,这样 ...
- PHP 支持8种基本的数据类型
四种标量类型: boolean (布尔型):这是最简单的类型,只有两种取值,可以为 TRUE/true 或 FALSE/false ,不区分大小写.详细请查看:PHP布尔类型(boolean)inte ...
- 隱藏在素數規律中的Pi -- BZOJ1041解題報告
退役狗在刷程書的過程中看到了一個有趣的視頻, 講解了一個有趣的問題. 在網上隨便搜索了一下居然還真的找到了一道以它爲背景的OI題目, BZOJ1041. 下面的內容會首先回顧一下視頻所討論的知識, 有 ...
- Java基础系列--static关键字
原创作品,可以转载,但是请标注出处地址:http://www.cnblogs.com/V1haoge/p/8477914.html 一.概述 static关键字是Java诸多关键字中较常使用的一个,从 ...
- maven常用命令介绍
mvn 3.0.4 创建maven项目命令 mvn archetype:generate -DgroupId=damocles-autocredit -DartifactId=damocles ...
- java对excel表格上传和下载的处理方法
详见:http://www.jb51.net/article/120443.htm