U盘启动器:
目的:安装grub到u盘,用u盘来维护系统
条件:1、电脑设为从USB设备启动。
2、要有一个Linux系统来安装Grub.
3、当然这个U盘要为此次行动做出牺牲。(呵呵,赶紧将重要资料转移吧~~)
实施步骤:
1、插入U盘,fdisk查看是否检测到U盘。
[star@localhost ~]$ sudo fdisk -l
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Disk identifier: 0xd10cd10c
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5540 44500018+ c W95 FAT32 (LBA)
/dev/sda2 5541 30401 199695982+ f W95 Ext'd (LBA)
/dev/sda3 22465 29878 59552955 c W95 FAT32 (LBA)
/dev/sda5 5541 13285 62211681 7 HPFS/NTFS
/dev/sda6 * 13286 22464 73730286 83 Linux
/dev/sda7 29879 30401 4200966 82 Linux swap / Solaris
Disk /dev/sdb: 4022 MB, 4022337024 bytes
255 heads, 63 sectors/track, 489 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Disk identifier: 0x000f4b77
Device Boot Start End Blocks Id System
/dev/sdb1 1 490 3928032 b W95 FAT32
Partition 1 has different physical/logical endings:
phys=(488, 254, 63) logical=(489, 5, 27)
2、先给u盘分区,分区方案自己照自己情况,这里以/dev/sdb1上安装grub为例。
[star@localhost ~]$ sudo fdisk /dev/sdb
Command (m for help): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-489, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-489, default 489): +500M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (66-489, default 66):
Using default value 66
Last cylinder, +cylinders or +size{K,M,G} (66-489, default 489):
Using default value 489
Command (m for help): p
Disk /dev/sdb: 4022 MB, 4022337024 bytes
255 heads, 63 sectors/track, 489 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Disk identifier: 0x000f4b77
Device Boot Start End Blocks Id System
/dev/sdb1 1 65 522081 83 Linux
/dev/sdb2 66 489 3405780 83 Linux
Command (m for help): a (这一步很重要,就是要激活该分区)
Partition number (1-4): 1
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3、格式化,即创建文件系统,我这里以ext3为例:
[star@localhost ~]$ sudo mkfs -t ext3 /dev/sdb1
mke2fs 1.41.10 (10-Feb-2009)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
130560 inodes, 522080 blocks
26104 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
64 block groups
8192 blocks per group, 8192 fragments per group
2040 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
4、挂载系统:
[star@localhost ~]$ sudo mkdir /media/test
[star@localhost ~]$ sudo mount -t ext3 /dev/sdb1 /media/test/
5、安装Grub到U盘上:
[star@localhost ~]$ sudo grub-install --root-directory=/media/test/ /dev/sdb
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported.
This is the contents of the device map /media/test//boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb
6、复制当前系统的menu.lst到u盘grub下:
[star@localhost ~]$ sudo cp /boot/grub/menu.lst /media/test/boot/grub/
7、根据实际情况修改menu.lst。
8、安装grub到MBR:
[star@localhost ~]$ sudo grub
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> find /boot/grub/stage1
(hd0,5)
(hd1,0)
grub> root (hd1,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 19 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd1) (hd1)1+19 p (hd1,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.
grub> quit
9、卸载就OK了,即完成了。以后就可以使用这个U盘来引导或修复系统了。
<script type="text/javascript" id="wumiiRelatedItems"> </script>
转发至微博
转发至微博
关闭
玩LOFTER,免费冲印20张照片,人人有奖!
我要抢>
U盘启动器:
目的:安装grub到u盘,用u盘来维护系统
条件:1、电脑设为从USB设备启动。
2、要有一个Linux系统来安装Grub.
3、当然这个U盘要为此次行动做出牺牲。(呵呵,赶紧将重要资料转移吧~~)
实施步骤:
1、插入U盘,fdisk查看是否检测到U盘。
[star@localhost ~]$ sudo fdisk -l
Disk /dev/sda: 250.1 GB, 250059350016 bytes
', blogTag:'', blogUrl:'blog/static/18351930820112171500149', isPublished:1, istop:false, type:0, modifyTime:0, publishTime:1300341000149, permalink:'blog/static/18351930820112171500149', commentCount:0, mainCommentCount:0, recommendCount:0, bsrk:-100, publisherId:0, recomBlogHome:false, currentRecomBlog:false, attachmentsFileIds:[], vote:{}, groupInfo:{}, friendstatus:'none', followstatus:'unFollow', pubSucc:'', visitorProvince:'', visitorCity:'', visitorNewUser:false, postAddInfo:{}, mset:'000', mcon:'', srk:-100, remindgoodnightblog:false, isBlackVisitor:false, isShowYodaoAd:false, hostIntro:'', hmcon:'0', selfRecomBlogCount:'0', lofter_single:'' }
{/if} {/list}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{/if}
评论