Chinaunix首页 | 论坛 | 博客
  • 博客访问: 733741
  • 博文数量: 235
  • 博客积分: 4309
  • 博客等级: 中校
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-17 11:25
个人简介

If you don\\\\\\\\\\\\\\\'t wanna do it, you find an EXCUSE; if you do, you\\\\\\\\\\\\\\\'ll find a WAY :-)

文章分类

全部博文(235)

文章存档

2014年(3)

2013年(2)

2012年(31)

2011年(199)

分类: LINUX

2011-01-17 15:02:57

Transfering a LiveCD image to a Flash drive: 

Unetbootin LiveUSB: 

Install CentOS directly from usb drive?

Actually, I figured out how to do it:
1. Using fdisk, I created two partitions on the drive: 
 /dev/sdc1 = 15 MB 
 /dev/sdc2 = The rest 
I marked the first one bootable 

2. I used dd to copy the diskboot.img to /dev/sdc1
dd if=images/diskboot.img of=/dev/sdc1

3. Formatted /dev/sdc2 as ext3 and copied the iso images there 

4. When I boot from the usb drive, I selected hard drive install and pointed the installer to /dev/scd2 

 It worked perfectly!
_________________________________________________________________________________

(下面是8G U盘 )

1.  8G U盘,两个分区,都是FAT32(这样U盘也可以在Win下使用),由于Windows XP只能看到第一个FAT32分区,因此,将CentOS 5.4 的相关安装文件 放在 第二个分区中; 在Linux下用fdisk命令对8G U盘进行分区,如下(红色为输入):


[root@localhost ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 30584.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p

Disk /dev/sda: 8017 MB, 8017412096 bytes
16 heads, 32 sectors/track, 30584 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       30590     7831024    6  FAT16

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/sda: 8017 MB, 8017412096 bytes
16 heads, 32 sectors/track, 30584 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-30584, default 1): 回车
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-30584, default 30584): 14000

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14001-30584, default 14001): 回车
Using default value 14001
Last cylinder or +size or +sizeM or +sizeK (14001-30584, default 30584): 回车
Using default value 30584

Command (m for help): p

Disk /dev/sda: 8017 MB, 8017412096 bytes
16 heads, 32 sectors/track, 30584 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       14000     3583984   83  Linux
/dev/sda2           14001       30584     4245504   83  Linux

Command (m for help): a
Partition number (1-4): 2

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): b
Changed system type of partition 2 to b (W95 FAT32)

Command (m for help): p

Disk /dev/sda: 8017 MB, 8017412096 bytes
16 heads, 32 sectors/track, 30584 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       14000     3583984    b  W95 FAT32
/dev/sda2   *       14001       30584     4245504    b  W95 FAT32

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
[root@localhost ~]# 

[root@localhost ~]# mkfs.vfat /dev/sda1        (将分区一格式化为FAT32)
mkfs.vfat 2.11 (12 Mar 2005)
[root@localhost ~]# mkfs.vfat /dev/sda2        (将分区二格式化为FAT32)
mkfs.vfat 2.11 (12 Mar 2005)
[root@localhost ~]# 



2.  在Linux下,在U盘第二个分区根目录创建boot文件夹,然后将(硬盘中) /boot中的 grub文件夹 整个 复制 到U盘的boot文件夹
    从网上下载 CentOS-5.4-i386-bin-DVD.iso,将其放在
U盘第二个分区根目录中;
    将
CentOS-5.4-i386-bin-DVD.iso中的isolinux文件夹提取出来,放在U盘第二个分区根目录中(如果是Fefora 10/11/12,则需要将Fefora*.iso中的images文件夹 也 提取出来,放在U盘第二个分区根目录中


[root@localhost disk-1]# tree (列出U盘第二个分区根目录中的内容)
.
|-- CentOS-5.4-i386-bin-DVD.iso
|-- boot
|   `-- grub
|       |-- device.map
|       |-- e2fs_stage1_5
|       |-- fat_stage1_5
|       |-- ffs_stage1_5
|       |-- grub.conf
|       |-- grub.conf~
|       |-- iso9660_stage1_5
|       |-- jfs_stage1_5
|       |-- minix_stage1_5
|       |-- reiserfs_stage1_5
|       |-- splash.xpm.gz
|       |-- stage1
|       |-- stage2
|       |-- ufs2_stage1_5
|       |-- vstafs_stage1_5
|       `-- xfs_stage1_5
`-- isolinux
    |-- boot.cat
    |-- boot.msg
    |-- general.msg
    |-- initrd.img
    |-- isolinux.bin
    |-- isolinux.cfg
    |-- memtest
    |-- options.msg
    |-- param.msg
    |-- rescue.msg
    |-- splash.lss
    `-- vmlinuz

3 directories, 29 files
[root@localhost disk-1]# 




3.  编辑U盘中的 /boot/grub/grub.conf 文件,内容如下:

#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,10)
#          kernel /vmlinuz-version ro root=/dev/hda3
#          initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,1)/grub/splash.xpm.gz

title Install CentOS 5.4
    kernel (hd0,1)/
isolinux/vmlinuz
    initrd (hd0,1)/
isolinux/initrd.img




4.  
在Linux下,依次执行如下命令:

[root@localhost ~]# grub

grub> root (hd
<敲TAB键>
 Possible disks are:  hd0 hd1
  注:hd0是硬盘,hd1是U盘

grub> root (hd1,
<敲TAB键>
 Possible partitions are:
   Partition num: 0,  Filesystem type is fat, partition type 0xb
   Partition num: 1,  Filesystem type is fat, partition type 0xb

grub> root (hd1,1)
            注:(hd1,1)是U盘的第2个分区
 Filesystem type is fat, partition type 0xb

grub> setup (hd1)
             注:安装 GRUB 的引导程序的stage1到U盘的MBR
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/fat_stage1_5" exists... yes
 Running "embed /boot/grub/fat_stage1_5 (hd1)"...  15 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd1) (hd1)1+15 p (hd1,1)/boot/grub/stage2 /boot/grub/grub.conf
"... succeeded
Done.

grub> quit


5.  OK,设置BIOS,U盘启动,进行安装。


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(下面是4G U盘 )


1.  4G U盘,整个U盘一个分区即可(如何分区?请参考前面的第1步),FAT32(这样U盘也可以在Win下使用)。
    
    如果在Linux下用fdisk命令查看,如下:
    [root@localhost ~]# fdisk -l /dev/sda

    Disk /dev/sda: 4173 MB, 4173332480 bytes
    129 heads, 62 sectors/track, 1019 cylinders
    Units = cylinders of 7998 * 512 = 4094976 bytes

       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1        1019     4074950    b  W95 FAT32

2.  在Linux下,在U盘根目录创建boot文件夹,然后将 /boot中的 grub文件夹 整个 复制 到U盘的boot文件夹
    从网上下载 CentOS-5.4-i386-bin-DVD.iso,将其放在
U盘根目录;
    将
CentOS-5.4-i386-bin-DVD.iso中的isolinux文件夹提取出来,放在U盘根目录;(如果是Fefora 10/11/12,则需要将Fefora*.iso中的images文件夹 也 提取出来,放在U盘根目录中

3.  编辑
U盘中的 /boot/grub/grub.conf 文件,内容如下:

#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,10)
#          kernel /vmlinuz-version ro root=/dev/hda3
#          initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz

title Install CentOS 5.4
    kernel (hd0,0)/isolinux/vmlinuz
    initrd (hd0,0)/isolinux/initrd.img

4.  
在Linux下,依次执行如下命令:

[root@localhost ~]# grub
grub> root (hd<敲TAB键>
 Possible disks are:  hd0 hd1  注:hd0是硬盘,hd1是U盘

grub> root (hd1,0)
             注:(hd1,0)是U盘的第一个分区
 Filesystem type is fat, partition type 0xb

grub> setup (hd1)
              注:安装 GRUB 的引导程序的stage1到U盘的MBR
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/fat_stage1_5" exists... yes
 Running "embed /boot/grub/fat_stage1_5 (hd1)"...  15 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf
"... succeeded
Done.

grub> quit

5.  OK,设置BIOS,U盘启动,进行安装。
  
    
    
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
阅读(2048) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~