Add initramfs portion
This commit is contained in:
		
							parent
							
								
									a61a66718f
								
							
						
					
					
						commit
						bc70fab889
					
				@ -67,26 +67,25 @@ create_image() {
 | 
				
			|||||||
  dd if=/dev/zero of=$1 bs=$3 count=$4 conv=sparse
 | 
					  dd if=/dev/zero of=$1 bs=$3 count=$4 conv=sparse
 | 
				
			||||||
  parted --script $1 mklabel gpt
 | 
					  parted --script $1 mklabel gpt
 | 
				
			||||||
  cgpt create $1
 | 
					  cgpt create $1
 | 
				
			||||||
  cgpt add -i 1 -t kernel -b 8192 -s 65536 -l Kernel -S 1 -T 5 -P 10 $1
 | 
					  kernel_start=8192
 | 
				
			||||||
  boot_start=$((8192 + 65536))
 | 
					  kernel_size=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))
 | 
					 | 
				
			||||||
  boot_size=409600 # 200 MB
 | 
					  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
 | 
					  cgpt add -i 2 -t data -b $boot_start -s $boot_size -l Boot $1
 | 
				
			||||||
  #Now the main filesystem
 | 
					  #Now the main filesystem
 | 
				
			||||||
  root_start=$(($boot_start + $boot_size))
 | 
					  root_start=$(($boot_start + $boot_size))
 | 
				
			||||||
  end=`cgpt show $1 | grep 'Sec GPT table' | awk '{print $1}'`
 | 
					  end=`cgpt show $1 | grep 'Sec GPT table' | awk '{print $1}'`
 | 
				
			||||||
  root_size=$(($end - $root_start))
 | 
					  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
 | 
					  # $size is in 512 byte blocks while ext4 uses a block size of 1024 bytes
 | 
				
			||||||
  losetup -P $2 $1
 | 
					  losetup -P $2 $1
 | 
				
			||||||
  mkfs.ext4 -F -b 1024 -m 0 ${2}p2 $(($boot_size / 2))
 | 
					  mkfs.ext4 -F -b 1024 -m 0 ${2}p2 $(($boot_size / 2))
 | 
				
			||||||
  mkfs.ext4 -F -b 1024 -m 0 ${2}p3 $(($root_size / 2))
 | 
					  mkfs.ext4 -F -b 1024 -m 0 ${2}p3 $(($root_size / 2))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # mount the / partition
 | 
					  # mount the / partition
 | 
				
			||||||
  mount -o noatime ${2}p2 $5
 | 
					  mount -o noatime ${2}p3 $5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # mount the /boot partiton
 | 
					  # mount the /boot partiton
 | 
				
			||||||
  mkdir -p $5/boot
 | 
					  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 the initramfs image that gets copied to partiton 2
 | 
				
			||||||
#make a skeleton filesystem
 | 
					#make a skeleton filesystem
 | 
				
			||||||
initramfs_src=/usr/src/initramfs
 | 
					initramfs_src=$outmnt/usr/src/initramfs
 | 
				
			||||||
chroot $outmnt mkdir -p $initramfs_src
 | 
					mkdir -p $initramfs_src/
 | 
				
			||||||
chroot $outmnt mkdir $initramfs_src/{bin,dev,etc,newroot,proc,sys,sbin,run,lib,lib/arm-linux-gnueabihf}
 | 
					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
 | 
					#install the few tools we need
 | 
				
			||||||
chroot $outmnt cp /bin/busybox /sbin/cryptsetup $initramfs_src/bin/
 | 
					cp $outmnt/bin/busybox $outmnt/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/
 | 
					cp ${outmnt}/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/
 | 
					cp $outmnt/lib/ld-linux-armhf.so.3 $initramfs_src/lib/
 | 
				
			||||||
chroot $outmnt cp /sbin/blkid $initramfs_src/bin/
 | 
					cp $outmnt/sbin/blkid $initramfs_src/bin/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#add the init script
 | 
					#add the init script
 | 
				
			||||||
cp $build_resources/initramfs-init $outmnt/$initramfs_src/init
 | 
					cp $build_resources/initramfs-init $initramfs_src/init
 | 
				
			||||||
chroot $outmnt chmod +x $initramfs_src/init
 | 
					chmod +x $initramfs_src/init
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#compress and install
 | 
					#compress and install
 | 
				
			||||||
#TODO, make this correct
 | 
					#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
 | 
					#add the live-boot fstab
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user