Installing the GRUB2 on the QEMU

Source: Internet
Author: User

Environment: ubuntu14.04 qemu-2.0.0

1. Create a disk File
sudo dd if=/dev/zero of=disk.img bs=4096 count=8192

2. Virtual Disk file as a loop block device
sudo losetup/dev/loop1 disk.img

3. Partitioning the disk File
sudo fdisk/dev/loop1
Command execution Result:
Command (enter M for help): N
Partition Type:
P Primary (0 primary, 0 extended, 4 free)
E Extended
Select (default p): P
Partition code (1-4, default = 1):
The default value of 1 will be used
Starting sector (2048-65535, default = 2048):
The default value of 2048 will be used
Last sector, + sector or +size{k,m,g} (2048-65535, default = 65535):
The default value of 65535 will be used
Command (enter M for help): Wq
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Warning:re-reading the partition table failed with error 22: invalid parameter.
The kernel still uses the old table. The new table is being used at
The next reboot or after you run Partprobe (8) or KPARTX (8)
Syncing disks.
4. Format the disk File
sudo mkfs.ext4/dev/loop1
Command execution Result:
MKE2FS 1.42.9 (4-feb-2014)
Discarding device blocks: complete
File System label =
OS Type:linux
Block size =1024 (log=0)
Chunked size =1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
8192 inodes, 32768 blocks
1638 blocks (5.00%) reserved for the Super user
First block of data =1
Maximum filesystem blocks=33554432
4 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577
Allocating group tables: complete
Writing Inode table: complete
Creating Journal (4096 blocks): complete
Writing Superblocks and FileSystem accounting information: Complete
5. Mount the disk file to the local file system
sudo mount/dev/loop1/mnt

6. Create a startup directory
sudo mkdir/mnt/boot

7. Install GRUB2 to startup directory
sudo grub-install–boot-directory=/mnt/boot–force dev/loop1
Command execution Result:
Installing for I386-PC platform.
Grub-install:warning:file system ' ext2 ' doesn ' t support embedding.
Grub-install:warning: Unable to embed. In this installation, GRUB can only be installed by using a block list. However, the Block list is not trustworthy and is not recommended for use.
Installation finished. No Error reported.

8. Solution Mount
sudo umount/mnt

9. Solution Device Virtual
sudo losetup-d/dev/loop1

10. Run Start QEMU
sudo qemu-system-i386-hda disk.img

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.