Tuesday, January 22, 2013



Grub2 installing in virtual disk





-----------------------------------------------------------------------------------------------------------------------------------------------------

Step1:
$ dd if=/dev/zero  of=hd.img bs=2048 count=100000
$ fdisk hd.img
$ m
$ n
$ p
$ 1
$ m
$ n
$ 2
$ m
$ t
$ 2
$ l
$ 8e
after that
$ p
Device Boot      Start         End      Blocks   Id  System
hd.img1            2048      299999      148976   83  Linux
hd.img2          300000      399999       50000   8e  Linux LVM



$ kpartx -a hd.img
>next give loop support
$ losetup /dev/loop0 hd.img
$ mkfs.ext4 /dev/loop0
$ mount -v -t ext4 /dev/loop0 /mnt/lfs
copy all file system files in mounting directory
as well as create a directories in mounting directory
mkdir -p /mnt/lfs/dev
mkdir -p /mnt/lfs/proc
mkdir -p /mnt/lfs/sys
mknod -m 600 /mnt/lfs/dev/console c 5 1
mknod -m 666 /mnt/lfs/dev/null c 1 3

next
$ echo “(hd0) /dev/loop0  > device.map
$ echo “set prefix=(hd0)/boot/grub >mycfg.cfg
$ /mnt/grub2/bin/grub-mkimage --config=mycfg.cfg-p /boot -O i386-pc  -o /mnt/lfs/boot/grub/core.img  loadenv chain biosdisk part_dvh part_msdos msdospart part_gpt exfat ext2 fat vbe vga ntfs echo test configfile minicmd hdparm normal multiboot

$ /mnt/grub2/lib/grub/i386-pc/boot.img /mnt/lfs/boot/grub
$ /mnt/grub2/sbin/grub-bios-setup -m device.map -d /mnt/lfs/boot/grub /dev/loop0
umount /mnt/lfs
kpartx -d hd.img


$ qemu-system-i386 -hda hd.img
$ qemu-system-i386 -hda /dev/loop0


No comments:

Post a Comment