Creating disk image for Jari OS

To create a correct disk image for Jari OS, follow the next steps:

$ dd if=/dev/zero of=hd.img bs=1024 count=262144 

This will create an empty image with 256Mb size.

$ sudo losetup /dev/loop0 hd.img 

Setup a fake device.

$ sudo echo -e "n\np\n1\n1\n32\na\n1\nw\n" | sudo fdisk /dev/loop0

Create partition on this image.

$ losetup --detach /dev/loop0 

Detach device.

$ sudo losetup --offset 32256 /dev/loop0 hd.img 

Attach with offset to first partition.

$ sudo mke2fs /dev/loop0 

Create ext2 file system.

$ mkdir tmp && sudo mount /dev/loop0 tmp 

Mount to local tmp directory.

$ sudo mkdir -p tmp/boot/grub tmp/dev tmp/pipe tmp/etc tmp/tmp tmp/env tmp/lib

Create all required directories.

$ sudo cp /boot/grub/stage* tmp/boot/grub/ && sudo cp /boot/grub/e2fs_stage1_5 tmp/boot/grub/

Copy grub files.

$ sudo jed tmp/boot/grub/menu.lst 

And fill it with the following content:

title           Jari OS                                                                                          
root            (hd0,0)                                                                                          
kernel          /boot/vmuielf                                                                                    
module          /boot/init.tar                                                                                   
module          /system/serv/nsv2.x.static                                                                       
module          /system/serv/vfsv2.x.static
module          /system/fs/init.fs.static                                                                        
module          /system/serv/procmgr.x.static                                                                    
module          /system/serv/btsdv2.x.static
$ sudo umount tmp && sudo losetup --detach /dev/loop0 

Umount image and detach device.

$ sudo grub 

And do the following commands:

device (hd0) hd.img
root (hd0,0)
setup (hd0)
quit

Well, image is ready now.