summaryrefslogtreecommitdiff
path: root/create_installroot/create_image.sh
blob: 2b9afa1e4c639a549082b0fea7c32a0b6f23c3f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/dash
set -x

IMG_NAME=xos_image
LOOP_NUM=0
LOOP=/dev/mapper/loop${LOOP_NUM}

dd if=/dev/zero of=${IMG_NAME}.img bs=1048576 count=256
parted --script ${IMG_NAME}.img mklabel msdos mkpart p ext2 1 128 mkpart p ext4 128 256 set 1 boot on 

kpartx -a ${IMG_NAME}.img
ls /dev/mapper/loop*

mkfs.ext2 -F ${LOOP}p1
mkfs.ext4 -F ${LOOP}p2


mkdir -p /mnt/disk0
mount ${LOOP}p1 /mnt/disk0/
grub-install --target=i386-pc --recheck --no-floppy --root-directory=/mnt/disk0 --modules="biosdisk part_msdos ext2 configfile normal multiboot" /dev/loop${LOOP_NUM}
mkdir -p /mnt/disk0/bin
cp bootfs/bin/sh /mnt/disk0/bin/
cp bootfs/bin/init /mnt/disk0/bin/
cp bootfs/vmlinuz-xos /mnt/disk0/
ls /mnt/disk0/bin

mkdir -p /mnt/disk1
mount ${LOOP}p2 /mnt/disk1/

cp -r rootfs/* /mnt/disk1/
ls /mnt/disk1/bin/

#nano /mnt/disk0/boot/grub/grub.cfg
cp bootfs/grub.cfg /mnt/disk0/boot/grub/grub.cfg
umount /mnt/disk0
umount /mnt/disk1
kpartx -d ${IMG_NAME}.img

chown fam ${IMG_NAME}.img
chgrp fam ${IMG_NAME}.img