diff options
author | Samuel Ortiz <sameo@openedhand.com> | 2008-10-08 14:30:16 +0000 |
---|---|---|
committer | Samuel Ortiz <sameo@openedhand.com> | 2008-10-08 14:30:16 +0000 |
commit | 864a4adacfdab389ca0492463d6238f9360dd903 (patch) | |
tree | 3976085ee82098e0fdb9c550f2271c8be65131b1 /meta/packages/initrdscripts | |
parent | 1ed1a58d623ee7638126cb32659d6512d1260945 (diff) | |
download | poky-864a4adacfdab389ca0492463d6238f9360dd903.tar.gz |
initramfs-live-install: Initial commit
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@5455 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/initrdscripts')
-rw-r--r-- | meta/packages/initrdscripts/files/init-install.sh | 154 | ||||
-rw-r--r-- | meta/packages/initrdscripts/initramfs-live-install_1.0.bb | 14 |
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 | ||
9 | boot_size=20 | ||
10 | |||
11 | # 5% for the swap | ||
12 | swap_ratio=5 | ||
13 | |||
14 | found="no" | ||
15 | |||
16 | echo "Searching for a hard drive..." | ||
17 | for 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 | |||
44 | done | ||
45 | |||
46 | if [ "$found" = "no" ]; then | ||
47 | exit 1 | ||
48 | fi | ||
49 | |||
50 | echo "Installing image on /dev/${device}" | ||
51 | |||
52 | if [ ! -b /dev/sda ] ; then | ||
53 | mknod /dev/sda b 8 0 | ||
54 | fi | ||
55 | |||
56 | if [ ! -b /dev/sdb ] ; then | ||
57 | mknod /dev/sdb b 8 16 | ||
58 | fi | ||
59 | |||
60 | if [ ! -b /dev/loop0 ] ; then | ||
61 | mknod /dev/loop0 b 7 0 | ||
62 | fi | ||
63 | |||
64 | mkdir -p /tmp | ||
65 | cat /proc/mounts > /etc/mtab | ||
66 | |||
67 | disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") | ||
68 | |||
69 | swap_size=$((disk_size*5/100)) | ||
70 | rootfs_size=$((disk_size-boot_size-swap_size)) | ||
71 | |||
72 | rootfs_start=$((boot_size + 1)) | ||
73 | rootfs_end=$((rootfs_start+rootfs_size)) | ||
74 | swap_start=$((rootfs_end+1)) | ||
75 | |||
76 | bootfs=/dev/${device}1 | ||
77 | rootfs=/dev/${device}2 | ||
78 | swap=/dev/${device}3 | ||
79 | |||
80 | echo "*****************" | ||
81 | echo "Boot partition size: $boot_size MB (/dev/${device}1)" | ||
82 | echo "Rootfs partition size: $rootfs_size MB (/dev/${device}2)" | ||
83 | echo "Swap partition size: $swap_size MB (/dev/${device}3)" | ||
84 | echo "*****************" | ||
85 | echo "Deleting partition table on /dev/${device} ..." | ||
86 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 | ||
87 | |||
88 | echo "Creating new partition table on /dev/${device} ..." | ||
89 | parted /dev/${device} mklabel msdos | ||
90 | |||
91 | echo "Creating boot partition on /dev/${device}1" | ||
92 | parted /dev/${device} mkpartfs primary ext2 0 $boot_size | ||
93 | |||
94 | echo "Creating rootfs partition on /dev/${device}2" | ||
95 | parted /dev/${device} mkpartfs primary ext2 $rootfs_start $rootfs_end | ||
96 | |||
97 | echo "Creating swap partition on /dev/${device}3" | ||
98 | parted /dev/${device} mkpartfs primary linux-swap $swap_start $disk_size | ||
99 | |||
100 | parted /dev/${device} print | ||
101 | |||
102 | echo "Formatting /dev/${device}1 to ext2..." | ||
103 | mkfs.ext3 $bootfs | ||
104 | |||
105 | echo "Formatting /dev/${device}2 to ext3..." | ||
106 | mkfs.ext3 $rootfs | ||
107 | |||
108 | echo "Formatting swap partition...(/dev/${device}3)" | ||
109 | mkswap $swap | ||
110 | |||
111 | mkdir /ssd | ||
112 | mkdir /mnt | ||
113 | |||
114 | mount $rootfs /ssd | ||
115 | mount -o rw,loop,noatime,nodiratime /media/$1/$2 /mnt | ||
116 | |||
117 | echo "Copying rootfs files..." | ||
118 | cp -a /mnt/* /ssd | ||
119 | |||
120 | if [ -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 | ||
127 | fi | ||
128 | |||
129 | umount /ssd | ||
130 | umount /mnt | ||
131 | |||
132 | echo "Preparing boot partition..." | ||
133 | mount $bootfs /ssd | ||
134 | grub-install --root-directory=/ssd /dev/${device} | ||
135 | |||
136 | echo "(hd0) /dev/${device}" > /ssd/boot/grub/device.map | ||
137 | |||
138 | echo "default 0" > /ssd/boot/grub/menu.lst | ||
139 | echo "timeout 30" >> /ssd/boot/grub/menu.lst | ||
140 | echo "title Poky-Netbook" >> /ssd/boot/grub/menu.lst | ||
141 | echo "root (hd0,0)" >> /ssd/boot/grub/menu.lst | ||
142 | echo "kernel /boot/vmlinuz root=$rootfs rw video=$3 vga=$4 quiet" >> /ssd/boot/grub/menu.lst | ||
143 | |||
144 | cp /media/$1/vmlinuz /ssd/boot/ | ||
145 | |||
146 | umount /ssd | ||
147 | sync | ||
148 | |||
149 | echo "Remove your installation media, and press ENTER" | ||
150 | |||
151 | read enter | ||
152 | |||
153 | echo "Rebooting..." | ||
154 | reboot -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 @@ | |||
1 | DESCRIPTON = "A live image init script" | ||
2 | |||
3 | SRC_URI = "file://init-install.sh" | ||
4 | |||
5 | PR = "r1" | ||
6 | |||
7 | RDEPENDS="grub parted e2fsprogs-mke2fs" | ||
8 | |||
9 | do_install() { | ||
10 | install -m 0755 ${WORKDIR}/init-install.sh ${D}/install.sh | ||
11 | } | ||
12 | |||
13 | PACKAGE_ARCH = "all" | ||
14 | FILES_${PN} = " /install.sh " | ||