U盘 安装 CentOS 5.4 / Fefora 10/11/12
(下面是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盘启动,进行安装。
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
下面是在网络找的资料
Install CentOS directly from usb drive
http://lists.centos.org/pipermail/centos/2009-April/074475.html
1. Using fdisk, I created two partitions on the drive: /dev/sdc1 = 15 MB /dev/sdc2 = The rest I marked the first one bootable 注: [root@localhost wini]# fdisk -l Disk /dev/hda: 120.0 GB, 120034123776 bytes ...(输出信息略) Disk /dev/sda: 4173 MB, 4173332480 bytes ....(输出信息略) [root@localhost wini]# [root@localhost wini]# fdisk /dev/sda Command (m for help): p Disk /dev/sda: 4173 MB, 4173332480 bytes 255 heads, 63 sectors/track, 507 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 507 4072446 b W95 FAT32 Command (m for help): d Selected partition 1 Command (m for help): 1 1: unknown command 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: 4173 MB, 4173332480 bytes 255 heads, 63 sectors/track, 507 cylinders Units = cylinders of 16065 * 512 = 8225280 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-507, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-507, default 507): 15M Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (16-507, default 16): Using default value 16 Last cylinder or +size or +sizeM or +sizeK (16-507, default 507): Using default value 507 Command (m for help): a Partition number (1-4): 1 Command (m for help): p Disk /dev/sda: 4173 MB, 4173332480 bytes 255 heads, 63 sectors/track, 507 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 15 120456 83 Linux /dev/sda2 16 507 3951990 83 Linux 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. Syncing disks. [root@localhost wini]# fdisk -l /dev/sda Disk /dev/sda: 4173 MB, 4173332480 bytes 255 heads, 63 sectors/track, 507 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 15 120456 83 Linux /dev/sda2 16 507 3951990 83 Linux 2. I used dd to copy the diskboot.img to /dev/sdc1 [root@localhost wini]# mount /mnt/temp/centos54/CentOS-5.4-i386-bin-DVD.iso /mnt/wini/ -o loop [root@localhost wini]# cd /mnt/wini/ [root@localhost wini]# dd if=images/diskboot.img of=/dev/sda1 24576+0 records in 24576+0 records out 12582912 bytes (13 MB) copied, 6.0851 seconds, 2.1 MB/s 3. Formatted /dev/sdc2 as ext3(我使用了FAT32) and copied the iso images there [root@localhost wini]# mkfs.vfat /dev/sda 4. When I boot from the usb drive, I selected hard drive install and pointed the installer to /dev/sdc2 It worked perfectly! Thanks, Neil
http://www.cnblogs.com/dinglu/archive/2009/10/04/1577958.html
新拿X200,心下痒痒的装Fedora,无奈小本不自带光驱,所以只能U盘安装,无网络同时。折腾了一个中秋节终于大功告成,F10和F11都装了一次,不知道为啥F11特别慢所以卸了又装了F10,不过两者的安装步骤相同,特此总结。
一. 分区
我是事先在Windows XP下使用“我的电脑”的管理对要装Fedora的区进行划分的,一共分了3个部分,文件格式都是ext3:
1)一个4G的部分作为swap,因为内存本身是2G的,记得看过好多地方说swap最好是内存的两倍。
2)一个400M的部分挂载/boot,这点最后证明十分必要,如果没有给/boot指定一个专门的盘挂载,装完之后在开机的时候无法进入正常的linux的grub启动。
3)一个20G的部分挂载/,反正新的机器硬盘比较大所以就划了这么多。U盘引导盘
二.制作Fedora的引导U盘
1.准备工作:
1)硬件:一个4G以上U盘
2)软件1:Fedora-10-i386-DVD.iso
3)软件2:grubinst-1.1-bin-w32-2007-12-29
4)软件3:grub4dos-0.4.3-2008-05-02.zip
5)软件4:WinImage
2.步骤:
1)用软件2里面的grubinst_gui.exe给U盘安装grub,装的时候只需选中“磁盘”,并且选择U盘对应的盘符,点击“安装”即可,如果出现“Badpartition”的错误,只要在额外参数的地方加上—skip-mbr-test即可,再点“安装”就可以出现successful的字样。
2)拷贝grub4dos下grldr和menu.lst到U盘。
3)拷贝Fedora-10-i386-DVD.iso到U盘。
4)安装WinImage。在U盘下面建两个目录分别为boot和images,使用WinImage从Fedora-10-i386-DVD.iso中的pxeboot中提取vmlinuz和initrd.img到U盘的boot目录,提取images整个文件夹到U盘的image目录下。如果不提取images出来,在稍后安装的过程中就会出现找不到install.img的情况,而如果只是单独提取出install.img,在安装时又会提示要联网安装,所以要使这些问题都不出现,就需要在一开始的时候将整个images的内容都提取出来。
WinImage的使用方法:首先打开需要提取的文件,然后找到需要提取的文件夹或者文件,双击或者点击右键,选择“Extract”,保存到需要的位置即可。
5)编辑menu.lst,加入以下内容:
title F10 setup
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hda1
initrd /boot/initrd.img
注意:root后面有一个空格,然后kernel和initrd后面的路径就是上一步提取vmlinuz和initrd在U盘所放的位置,即boot文件夹下。如果是按步骤来的话就直接使用上面的内容就可以了。
6)启动盘安装完毕。包括:
grldr
menu.lst
/boot
vmlinuz
initrd.img
/images
从F10镜像images文件夹中提取的所有文件
三.安装Fodera步骤
1.我是IBM的机器,开机按F12,选择USB启动。
2.选择F10 setup进入,按步骤操作,当提示要选择载入的镜像时,选择/dev/sdb1即可,系统会自动找到/images下需要的镜像。
3.安装开始,当出现界面显示“安装需要对您的硬盘进行分区。”的时候,选择“手工分区”那个选项。由于在我的计划中,将/dev/sda8作为swap,将/dev/sda9作为/boot的挂载点,将/dev/sda10作为/的挂载点,以此为例进行说明。点击/dev/sda8,按“编辑”,在弹出对话框中选择格式化为”swap”,确定。对/dev/sda9,编辑时首先要选择挂载为/boot,然后格式化为ext3。对/dev/sda10,编辑时首先要选择挂载为/,然后格式化为ext3。都完成后,可以看到这三个设备后面都多了一个格式化的对勾,选择下一步,将这三个设备格式化。
4.此后就按照安装步骤操作就可以了,不会有新的问题出现。
四.出现问题及总结
1.grubinst_gui.exe创建引导grub失败。解决方法:在额外参数的地方加上—skip-mbr-test即可。
2.用U盘引导的时候提示找不到文件.原因是menu.lst写的不对,之前没有建./boot目录将vmlinuz和initrd.img就直接放在/下面,所以找不到,此时重写menu.lst引导至正确的位置,或者像实际采取的方法,建一个/boot文件夹将文件拷进去都可以解决问题。
3.在安装时选择了/dev/sdb1,确仍然提示找不到安装image。原因是最开始的时候没有将f10镜像中的install.img提取到U盘,所以将该img提取出来放到U盘,再到这一步的时候就不会出错了。
4.按照3的方法,在其后某一步会弹出对话框,让联网安装,可是我没有网,所以安装又一度中断。解决方法为,将f10镜像中的整个images文件夹的内容都提取到U盘中新建的images文件夹中。
5.最初我只给Fedora划分了两个分区,安装完毕之后发现无论如何都进不了Fedora的grub,总是一开机就进了WinXP,折腾了半天最终找到原因,就是没有给/boot划分一个分区,所以只要再多划一个分区给/boot就可以解决问题。貌似U盘安装都需要这个,因为我拿光盘装的时候没有这个分区一样可以启动。
+++++++++++++++++++++++++++++++++++++++++++++++++++
Installing Fedora 11, 10 or 9 From USB Stick
http://galder.zamarreno.com/?p=244
Updated on JUL 1, 2009: To installFedora 11, please follow the instructions given for Fedora 10 below butmake sure the bootable partition is slightly bigger because the netinstall iso on Fedora 11 is bigger than the one in Fedora 10. I gavethe bootable partition 512 megs and it worked perfectly.
The aim of this post is to explain how to install Fedora directlyfrom a USB stick containing the Fedora*-DVD.iso image. For thoseimpatient, just go to the Instructions section.
It’s been almost 2 years since I said goodbye to Windows and movedmy work laptop to Fedora, and I couldn’t be happier with the move. Ifyou wanna find out why I’m happier with Fedora, just carry on readingmy blog over the coming months. For the moment, I’ll be focusing on theFedora installation process. One of the best things about Fedora isthat it gets released twice a year so you keep upgrading your machineto the get the latest features, latest bugs…etc. This means that youend up downloading and burning a Fedora ISO into a brand new DVD every6 months. As you can imagine, I was quickly piling up DVDs that wereuseless soon after. So, after having looking around in electronicshops, I realised that USB keys had gone down in price and that youcould get an 8GB USB stick for little money. This happened at the sametime that I was getting a new laptop at work, so I wondered, what aboutI get myself one of those sticks, put the latest Fedora image on it andinstall it from there rather than burning yet another DVD? For sure,installing from an USB key was always going to be faster than from aDVD, so that was a plus as well.
For some reason, maybe because people haven’t tried this that much,it took me a while to find some decent instructions on how to do this.Eventually, this came from Michale Hartley’s comment on Haral Hoyer’s blog entry on “Fedora 8 on a USB stick”.However, I had some issues with these instructions, specially whentrying to create the bootable partition in the USB stick, so I ended upwriting my own set of instructions for Fedora 9:
Installing Fedora 9 from USB stick
- Download Fedora-9-i386-DVD.iso
- Download Fedora-9-i386-netinst.iso
- Create 2 ext3 partitions in USB stick (Hint:GParted is a wicked graphical tool to create partitions): A 200 MBbootable partition and another partition with the rest of space.
- Copy Fedora-9-i386-netinst.iso to 1st partition:
1
livecd-iso-to-disk Fedora-9-i386-netinst.iso /dev/sdb1
- Copy DVD iso image to 2nd partition:
1 2 3
mount /dev/sdb2 mnt-sdb2/ cp Fedora-9-i386-DVD.iso mnt-sdb2/ umount mnt-sdb2/
- Reboot with USB key inserted.
- Select install from Hard Drive and select /dev/sdb2
When Fedora 10 was released, I followed the same steps to install asI did for Fedora 9 but I kept getting an error saying that no imagecould be found in /dev/sdb2 even though the Fedora 10 DVD isoimage was there and had passed the SHA1SUM test successfully. Afterexchanging some emails within Red Hat I was pointed to the Installation from a Hard Drive section of the Fedora 10 documentation, which mentioned that install.img had to be present under the images/ directory in the partition from where Fedora 10 had to be installed.
On my 2nd attempt, I extracted the entire DVD iso and put it in the USB stick so that images/install.img would be found but doing only that didn’t work. In the 2nd phase of theinstallation, I was told that an image was missing. I just couldn’tunderstand what the hell was going on, so eventually, after a fewfurther email exchanges, I worked out what needed doing: First, images/install.img had to be in the USB stick and next to the images/ folder, you needed to have Fedora-10-i386-DVD.iso. So, here’re the instructions to install Fedora 10 from USB stick:
Installing Fedora 10 from USB stick
- Download Fedora-10-i386-DVD.iso
- Download Fedora-10-i386-netinst.iso
- Create 2 ext3 partitions in USB stick (Hint:GParted is a wicked graphical tool to create partitions): A 200 MBbootable partition and another partition with the rest of space.
- Copy Fedora-10-i386-netinst.iso to 1st partition:
1
livecd-iso-to-disk Fedora-10-i386-netinst.iso /dev/sdb1
- Extract images/ folder from Fedora-9-i386-DVD.iso and copy to 2nd partition:
1 2 3 4
mount -t iso9660 Fedora-10-i386-DVD.iso mnt-dvd/ -o loop mount /dev/sdb2 mnt-sdb2/ cp -rp mnt-dvd/images mnt-sdb2/ umount mnt-dvd/
Note: If you do a ‘cp -a’ as recommended in the Installing from Hard Drive section, you’ll get an error like this, so just use ‘cp -rp’ instead:
SELinux is preventing cp from creating a file with a context ofiso9660_t on a filesystem. Usually this happens when you ask the cpcommand to maintain the context of a file when copying between filesystems, “cp -a” for example. Not all file contexts should bemaintained between the file systems. For example, a read-only file typelike iso9660_t should not be placed on a r/w system. “cp -P” might be abetter solution, as this will adopt the default file context for thedestination. . - Copy DVD iso image to 2nd partition:
1 2
cp Fedora-10-i386-DVD.iso mnt-sdb2/ umount mnt-sdb2/
- Reboot with USB key inserted.
- Select install from Hard Drive and select /dev/sdb2
And that’s it. I’m fully aware that these instructions could besimplified/reduced but can’t be bothered to do that right now. It’s notsomething that I’m doing on a daily basis and it works, so I’m happy toleave them as they are for the time being. If anyone has anysuggestions, please feel free to comment.