全部博文(1159)
分类: LINUX
2010-03-18 09:17:41
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
The aim of this post is to explain how to install Fedora directly from a USB stick containing the Fedora*-DVD.iso image. For those impatient, just go to the Instructions section.
It’s been almost 2 years since I said goodbye to Windows and moved my work laptop to Fedora, and I couldn’t be happier with the move. If you wanna find out why I’m happier with Fedora, just carry on reading my blog over the coming months. For the moment, I’ll be focusing on the Fedora installation process. One of the best things about Fedora is that it gets released twice a year so you keep upgrading your machine to the get the latest features, latest bugs…etc. This means that you end up downloading and burning a Fedora ISO into a brand new DVD every 6 months. As you can imagine, I was quickly piling up DVDs that were useless soon after. So, after having looking around in electronic shops, I realised that USB keys had gone down in price and that you could get an 8GB USB stick for little money. This happened at the same time that I was getting a new laptop at work, so I wondered, what about I get myself one of those sticks, put the latest Fedora image on it and install it from there rather than burning yet another DVD? For sure, installing from an USB key was always going to be faster than from a DVD, 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 when trying to create the bootable partition in the USB stick, so I ended up writing my own set of instructions for Fedora 9:
1 |
livecd-iso-to-disk Fedora-9-i386-netinst.iso /dev/sdb1 |
1 2 3 |
mount /dev/sdb2 mnt-sdb2/ cp Fedora-9-i386-DVD.iso mnt-sdb2/ umount mnt-sdb2/ |
When Fedora 10 was released, I followed the same steps to install as I did for Fedora 9 but I kept getting an error saying that no image could be found in /dev/sdb2 even though the Fedora 10 DVD iso image was there and had passed the SHA1SUM test successfully. After exchanging 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 the installation, I was told that an image was missing. I just couldn’t understand what the hell was going on, so eventually, after a few further 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:
1 |
livecd-iso-to-disk Fedora-10-i386-netinst.iso /dev/sdb1 |
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 , you’ll get an error like this, so just use ‘cp -rp’ instead:
SELinux is preventing cp from creating a file with a context of
iso9660_t on a filesystem. Usually this happens when you ask the cp
command to maintain the context of a file when copying between file
systems, “cp -a” for example. Not all file contexts should be
maintained between the file systems. For example, a read-only file type
like iso9660_t should not be placed on a r/w system. “cp -P” might be a
better solution, as this will adopt the default file context for the
destination. .
1 2 |
cp Fedora-10-i386-DVD.iso mnt-sdb2/ umount mnt-sdb2/ |
And that’s it. I’m fully aware that these instructions could be simplified/reduced but can’t be bothered to do that right now. It’s not something that I’m doing on a daily basis and it works, so I’m happy to leave them as they are for the time being. If anyone has any suggestions, please feel free to comment.
chinaunix网友2010-09-10 17:04:12
张老师,您好 我想请教一个问题,CentOS的镜像为4.3G左右,而FAT32格式的U盘却不允许复制单文件大于4G的文件,请问怎样才能把镜像拷到U盘上?