Browse Source

Add initramfs portion

Hal Emmerich 5 years ago
parent
commit
bc70fab889
1 changed files with 18 additions and 18 deletions
  1. 18 18
      scripts/buildFilesystem.sh

+ 18 - 18
scripts/buildFilesystem.sh

@@ -67,26 +67,25 @@ create_image() {
   dd if=/dev/zero of=$1 bs=$3 count=$4 conv=sparse
   parted --script $1 mklabel gpt
   cgpt create $1
-  cgpt add -i 1 -t kernel -b 8192 -s 65536 -l Kernel -S 1 -T 5 -P 10 $1
-  boot_start=$((8192 + 65536))
-  boot_end=`cgpt show $1 | grep 'Sec GPT table' | awk '{print $1}'`
-  size=$(($boot_end - $boot_start))
-  #create the initramfs partiton, aka /boot
-  boot_start=$(($start + $size))
+  kernel_start=8192
+  kernel_size=65536
   boot_size=409600 # 200 MB
+  cgpt add -i 1 -t kernel -b $kernel_start -s $kernel_size -l Kernel -S 1 -T 5 -P 10 $1
+  #create the initramfs partiton, aka /boot
+  boot_start=$(($kernel_start + $kernel_size))
   cgpt add -i 2 -t data -b $boot_start -s $boot_size -l Boot $1
   #Now the main filesystem
   root_start=$(($boot_start + $boot_size))
   end=`cgpt show $1 | grep 'Sec GPT table' | awk '{print $1}'`
   root_size=$(($end - $root_start))
-  cgpt add -i 3 -t data -b $start -s $size -l Root $1
+  cgpt add -i 3 -t data -b $root_start -s $root_size -l Root $1
   # $size is in 512 byte blocks while ext4 uses a block size of 1024 bytes
   losetup -P $2 $1
   mkfs.ext4 -F -b 1024 -m 0 ${2}p2 $(($boot_size / 2))
   mkfs.ext4 -F -b 1024 -m 0 ${2}p3 $(($root_size / 2))
 
   # mount the / partition
-  mount -o noatime ${2}p2 $5
+  mount -o noatime ${2}p3 $5
 
   # mount the /boot partiton
   mkdir -p $5/boot
@@ -168,22 +167,23 @@ chroot $outmnt apt install -y initscripts udev kmod net-tools inetutils-ping tra
 
 #make the initramfs image that gets copied to partiton 2
 #make a skeleton filesystem
-initramfs_src=/usr/src/initramfs
-chroot $outmnt mkdir -p $initramfs_src
-chroot $outmnt mkdir $initramfs_src/{bin,dev,etc,newroot,proc,sys,sbin,run,lib,lib/arm-linux-gnueabihf}
+initramfs_src=$outmnt/usr/src/initramfs
+mkdir -p $initramfs_src/
+mkdir ${initramfs_src}/{bin,dev,etc,newroot,proc,sys,sbin,run,lib}
+mkdir $initramfs_src/lib/arm-linux-gnueabihf
 #install the few tools we need
-chroot $outmnt cp /bin/busybox /sbin/cryptsetup $initramfs_src/bin/
-chroot $outmnt cp /lib/arm-linux-gnueabihf/{libblkid.so.1,libc.so.6,libuuid.so.1} $initramfs_src/lib/arm-linux-gnueabihf/
-chroot $outmnt cp /lib/ld-linux-armhf.so.3 $initramfs_src/lib/
-chroot $outmnt cp /sbin/blkid $initramfs_src/bin/
+cp $outmnt/bin/busybox $outmnt/sbin/cryptsetup $initramfs_src/bin/
+cp ${outmnt}/lib/arm-linux-gnueabihf/{libblkid.so.1,libc.so.6,libuuid.so.1} ${initramfs_src}/lib/arm-linux-gnueabihf/
+cp $outmnt/lib/ld-linux-armhf.so.3 $initramfs_src/lib/
+cp $outmnt/sbin/blkid $initramfs_src/bin/
 
 #add the init script
-cp $build_resources/initramfs-init $outmnt/$initramfs_src/init
-chroot $outmnt chmod +x $initramfs_src/init
+cp $build_resources/initramfs-init $initramfs_src/init
+chmod +x $initramfs_src/init
 
 #compress and install
 #TODO, make this correct
-chroot $outmnt find $initramfs_src -print0 | cpio --null --create --verbose --format=newc | gzip --best > /boot/PrawnOS-initramfs.cpio.gz 
+find $initramfs_src -print0 | cpio --null --create --verbose --format=newc | gzip --best > $outmnt/boot/PrawnOS-initramfs.cpio.gz 
 
 
 #add the live-boot fstab