[fedora-virt] P2V and grub bootloader

Richard W.M. Jones rjones at redhat.com
Fri May 1 15:36:10 UTC 2009


Here's an example where I've used a separate /boot partition and root
is on an LV:

-------------------------------------------------- /tmp/test.sh 
#!/bin/sh -

guestfish <<EOF
alloc /tmp/test.img 500MB
run
sfdisk /dev/sda 0 0 0 ",10 ,"

echo Size of /dev/sda1:
blockdev-getsize64 /dev/sda1
echo Size of /dev/sda2:
blockdev-getsize64 /dev/sda2

mkfs ext2 /dev/sda1
pvcreate /dev/sda2
vgcreate VG /dev/sda2
lvcreate LV VG 400M
mkfs ext2 /dev/VG/LV

mount /dev/VG/LV /
mkdir /boot
mount /dev/sda1 /boot

grub-install / /dev/sda

echo Grub is installed on /dev/sda
ll /boot
ll /boot/grub
EOF

ls -l /tmp/test.img
file /tmp/test.img
--------------------------------------------------

$ time /tmp/test.sh 
qemu: loading initrd (0x15b0097 bytes) at 0x000000000b53f000
Size of /dev/sda1:
82252288
Size of /dev/sda2:
435939840
Grub is installed on /dev/sda
total 15
drwxr-xr-x 4 root root  1024 May  1 10:58 .
drwxr-xr-x 4 root root  1024 May  1 10:58 ..
drwxr-xr-x 2 root root  1024 May  1 10:58 grub
drwx------ 2 root root 12288 May  1 10:58 lost+found

total 236
drwxr-xr-x 2 root root   1024 May  1 10:58 .
drwxr-xr-x 4 root root   1024 May  1 10:58 ..
-rw-r--r-- 1 root root     30 May  1 10:58 device.map
-rw-r--r-- 1 root root  11736 May  1 10:58 e2fs_stage1_5
-rw-r--r-- 1 root root  11512 May  1 10:58 fat_stage1_5
-rw-r--r-- 1 root root  10744 May  1 10:58 ffs_stage1_5
-rw-r--r-- 1 root root  10736 May  1 10:58 iso9660_stage1_5
-rw-r--r-- 1 root root  12328 May  1 10:58 jfs_stage1_5
-rw-r--r-- 1 root root  10968 May  1 10:58 minix_stage1_5
-rw-r--r-- 1 root root  13360 May  1 10:58 reiserfs_stage1_5
-rw-r--r-- 1 root root    512 May  1 10:58 stage1
-rw-r--r-- 1 root root 111004 May  1 10:58 stage2
-rw-r--r-- 1 root root  11008 May  1 10:58 ufs2_stage1_5
-rw-r--r-- 1 root root  10344 May  1 10:58 vstafs_stage1_5
-rw-r--r-- 1 root root  12984 May  1 10:58 xfs_stage1_5

-rw-rw-r--. 1 rjones rjones 524288000 2009-05-01 15:58 /tmp/test.img
/tmp/test.img: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, 1st sector stage2 0x4c03, GRUB version 0.94; partition 1: ID=0x83, starthead 0, startsector 1, 160649 sectors; partition 2: ID=0x83, starthead 0, startsector 160650, 851445 sectors, code offset 0x48

real	       0m48.690s
user	       0m0.057s
sys	       0m3.109s


-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw




More information about the virt mailing list