Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 115 lines (89 sloc) 3.567 kb
7e2faef minor tweeks, verified to work without additional tricks
Brian LaMere authored
1 #!/bin/sh
2 # Version 0.7
3 # version0.1 from: http://www.ioncannon.net/system-administration/894/fedora-12-bootable-root-ebs-on-ec2/
4
5 # assumptions: you're on an amazon instance that has an extra EBS mounted at /dev/sdf
6
7 #from a base install, I need e2fsprogs; remove the next line if you're not on a yum system
8 yum -y install e2fsprogs
9
10 ##########FILESYSTEMS SECTION##############
11 # forgive me, I used gentoo years ago during a period - came back to fedora, though!
12
13 #if you want to actually partition out your ebs...
14 #echo -e "o\nn\np\n1\n1\n+100M\nn\np\n2\n\n+2G\nt\n2\n82\nn\np\n3\n\n\na\n1\nw\n" | fdisk /dev/xvdf
15
16 echo -e "o\nw\n" | fdisk /dev/xvdf
9acad12 simple change to mkfs
Brian LaMere authored
17 mkfs.ext3 -F /dev/xvdf
7e2faef minor tweeks, verified to work without additional tricks
Brian LaMere authored
18
19 mkdir /mnt/chroot
20 mount /dev/xvdf /mnt/chroot
21 mkdir /mnt/chroot/dev /mnt/chroot/proc /mnt/chroot/etc /mnt/chroot/sys
22 mount -o bind /dev /mnt/chroot/dev
23 mount -o bind /dev/pts /mnt/chroot/dev/pts
24 mount -o bind /dev/shm /mnt/chroot/dev/shm
25 mount -o bind /proc /mnt/chroot/proc
26 mount -o bind /sys /mnt/chroot/sys
27
28 cat <<EOL > /mnt/chroot/etc/fstab
29 /dev/xvda / ext4 relatime 1 1
30 none /dev/pts devpts gid=5,mode=620 0 0
31 none /dev/shm tmpfs defaults 0 0
32 none /proc proc defaults 0 0
33 none /sys sysfs defaults 0 0
34 EOL
35
36 cat <<EOL > /tmp/yumec2.conf
37 [main]
38 cachedir=/var/cache/yum
39 debuglevel=2
40 logfile=/var/log/yum.log
41 exclude=*-debuginfo
42 gpgcheck=0
43 obsoletes=1
44 reposdir=/dev/null
45
46 [base]
47 name=Fedora 14 – x86_64 – Base
48 mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-14&arch=x86_64
49 enabled=1
50
51 [updates-released]
52 name=Fedora 14 – x86_64 – Released Updates
53 mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f14&arch=x86_64
54 enabled=1
55 EOL
56
57 yum -c /tmp/yumec2.conf --installroot=/mnt/chroot -y install grub grubby
58 yum -c /tmp/yumec2.conf --installroot=/mnt/chroot -y groupinstall Base
59 yum -c /tmp/yumec2.conf --installroot=/mnt/chroot -y install openssh-server kernel-headers kernel-PAE
60 yum -c /tmp/yumec2.conf --installroot=/mnt/chroot -y clean packages
61
62 echo "UseDNS no" >> /mnt/chroot/etc/ssh/sshd_config
63 echo "PermitRootLogin without-password" >> /mnt/chroot/etc/ssh/sshd_config
64
65 cp /etc/rc.local /mnt/chroot/etc/
66 cp /etc/sysconfig/network /mnt/chroot/etc/sysconfig/network
67 cp /etc/sysconfig/network-scripts/ifcfg-eth0 /mnt/chroot/etc/sysconfig/network-scripts/ifcfg-eth0
68
69 cat <<EOF >> /mnt/chroot/etc/rc.sysinit
70
71 # below lines added for setting up a couple devices on ebs
72 # later, will make this sexier
73 mknod -m 0644 /dev/random c 1 8
74 chown root:root /dev/random
75 mknod -m 0644 /dev/urandom c 1 9
76 chown root:root /dev/urandom
77
78 #echo -e "o\nn\np\n1\n1\n+10G\nt\n1\n82\nn\np\n2\n\n\nw\n" | fdisk /dev/xvdc
79 #echo "y" | mkfs.ext4 /dev/xvdc2
80 #mkswap /dev/xvdc1
81 EOF
82
83 chroot /mnt/chroot chkconfig --level 2345 NetworkManager off
84 chroot /mnt/chroot chkconfig --level 2345 network on
85
86 # here's the trick...what should /boot look like? answer: plain as hell
87 cat <<EOL > /mnt/chroot/boot/grub/grub.conf
88
89 default=0
90 timeout=0
91 title Fedora14
92 root (hd0)
93 kernel /boot/vmlinuz ro root=/dev/xvda1 rd_NO_PLYMOUTH selinux=0
94 initrd /boot/initramfs
95 EOL
96
97 chroot /mnt/chroot ln -s /boot/grub/grub.conf /boot/grub/menu.lst
98
99 kern=`ls /mnt/chroot/boot/vmlin*|awk -F/ '{print $NF}'`
1389f5d They added a initrd-plymouth.img file...darn them.
Brian LaMere authored
100 ird=`ls /mnt/chroot/boot/initramfs*.img|awk -F/ '{print $NF}'`
7e2faef minor tweeks, verified to work without additional tricks
Brian LaMere authored
101
102 sed -ie "s/vmlinuz/$kern/" /mnt/chroot/boot/grub/grub.conf
103 sed -ie "s/initramfs/$ird/" /mnt/chroot/boot/grub/grub.conf
104
105 sync
106
107 umount /mnt/chroot/dev/shm
108 umount /mnt/chroot/dev/pts
109 umount /mnt/chroot/sys
110 umount /mnt/chroot/proc
111 umount /mnt/chroot/dev
112 umount /mnt/chroot
113
114 echo "I...I think we've done it."
Something went wrong with that request. Please try again.