summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/packages/initrdscripts/files/init-install.sh154
-rw-r--r--meta/packages/initrdscripts/initramfs-live-install_1.0.bb14
2 files changed, 168 insertions, 0 deletions
diff --git a/meta/packages/initrdscripts/files/init-install.sh b/meta/packages/initrdscripts/files/init-install.sh
new file mode 100644
index 0000000000..4d90f457cd
--- /dev/null
+++ b/meta/packages/initrdscripts/files/init-install.sh
@@ -0,0 +1,154 @@
1#!/bin/sh -e
2#
3# Copyright (C) 2008 Intel
4#
5# install.sh [device_name] [rootfs_name] [video_mode] [vga_mode]
6#
7
8# We need 20 Mb for the boot partition
9boot_size=20
10
11# 5% for the swap
12swap_ratio=5
13
14found="no"
15
16echo "Searching for a hard drive..."
17for device in 'hda' 'hdb' 'sda' 'sdb'
18 do
19 if [ -e /sys/block/${device}/removable ]; then
20 if [ "$(cat /sys/block/${device}/removable)" = "0" ]; then
21 found="yes"
22
23 while true; do
24 echo "Found drive at /dev/${device}. Do you want to install moblin there ? [y/n]"
25 read answer
26 if [ "$answer" = "y" ] ; then
27 break
28 fi
29
30 if [ "$answer" = "n" ] ; then
31 found=no
32 break
33 fi
34
35 echo "Please answer by y or n"
36 done
37 fi
38 fi
39
40 if [ "$found" = "yes" ]; then
41 break;
42 fi
43
44done
45
46if [ "$found" = "no" ]; then
47 exit 1
48fi
49
50echo "Installing image on /dev/${device}"
51
52if [ ! -b /dev/sda ] ; then
53 mknod /dev/sda b 8 0
54fi
55
56if [ ! -b /dev/sdb ] ; then
57 mknod /dev/sdb b 8 16
58fi
59
60if [ ! -b /dev/loop0 ] ; then
61 mknod /dev/loop0 b 7 0
62fi
63
64mkdir -p /tmp
65cat /proc/mounts > /etc/mtab
66
67disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
68
69swap_size=$((disk_size*5/100))
70rootfs_size=$((disk_size-boot_size-swap_size))
71
72rootfs_start=$((boot_size + 1))
73rootfs_end=$((rootfs_start+rootfs_size))
74swap_start=$((rootfs_end+1))
75
76bootfs=/dev/${device}1
77rootfs=/dev/${device}2
78swap=/dev/${device}3
79
80echo "*****************"
81echo "Boot partition size: $boot_size MB (/dev/${device}1)"
82echo "Rootfs partition size: $rootfs_size MB (/dev/${device}2)"
83echo "Swap partition size: $swap_size MB (/dev/${device}3)"
84echo "*****************"
85echo "Deleting partition table on /dev/${device} ..."
86dd if=/dev/zero of=/dev/${device} bs=512 count=2
87
88echo "Creating new partition table on /dev/${device} ..."
89parted /dev/${device} mklabel msdos
90
91echo "Creating boot partition on /dev/${device}1"
92parted /dev/${device} mkpartfs primary ext2 0 $boot_size
93
94echo "Creating rootfs partition on /dev/${device}2"
95parted /dev/${device} mkpartfs primary ext2 $rootfs_start $rootfs_end
96
97echo "Creating swap partition on /dev/${device}3"
98parted /dev/${device} mkpartfs primary linux-swap $swap_start $disk_size
99
100parted /dev/${device} print
101
102echo "Formatting /dev/${device}1 to ext2..."
103mkfs.ext3 $bootfs
104
105echo "Formatting /dev/${device}2 to ext3..."
106mkfs.ext3 $rootfs
107
108echo "Formatting swap partition...(/dev/${device}3)"
109mkswap $swap
110
111mkdir /ssd
112mkdir /mnt
113
114mount $rootfs /ssd
115mount -o rw,loop,noatime,nodiratime /media/$1/$2 /mnt
116
117echo "Copying rootfs files..."
118cp -a /mnt/* /ssd
119
120if [ -d /ssd/etc/ ] ; then
121 echo "$swap swap swap defaults 0 0" >> /ssd/etc/fstab
122
123 # We dont want udev to mount our root device while we're booting...
124 if [ -d /ssd/etc/udev/ ] ; then
125 echo "/dev/${device}" >> /ssd/etc/udev/mount.blacklist
126 fi
127fi
128
129umount /ssd
130umount /mnt
131
132echo "Preparing boot partition..."
133mount $bootfs /ssd
134grub-install --root-directory=/ssd /dev/${device}
135
136echo "(hd0) /dev/${device}" > /ssd/boot/grub/device.map
137
138echo "default 0" > /ssd/boot/grub/menu.lst
139echo "timeout 30" >> /ssd/boot/grub/menu.lst
140echo "title Poky-Netbook" >> /ssd/boot/grub/menu.lst
141echo "root (hd0,0)" >> /ssd/boot/grub/menu.lst
142echo "kernel /boot/vmlinuz root=$rootfs rw video=$3 vga=$4 quiet" >> /ssd/boot/grub/menu.lst
143
144cp /media/$1/vmlinuz /ssd/boot/
145
146umount /ssd
147sync
148
149echo "Remove your installation media, and press ENTER"
150
151read enter
152
153echo "Rebooting..."
154reboot -f
diff --git a/meta/packages/initrdscripts/initramfs-live-install_1.0.bb b/meta/packages/initrdscripts/initramfs-live-install_1.0.bb
new file mode 100644
index 0000000000..f772e3b047
--- /dev/null
+++ b/meta/packages/initrdscripts/initramfs-live-install_1.0.bb
@@ -0,0 +1,14 @@
1DESCRIPTON = "A live image init script"
2
3SRC_URI = "file://init-install.sh"
4
5PR = "r1"
6
7RDEPENDS="grub parted e2fsprogs-mke2fs"
8
9do_install() {
10 install -m 0755 ${WORKDIR}/init-install.sh ${D}/install.sh
11}
12
13PACKAGE_ARCH = "all"
14FILES_${PN} = " /install.sh "