mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:12:43 +00:00 
			
		
		
		
	 e1c982e4db
			
		
	
	
		e1c982e4db
		
	
	
	
	
		
			
			This removes grub and all the loopback device business from the default build process. Running grub takes about a second, and it turns out it's inconsistently packaged in different distributions, which has led to at least one confusing issue so far (grub-install vs grub2-install). Removing it from the basic path will make it easier for people to try Serenity out. There are now two scripts that can be used to build a disk image: 1. `build-image-grub.sh` - this will build an image suitable for writing to the IDE hard drive of a physical machine, complete with a partition table and bootloader. This can be run in qemu with the `qgrub` target for the `run` script. 2. `build-image-qemu.sh` - this is a simpler script which creates a bare filesystem image rather than a full MBR disk. Both of these call out to `build-root-filesystem.sh` to do most of the work setting up... the root filesystem. For completeness' sake, I've retained the `sync.sh` script as a simple forwarding to `build-image-qemu.sh`. This relies on the functionality from #194 and #195. #195 allows us to use `/dev/hda` as the root device when nothing else is specified, and #194 works around a strange feature of qemu that appends a space to the kernel command line.
		
			
				
	
	
		
			38 lines
		
	
	
	
		
			807 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			807 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
| #!/bin/bash
 | |
| 
 | |
| set -e
 | |
| 
 | |
| die() {
 | |
|     echo "die: $@"
 | |
|     exit 1
 | |
| }
 | |
| 
 | |
| if [ $(id -u) != 0 ]; then
 | |
|     die "this script needs to run as root"
 | |
| fi
 | |
| 
 | |
| echo "setting up disk image..."
 | |
| qemu-img create _disk_image ${DISK_SIZE:-500}m || die "couldn't create disk image"
 | |
| chown 1000:1000 _disk_image || die "couldn't adjust permissions on disk image"
 | |
| echo "done"
 | |
| 
 | |
| echo -n "creating new filesystem... "
 | |
| mke2fs -q -I 128 _disk_image || die "couldn't create filesystem"
 | |
| echo "done"
 | |
| 
 | |
| echo -n "mounting filesystem... "
 | |
| mkdir -p mnt
 | |
| mount _disk_image mnt/ || die "couldn't mount filesystem"
 | |
| echo "done"
 | |
| 
 | |
| cleanup() {
 | |
|     if [ -d mnt ]; then
 | |
|         echo -n "unmounting filesystem... "
 | |
|         umount mnt || ( sleep 1 && sync && umount mnt )
 | |
|         rm -rf mnt
 | |
|         echo "done"
 | |
|     fi
 | |
| }
 | |
| trap cleanup EXIT
 | |
| 
 | |
| ./build-root-filesystem.sh
 |