Linux U盘 启动盘

/******************************************************************************
 *                          Linux U盘 启动盘
 * 说明:
 *     之前一直有个想法,那就是将x86的系统放在U盘中,像ARM那样做,但一直也不知
 * 道大概要怎么查资料,最近搞redhat,查到了一些相关资料,记录一下。
 *
 *                                         2017-3-6 深圳 南山平山村 曾剑锋
 *****************************************************************************/

一、参考文档:
    1. 制作一个linux的u盘最小系统
        http://zhuyi108.blog.51cto.com/2087327/845246
    2. 制作u盘启动linux系统
        http://www.voidcn.com/blog/mr_zhaojy/article/p-5974248.html
    3. U 盘启动LINUX
        http://blog.csdn.net/clozxy/article/details/5865632
    4. 定制自己的U盘Linux系统
        http://mowblog.com/%E5%AE%9A%E5%88%B6%E8%87%AA%E5%B7%B1%E7%9A%84u%E7%9B%98linux%E7%B3%BB%E7%BB%9F/
    5. CDlinux HOWTOs 文档
        http://cd-linux.sourceforge.net/archive/0.4/howto-cn.html
    6. GRUB (简体中文)
        https://wiki.archlinux.org/index.php/GRUB_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
    7. 什么是 initrd.img
        http://blog.csdn.net/chrisniu1984/article/details/3907874
    8. Linux2.6 内核的 Initrd 机制解析
        https://www.ibm.com/developerworks/cn/linux/l-k26initrd/
    9. Linux 初始 RAM 磁盘(initrd)概述
        https://www.ibm.com/developerworks/cn/linux/l-initrd.html
    10. Linux 引导过程内幕
        https://www.ibm.com/developerworks/cn/linux/l-linuxboot/
    11. LINUX下三个内核文件详解(vmlinuz/initrd.img/System.map)
        https://www.path8.net/tn/archives/5304

二、基本操作说明:
    1. U盘(SD卡)分两个区:
        1. /dev/sdb1;
        2. /dev/sdb2;
    2. mount /dev/sdb1 /mnt
    3. grub-install –root-directory=/mnt /dev/sdb
        Installing for i386-pc platform.
        Installation finished. No error reported.
    4. ls /boot/grub/
        fonts gfxblacklist.txt grub.cfg grubenv i386-pc locale unicode.pf2
    5. 编写/boot/grub/grub.cfg文件:
        set default=0
            insmod gzio
            insmod jpeg
            insmod part_msdos
            insmod ext2
            insmod ext3
            insmod ext4
        set timeout=10
        set root='hd0,1'
            # linux (hd0,1)/boot/vmlinuz rw # root=/dev/sdb2 rootfstype=ext3
            linux (hd0,1)/boot/vmlinuz rw root=/dev/sdb2 rootfstype=ext3
            initrd (hd0,1)/boot/initrd.img
            boot
    6. 拷贝对应的系统文件,最终/dev/sdb1分区目录如下:
        .
        └── boot
            ├── grub
            │   ├── fonts
            │   ├── grub.cfg
            │   ├── grubenv
            │   ├── i386-pc
            │   └── locale
            ├── initrd.img
            ├── initrd.img_redhat
            ├── initrd.img_ubuntu
            ├── vmlinuz
            ├── vmlinuz_redhat
            └── vmlinuz_ubuntu
    7. 下载Ubuntu Core,并将其解压到/dev/sdb2分区中,注意将passwd中间中root密码去掉,否则要输入密码。
    8. 如上所示,既有redhat,又有ubuntu的,遇到了redhat内核版本过低,Ubuntu Core版本高过不能挂载文件系统的问题。

三、遇到错误:
    1. 现象:
        ...
        mount: could not find filesystem /dev/root 
        Setting up other filesystems
        Setting up new root fs
        setuproot: moving /dev failed: No such file or directory
        ...
    2. 参考文档:
        1. [SOLVED] Getting existing CentOS5 system to run with a new motherboard
            https://www.centos.org/forums/viewtopic.php?t=24681
        2. Creating a New Initial RAM Disk
            https://wiki.centos.org/TipsAndTricks/CreateNewInitrd
    3. 原因:
        If you have changed a motherboard or moved a disk to a different system it may fail to boot due to the lack of appropriate drivers in the initial RAM disk image (initramfs for CentOS 6, initrd for CentOS 5).

 

posted on 2017-03-06 21:12  zengjf  阅读(595)  评论(0编辑  收藏  举报

导航