A computer without an operating system. The computer turns on, but the operating system does not start: possible causes and solutions to the problem

Determine the installation sequence. If you want to use Linux along with Windows, then you should install Windows first, and then Linux. This is due to the fact that Windows has a fairly strict bootloader (bootloader) that must run before Linux, otherwise the system will not boot.

Insert the disc into the drive and restart your computer. In standard mode, the computer boots from the hard drive, so you will need to adjust some settings in the BIOS in order to boot from the drive. You can enter BIOS by pressing a specific enter button while your computer boots up. This button will be displayed on the screen with the manufacturer's logo.

  • On most computers, these buttons are F2, F10, F12, and Del / Delete.
  • Once you find yourself in the BIOS setup menu, go to the Boot menu. Select your DVD / CD as the first boot device. If you are booting from a USB stick, make sure it is inserted and select it.
  • After you have selected the desired device, save the changes and exit the settings menu. Your computer will restart.

Test your Linux distribution before installing. Most Linux distributions can be started before starting the installation. This will allow you to test the operating system before installing it. When you're ready to install, run the installer on your desktop.

  • This is only possible with Linux distributions. Windows does not have the ability to test the operating system prior to installation.
  • Wait for the installer to start. Regardless of the system you are installing, the installer will first copy the necessary files to your computer. This may take several minutes, depending on the speed of your hardware.

    • You will most likely need to choose some basic settings such as language and keyboard layout.
  • Enter your activation code. If you are installing Windows 8, you will need to enter an activation code before starting the installation. Older versions of Windows require an activation code at the end of the installation. Linux users do not have to enter an activation code, except for paid versions such as Red Hat.

  • Select the type of installation. Windows will prompt you to choose between System Update or Custom Installation. Even if you are upgrading from an older version of Windows, it is highly recommended that you select Custom Installation and install from scratch. This will avoid problems related to incompatibility between old and new settings.

    • If you are installing Linux, you will be prompted to install Linux alongside your current Windows, or to clean up disk and install Linux only. Choose what works best for you. If you choose to install alongside Windows, you will need to select the amount of hard disk space set aside for Linux.
  • Format partitions. If you are installing Windows, you will need to select the partition on which you want to install it. Deleting partitions will erase all data and the free space will become Unallocated Area. Select Unallocated area and create a new section.

    • If you are installing Linux, the partition must be formatted to Ext4.
  • Configure Linux. Before starting the installation, the Linux installer will ask you to select a time zone and create a username and password. You will use them to log into your Linux distribution and also when authorizing system changes.

    • Windows users fill in personal information after the installation is complete.
  • 7 (92221) 34 176 787 5 years

    Installing an operating system on a computer

    If you have never installed (reinstalled) an operating system on a personal computer or laptop, but want to learn, then this article is for you. There is nothing particularly complicated in this procedure, the main thing is to be careful and not to rush.
    Definitions

    First, let's figure out the definitions and abbreviations that are found in this article:

    Operating system (abbreviated OS) - special program, with the help of which other programs start and control the operation of the computer. For a computer user, the operating system looks like a desktop and windows in which programs are launched.

    Windows is the most popular commercial OS from Microsoft.

    Linux is an OS family based on the kernel of the same name. It comes in various distributions, many of which are free.

    OS Distribution - a set that includes the OS kernel, utilities and programs.

    Software (abbreviated as software) is a set of programs that perform a certain type of task.

    A driver is a special program used by other programs to access the components of a computer.
    Self-installation risks

    The first and biggest risk when reinstalling an operating system is information loss. If the data is lost, it will be quite difficult (sometimes even impossible) to recover it. Therefore, before the experiment, it is highly desirable to copy all the necessary data (documents, music, films, etc.) to an external storage medium (see the first stage of installation below in the text).

    The second risk is errors during the installation process, due to which it is impossible to install the OS (operating system) on a given computer. In this case, the computer will remain inoperative until someone can help overcome this obstacle. By the type of error, you can try to find the answer on the Internet or consult an acquaintance who is experienced in the field of computer technology. Also in this case, you can try to install a different version of the operating system.

    There may be other problems during the OS installation process, most of which are related to the peculiarities of computer components, but they do not occur often.

    As a conclusion: if possible, experiment on an old "backup" computer or laptop. If this is not possible, then weigh the pros and cons, assessing the possible risks.
    The main stages of OS installation:

    Regardless of which operating system you decide to install on your computer (Windows or Linux), the following steps are assumed:

    1. Prepare the hard drive.

    5. Installing drivers.

    7. Setting up the OS.

    Let's consider each stage together with "Garlic" in more detail:
    1. Prepare the hard drive.

    If the necessary information is not on the hard disk or the hard disk is new, then you can go directly to the second stage.

    If you have the necessary information on your hard disk, be sure to follow backup before installing the operating system.

    For this purpose, you can use a Flash drive, a DVD or a second hard drive (for example, an external one with a USB interface). Copy to this medium all the data you need (documents, music, movies, browser bookmark files, program settings files, etc.). Do not forget to copy the contents of the desktop, if you store documents on it, and go to the "My Documents" folder, usually the files created by various programs are saved to it. for reliability, you can copy on two types of media.

    Be sure to disconnect the drive from your computer after copying.

    To install an operating system, you need an installation distribution. It can be on a CD or DVD, Flash drive, or a hidden partition on your hard drive. The most versatile installation method is from an optical disc (CD or DVD).

    A disc with a licensed version of Windows can be purchased at almost any computer hardware store.

    You can create a Linux disk yourself by downloading a disk image from the official website (for example, an Ubuntu distribution) and burning it to a DVD-R disc (of course, this must be done in advance, before starting the installation process).

    Note: For laptops that came with a preinstalled operating system, the instructions usually tell you how to reinstall the operating system. Most often, for this you need to hold down a certain function key during boot and wait for the OS installation to start (for ASUS laptops, this is the F9 key).

    To boot from the installation disk, when you turn on the computer, call the boot menu ("Boot menu"), select the appropriate device to boot (DVD drive or USB Flash drive).
    You can also go to BIOS Setup and in the Boot section set the DVD drive or USB Flash drive first in the boot queue.
    3. Determination of installation parameters.

    At the beginning of the operating system installation process, you may need to specify the basic installation parameters (installation language, operating system variant, etc.)

    The selection is made either with the mouse pointer or by moving the cursor using the arrows on the keyboard.
    4. Following the instructions of the installation wizard.

    After starting the installation process, dialog boxes may appear asking you to configure the operating system parameters (input language, serial number OS, network adapter settings, username, login password, etc.). Your task is to indicate what is required of you or leave the default value (if possible).

    When prompted to specify a hard disk partition for OS installation, there are three options:

    There are no partitions on the hard disk: using the installation wizard, create two partitions (one for the OS with a size of 30-40 Gigabytes and programs, the second for user files using all the remaining space on the hard disk).
    There is one partition on the hard disk: it is advisable to delete the partition (all data will be lost in this case) and create two partitions using the installation wizard (see the previous option).
    There are two or more partitions on a hard disk: the best option, there is no need to change partitions if the first partition is more than 30 Gigabytes in size.

    After creating partitions, select the first partition to install the OS and you can continue without losing data on the remaining partitions.

    The installation process usually takes 20 to 40 minutes, so be patient. Most of this time, the computer does not require your attention, copying files and performing various settings.

    Note: Sometimes it may seem that the computer is frozen, but it is not worth forcibly restarting it. If the state of the computer does not change for more than 10 minutes and at the same time there is no access to the hard disk (red indicator on the system unit), then you can perform a forced reboot (the "Reset" button) or, holding the power button for 5-10 seconds, perform a forced shutdown with subsequent inclusion.
    5. Installing drivers.

    After installing the operating system, you need to check if all the drivers are installed. It is often required to install a driver on a video adapter, sound adapter and peripheral devices (printer, scanner, etc.). You can find these drivers either on the disc that comes with the computer (laptop), or on the website of the manufacturer of the corresponding components.

    Note: If there is no driver disk, then they must be loaded in advance, before starting the OS installation process.
    6. OS activation (for Windows OS).

    For paid operating systems (Windows OS), authentication must be performed. To do this, run the appropriate item in the OS menu. To activate the OS, you need a serial number, which can be found on the disc packaging or on a sticker on the computer (laptop) case.
    7. Setting up the OS.

    The next step is setting up the operating system. We will consider this item in detail in one of the following articles on the 4esnok website.

    Setting up the OS includes: configuring the parameters of access to the network and the Internet, setting the rights of user accounts, setting the parameters for updating the OS, configuring the OS interface, etc.
    8. Installing additional software.

    After all the above steps, you can start installing the programs. Today, the easiest way to install software is to download it over the Internet. If paid software is considered, then it can also be purchased using the Internet.

    The most important thing was not described in sufficient detail: how to run this code on real hardware? How to create your own boot disk? In this article, we will answer all these questions in detail (some of these questions were dealt with in the previous article, but for ease of reading we will allow ourselves a little duplication of the material).

    There are a huge number of descriptions and tutorials on the Internet about how to write your own mini-OS, there are even hundreds of ready-made small hobby OS. One of the most worthy resources on this subject, which I would like to highlight, is the osdev.org portal. To complement the previous article on PCI (and the ability to write subsequent articles about the various functions that are present in any modern OS), we will describe step by step instructions on creating a bootable disk with a familiar program in C. We tried to write as much detail as possible so that we could figure it out on our own.

    So, the goal: spending as little effort as possible, create your own bootable USB drive which just prints the classic "Hello World" on the computer screen.

    To be more precise, we need to "get" into the protected mode with disabled paging and interrupts - the simplest mode of the processor with the usual behavior for a simple console program. The smartest way to accomplish this is to build a multiboot kernel and boot it using the popular Grub boot loader. An alternative to this solution is to write your own volume boot record (VBR), which would load the written own loader (loader). A decent bootloader, at least, should be able to work with a disk, with a file system, and parse elf images. This means that you have to write a lot of assembly code, and a lot of C code. In short, it's easier to use Grub, which already knows how to do everything you need to do.

    To begin with, further actions require a certain set of compilers and utilities. The easiest way is to use some kind of Linux (for example, Ubuntu), since it will already contain everything you need to create a bootable USB flash drive. If you are used to working in Windows, then you can configure virtual machine with Linux (using Virtual Box or VMware Workstation).

    If you are using Linux Ubuntu, then first of all you need to install several utilities:
    1. Grub. To do this, use the command:
    sudo apt-get install grub

    2. Qemu. It is needed to make everything fast, for this, the command is similar:
    sudo apt-get install qemu

    Our plan now looks like this:
    1.Create a C program that prints a string to the screen.
    2. build from it an image (kernel.bin) in miniboot format so that it is available for booting using GRUB.
    3. Create a boot disk image file and format it.
    4. install Grub on this image.
    5. copy the created program (kernel.bin) to the disk.
    6. write the image to physical media or run it in qemu.

    And the system boot process:

    To do this, you will need to create several files and directories:

    Step 1. Generating the target program (kernel) code:

    Create a kernel.c file that contains the following code to print a message on the screen:

    #include "printf.h" #include "screen.h" #include "types.h" void main (void) (clear_screen (); printf ("\ n >>> Hello World! \ n");)

    Everything is familiar and simple here. The addition of printf and clear_screen functions will be discussed later. In the meantime, we need to supplement this code with everything necessary so that it can be loaded by Grub.
    In order for the kernel to be in multiboot format, the following structure is needed in the first 8 kilobytes of the kernel image:

    If all the specified conditions are met, then Grub passes a pointer to the multiboot Information structure and the value 0x1BADB002 through the% eax and% ebx registers, respectively. The multiboot Information structure contains various information, including the list of loaded modules and their location, which may be needed to further boot the system.
    In order for the file with the program to contain the necessary signatures, we will create a file loader.s, with the following contents:

    Text .global loader # making entry point visible to linker # setting up the Multiboot header - see GRUB docs for details .set FLAGS, 0x0 # this is the Multiboot "flag" field .set MAGIC, 0x1BADB002 # "magic number" lets bootloader find the header .set CHECKSUM, - (MAGIC + FLAGS) # checksum required .align 4 .long MAGIC .long FLAGS .long CHECKSUM # reserve initial kernel stack space .set STACKSIZE, 0x4000 # that is, 16k. .lcomm stack, STACKSIZE # reserve 16k stack .comm mbd, 4 # we will use this in kmain .comm magic, 4 # we will use this in kmain loader: movl $ (stack + STACKSIZE),% esp # set up the stack movl% eax, magic # Multiboot magic number movl% ebx, mbd # Multiboot data structure call main # call C code cli hang: hlt # halt machine should kernel return jmp hang

    Let's take a closer look at the code. This code, almost unchanged, is taken from wiki.osdev.org/Bare_Bones. Since gcc is used for compilation, GAS syntax is used. Let's take a closer look at what this code does.
    .text
    All subsequent code will fall into the executable section .text.
    .global loader
    We declare the loader symbol visible to the linker. This is required because the linker will use the loader as the entry point.
    .set FLAGS, 0x0 # assign FLAGS = 0x0 .set MAGIC, 0x1BADB002 # assign MAGIC = 0x1BADB002 .set CHECKSUM, - (MAGIC + FLAGS) # assign CHECKSUM = - (MAGIC + FLAGS) .align 4 # align subsequent data by 4 bytes .long MAGIC # place the MAGIC value at the current address .long FLAGS # place the FLAGS value at the current address .long CHECKSUM # place the CHECKSUM value at the current address
    This code generates a Multiboot format signature. The .set directive sets the value of a character to an expression to the right of the comma. The .align 4 directive aligns the subsequent content by 4 bytes. The .long directive stores the value in the next four bytes.
    .set STACKSIZE, 0x4000 # assign STACKSIZE = 0x4000 .lcomm stack, STACKSIZE # reserve STACKSIZE bytes. stack refers to the comm mbd range, 4 # reserve 4 bytes for the mdb variable in the COMMON area .comm magic, 4 # reserve 4 bytes for the magic variable in the COMMON area
    During the boot process grub does not configure the stack, and the first thing the kernel has to do is configure the stack, for this we reserve 0x4000 (16Kb) bytes. The .lcomm directive reserves the number of bytes after the comma in the .bss section. The stack name will only be visible in the compiled file. The .comm directive does the same as .lcomm, but the symbol name will be declared globally. This means that by writing the following line in the C code, we can use it.
    extern int magic

    And now the last part:
    loader: movl $ (stack + STACKSIZE),% esp # initialize stack movl% eax, magic # write% eax to magic movl% ebx, mbd # write% ebx to mbd call main # call main function cli # disable interrupts from hardware hang: hlt # stop processor until interrupt occurs jmp hang # jump to hang tag

    The first instruction is to store the value on the top of the stack in the% esp register. As the stack grows downwards,% esp stores the address of the end of the range allocated for the stack. The next two instructions store in the previously reserved ranges of 4 bytes the values ​​that Grub passes in the% eax,% ebx registers. Then the main function is called, which is already written in C. If this procedure returns, the processor will go into a loop.

    Step 2. Prepare additional code for the program (system library):

    Since the entire program is written from scratch, the printf function must be written from scratch. To do this, you need to prepare several files.
    Let's create a common and include folder:

    Mkdir common mkdir include

    Let's create a file common \ printf.c, which will contain the implementation of the familiar printf function. This file can be taken entirely from the www.bitvisor.org project. The path to the file in the bitvisor sources: core / printf.c. In the printf.c file copied from bitvisor, for use in the target program, you need to replace the lines:

    #include "initfunc.h" #include "printf.h" #include "putchar.h" #include "spinlock.h"
    per lines:
    #include "types.h" #include "stdarg.h" #include "screen.h"

    Then, remove the printf_init_global function and all its references in this file:

    Static void printf_init_global (void) (spinlock_init (& printf_lock);) INITFUNC ("global0", printf_init_global);

    Then remove the printf_lock variable and all references to it in this file:
    static spinlock_t printf_lock; … Spinlock_lock (& ​​printf_lock); ... spinlock_unlock (& ​​printf_lock);

    The printf function uses the putchar function, which also needs to be written. To do this, create a common \ screen.c file with the following content:
    #include "types.h" #define GREEN 0x2 #define MAX_COL 80 // Maximum number of columns #define MAX_ROW 25 // Maximum number of rows #define VRAM_SIZE (MAX_COL * MAX_ROW) // Size of screen, in short "s # define DEF_VRAM_BASE 0xb8000 // Default base for video memory static unsigned char curr_col = 0; static unsigned char curr_row = 0; // Write character at current screen location #define PUT (c) (((unsigned short *) (DEF_VRAM_BASE)) \ [(curr_row * MAX_COL) + curr_col] = (GREEN<< 8) | (c)) // Place a character on next screen position static void cons_putc(int c) { switch (c) { case "\t": do { cons_putc(" "); } while ((curr_col % 8) != 0); break; case "\r": curr_col = 0; break; case "\n": curr_row += 1; if (curr_row >= MAX_ROW) (curr_row = 0;) break; case "\ b": if (curr_col> 0) (curr_col - = 1; PUT ("");) break; default: PUT (c); curr_col + = 1; if (curr_col> = MAX_COL) (curr_col = 0; curr_row + = 1; if (curr_row> = MAX_ROW) (curr_row = 0;))); ) void putchar (int c) (if (c == "\ n") cons_putc ("\ r"); cons_putc (c);) void clear_screen (void) (curr_col = 0; curr_row = 0; int i; for (i = 0; i< VRAM_SIZE; i++) cons_putc(" "); curr_col = 0; curr_row = 0; }

    The above code contains simple logic for printing characters to the screen in text mode. In this mode, two bytes are used to write a character (one with the character code, the other with its attributes), written directly to the video memory displayed immediately on the screen and starting from the address 0xB8000. The screen resolution is 80x25 characters. Direct printing of a symbol is carried out using the PUT macro.
    Now only a few header files are missing:
    1. File include \ screen.h. Declares the putchar function, which is used in the printf function. File contents:
    #ifndef _SCREEN_H #define _SCREEN_H void clear_screen (void); void putchar (int c); #endif

    2. File include \ printf.h. Declares the printf function, which is used in main. File contents:
    #ifndef _PRINTF_H #define _PRINTF_H int printf (const char * format, ...); #endif

    3. File include \ stdarg.h. Declares functions for iterating over arguments, the number of which is not known in advance. The entire file is taken from the www.bitvisor.org project. The path to the file in the bitvisor project code is include \ core \ stdarg.h.
    4. File include \ types.h. Declares NULL and size_t. File contents:
    #ifndef _TYPES_H #define _TYPES_H #define NULL 0 typedef unsigned int size_t; #endif
    Thus, the include and common folders contain the minimum system library code that any program needs.

    Step 3. Create a script for the linker:

    Create a linker.ld file that will be used by the linker to generate the target program file (kernel.bin). The file should contain the following:

    ENTRY (loader) LMA = 0x00100000; SECTIONS (. = LMA; .multiboot ALIGN (0x1000): (loader.o (.text)) .text ALIGN (0x1000): (* (. Text)) .rodata ALIGN (0x1000): (* (. Rodata *) ) .data ALIGN (0x1000): (* (. data)) .bss: (* (COMMON) * (. bss)) / DISCARD /: (* (. comment)))

    The built-in ENTRY () function allows us to set the entry point for our kernel. It is at this address that grub will transfer control after loading the kernel. The linker will use this script to create an ELF binary file. An ELF file consists of a set of segments and sections. The list of segments is contained in the Program header table, the list of sections is in the Section header table. The linker operates with sections, the image loader (in our case it is GRUB) with segments.

    As you can see in the figure, segments are made up of sections. One of the fields describing the section is the virtual address at which the section should be located at the time of execution. In fact, a segment has 2 fields that describe its location: the virtual address of the segment and the physical address of the segment. The virtual address of the segment is the virtual address of the first byte of the segment at the time of code execution, the physical address of the segment is the physical address at which the segment should be loaded. For application programs, these addresses are always the same. Grub loads image segments at their physical address. Since Grub does not configure paging, the virtual address of a segment must match its physical address, since virtual memory is also not configured in our program.

    SECTIONS
    Indicates that sections are described below.
    ... = LMA;
    This expression tells the linker that all subsequent sections are after the LMA address.
    ALIGN (0x1000)
    The directive above means that the section is 0x1000 byte aligned.
    .multiboot ALIGN (0x1000): (loader.o (.text))
    A separate multiboot section, which includes the .text section from the loader.o file, is made to ensure that the multiboot format signature gets into the first 8kb of the kernel image.
    .bss: (* (COMMON) * (. bss))
    * (COMMON) is the area in which memory is reserved by the .comm and.lcomm instructions. We put it in the .bss section.
    / DISCARD /: (* (. Comment))
    All sections marked as DISCARD are removed from the image. In this case, we are deleting the.comment section, which contains information about the version of the linker.

    Now let's compile the code into a binary file with the following commands:
    as -o loader.o loader.s gcc -Iinclude -Wall -fno-builtin -nostdinc -nostdlib -o kernel.o -c kernel.c gcc -Iinclude -Wall -fno-builtin -nostdinc -nostdlib -o printf.o -c common / printf.c gcc -Iinclude -Wall -fno-builtin -nostdinc -nostdlib -o screen.o -c common / screen.c ld -T linker.ld -o kernel.bin kernel.o screen.o printf .o loader.o
    Using objdump, let's see what the kernel image looks like after linking:
    objdump -ph ./kernel.bin

    As you can see, the sections in the image are the same as those described in the linker script. The linker has formed 3 segments from the described sections. The first segment includes the multiboot, .text, .rodata sections and has a virtual and physical address of 0x00100000. The second segment contains the .data and .bss sections and is located at 0x00104000. So you are ready to download this file with Grub.

    Step 4. Prepare the Grub bootloader:
    Create grub folder:
    mkdir grub

    Copy several Grub files into this folder, which are necessary to install it on the image (the following files exist if Grub is installed on the system). To do this, you need to run the following commands:
    cp / usr / lib / grub / i386-pc / stage1 ./grub/ cp / usr / lib / grub / i386-pc / stage2 ./grub/ cp / usr / lib / grub / i386-pc / fat_stage1_5 ./grub /

    Create file grub / menu.lst, with the following contents:
    timeout 3 default 0 title mini_os root (hd0,0) kernel /kernel.bin

    Step 5. Automate and create a bootable image:

    To automate the build process, we will use the make utility. To do this, we will create a makefile that will build compile source code, build a kernel and create a boot image. The Makefile should have the following content:

    CC = gcc CFLAGS = -Wall -fno-builtin -nostdinc -nostdlib LD = ld OBJFILES = \ loader.o \ common / printf.o \ common / screen.o \ kernel.o image: @echo "Creating hdd.img. .. "@dd if = / dev / zero of =. / hdd.img bs = 512 count = 16065 1> / dev / null 2> & 1 @echo" Creating bootable first FAT32 partition ... "@losetup / dev / loop1 ./hdd.img @ (echo c; echo u; echo n; echo p; echo 1; echo; echo; echo a; echo 1; echo t; echo c; echo w;) | fdisk / dev / loop1 1> / dev / null 2> & 1 || true @echo "Mounting partition to / dev / loop2 ..." @losetup / dev / loop2 ./hdd.img \ --offset `echo \` fdisk -lu / dev / loop1 | sed -n 10p | awk "(print $$ 3)" \ `* 512 | bc` \ --sizelimit `echo \` fdisk -lu / dev / loop1 | sed -n 10p | awk "(print $$ 4)" \ `* 512 | bc` @losetup -d / dev / loop1 @echo "Format partition ..." @mkdosfs / dev / loop2 @echo "Copy kernel and grub files on partition ..." @mkdir -p tempdir @mount / dev / loop2 tempdir @mkdir tempdir / boot @cp -r grub tempdir / boot / @cp kernel.bin tempdir / @sleep 1 @umount / dev / loop2 @rm -r tempdir @losetup -d / dev / loop2 @echo "Installing GRUB. .. "@echo" device (hd0) hdd.img \ n \ root (hd0,0) \ n \ setup (hd0) \ n \ quit \ n "| grub --batch 1> / dev / null @echo "Done!" all: kernel.bin rebuild: clean all .s.o: as -o [email protected] $< .c.o: $(CC) -Iinclude $(CFLAGS) -o [email protected]-c $< kernel.bin: $(OBJFILES) $(LD) -T linker.ld -o [email protected]$ ^ clean: rm -f $ (OBJFILES) hdd.img kernel.bin

    The file declares two main goals: all - compiles the kernel, and image - which creates a boot disk. The all target, like the usual makefile, contains the .s.o and .c.o subgoals that compile * .s and * .c files into object files (* .o), as well as a target for generating kernel.bin, which calls the linker with the previously created script. These goals perform exactly the same commands that are specified in step 3.
    Of greatest interest here is the creation boot image hdd.img (target image). Let's consider in stages how this happens.
    dd if = / dev / zero of =. / hdd.img bs = 512 count = 16065 1> / dev / null 2> & 1
    This command creates an image with which further work will take place. The number of sectors was not chosen by chance: 16065 = 255 * 63. By default, fdsik works with the disk as if it has CHS geometry, in which Headers (H) = 255, Sectors (S) = 63, and Cylinders (C) depends on disk size. Thus, the minimum disk size that the fdsik utility can work with without changing the default geometry is 512 * 255 * 63 * 1 = 8225280 bytes, where 512 is the sector size and 1 is the number of cylinders.
    Next, a partition table is created:
    losetup / dev / loop1 ./hdd.img (echo c; echo u; echo n; echo p; echo 1; echo; echo; echo a; echo 1; echo t; echo c; echo w;) | fdisk / dev / loop1 1> / dev / null 2> & 1 || true
    The first command mounts the hdd.img file to the / dev / loop1 block device, allowing the file to be treated like a device. The second command creates a partition table on the device / dev / loop1, which contains 1 primary boot partition of the disk, occupying the entire disk, labeled with the FAT32 file system.
    Then we format the created section. To do this, you need to mount it as a block device and perform formatting.
    losetup / dev / loop2 ./hdd.img \ --offset `echo \` fdisk -lu / dev / loop1 | sed -n 10p | awk "(print $$ 3)" \ `* 512 | bc` \ --sizelimit `echo \` fdisk -lu / dev / loop1 | sed -n 10p | awk "(print $$ 4)" \ `* 512 | bc` losetup -d / dev / loop1
    The first command mounts the previously created partition to the / dev / loop2 device. The –offset option specifies the start of the section, and –sizelimit specifies the end of the section. Both parameters are obtained using the fdisk command.
    mkdosfs / dev / loop2
    The mkdosfs utility formats the partition into file system FAT32.
    To build the kernel directly, the commands discussed earlier in the classic makefile syntax are used.
    Now let's see how to install GRUB on a partition:
    mkdir -p tempdir # creates a temporary directory mount / dev / loop2 tempdir # mounts the partition in the mkdir directory tempdir / boot # creates a / boot directory on the cp -r grub partition tempdir / boot / # copy the grub folder to / boot cp kernel.bin tempdir / # copies the kernel to the root of the partition sleep 1 # wait for Ubuntu umount / dev / loop2 # unmount the temporary folder rm -r tempdir # delete the temporary folder losetup -d / dev / loop2 # unmount the partition
    After executing the above commands, the image will be ready to install GRUB. The following command installs GRUB into the MBR of the hdd.img disk image.
    echo "device (hd0) hdd.img \ n \ root (hd0,0) \ n \ setup (hd0) \ n \ quit \ n" | grub --batch 1> / dev / null

    Everything is ready for testing!

    Step 6. Launch:

    To compile, use the command:
    make all
    After which the file kernel.bin should appear.
    To create a bootable disk image, use the command:
    sudo make image
    As a result, the hdd.img file should appear.
    Now you can boot from the hdd.img disk image. You can check this with the following command:
    qemu -hda hdd.img -m 32
    or:
    qemu-system-i386 -hda hdd.img


    To test it on a real machine, you need to dd this image onto a flash drive and boot from it. For example with the following command:
    sudo dd if =. / hdd.img of = / dev / sdb

    Summing up, we can say that as a result of the actions done, a set of sources and scripts is obtained that allow you to carry out various experiments in the field of system programming. Taking the first step towards creating system software such as hypervisors and operating systems.

    There are several installation options for this operating system, and all of them differ only in minor deviations from the installation process itself. Windows 7 can be installed, for example:

    1 ... On a new computer;
    2 ... Over Windows XP;
    3 ... That there were two systems: XP and "seven";
    4 ... To have two "sevens";
    5 ... Reinstall Windows 7.

    During the installation process, you will understand that there is nothing complicated here. It's scary the first time, and then everything is done with closed eyes. We will dwell on the most common option, this is when your operating system "crashed" or suffered from viruses and no longer shows any signs of life.
    And so, let's get started.

    1. We go into the "BIOS".

    Insert the CD with the distribution kit Windows 7 into the DVD drive and send the computer to reboot. Immediately after the reboot, the motherboard welcome window will appear for 2 - 3 seconds, where it is suggested to press the " DEL", And in laptops" F2».

    As soon as the welcome window opens, press the " DEL" or " F2"To get into" BIOS". If you do not have time in this short period of time, then the restart procedure will have to be repeated again, since the computer will start booting from the hard disk.

    So, we did everything right, and ended up in " BIOS"In the section" Main».

    Using the tips, and in different models of motherboards they can be slightly modified, we move to the section " Boot" (loading).
    In my case, moving is done using the arrow buttons " up down" or " left-right"Located on the keyboard, and for most laptops the navigation buttons will be F5 and F6.

    Being in the section " Boot"Go to the menu item" Boot Device Priority"By pressing the button" Enter».

    Before us opened the boot menu window, where it is indicated that the computer by default should boot from floppy disk, and if there is none, then the next device is HDD... Well, the last on this list is CDROM.

    Here, we choose to boot the computer from the DVD drive. Therefore, we press the button " Enter"And another window opens in front of us, in which it is necessary to select our drive.
    The arrow buttons up down"Go down to the line" CDROM: 3S-Optiarc DVD RW AD-5260"And click" Enter". Your DVD drive name will be different.
    In the case of a laptop, the navigation buttons will be F5 and F6.

    As you can see, the DVD drive has become the first in the boot list of the computer.

    2. Installing Windows 7 on your hard drive.

    After rebooting, a window will appear for a short time, where in the upper left corner there will be a request line to start the installation from the DVD drive. We press any key. If the key is not pressed, the computer will boot from the hard drive.

    The Windows 7 setup program starts, determines the minimum hardware it needs to install, and copies the necessary installation files to your hard drive.

    Everything. We have done the most difficult part with you, and now all that remains is to follow the instructions of the installation program.
    In this window, select the installation language.

    Here we select the language of the operating system and click " Further».

    Press the button " Install»To start the Windows installation.

    In the next window, you will need to select the version of Windows 7 that was previously installed on your computer. It is important to know here: a 32-bit or 64-bit operating system was installed on the computer, otherwise there will be problems with the operation of hardware if it is not designed to work with a 64-bit system.
    As a rule, if there is more than 3 GB of RAM, you can safely install the 64-bit version of the system. As decided, click " Further».

    If you install the system on a laptop, then the system data can be taken from the sticker glued to the bottom of the laptop.

    We agree with the License Agreement and click " Further».

    We choose a complete installation.

    After a while, the installer will automatically detect the partition where it will offer to install the operating system. But you can also specify in which partition to install Windows. In our case, we leave everything by default and select “ Disk setup».

    In this window, select formatting section. The program will immediately warn you that you will lose all unsaved data in this section. And since we have no choice - Windows still does not boot, unambiguously press “ Further».

    Formatting a hard disk partition, we sort of plow it, creating a fertile "soil" for files and folders of the new operating system.
    Now it remains to wait until Windows is installed on the computer.

    After the installation of the files is complete, the computer will reboot.

    After the next reboot and in the future, while the system is being installed, you will see a window that says a request to start the installation.

    Do not click anything, as the required files have already been downloaded to the hard drive, and you do not need to load them from the installation disc again.

    3. Completing the installation of WINDOWS 7.

    Windows now prompts you to enter some more information to finalize the installation. In the window that opens, enter the name of the computer user and click " Further". You can enter your name.

    In this window, you are prompted to enter a password for your account... You may or may not enter. I usually don't enter a password. We press " Further».

    The next window prompts you to enter your product key. We press " Further».
    You can not enter it, but use this operating system for 30 days. But at the end of this period, you will need to activate Windows by entering the key.

    We check the set: date, time and time zone.

    We are waiting for the settings to be applied.

    Everything. Now you can be congratulated on self-installation operating room Windows systems 7 .

    4. Add some shine.

    Let's do a couple more finishing touches.
    As you can see, the screen resolution is a bit high and the “ Desktop"Look large.
    Right-click on " Desktop"And in the appeared context menu choose “ Screen resolution».

    As you can see, the default screen resolution is 800x600 pixels. It changes with a slider located in the window that opens with options for resolutions. Choose the one you need, click " Apply", and " OK».

    And the second thing that must be done is to restart the computer and once again enter the " BIOS»To change the download option.

    We also go to the section " Boot"And from the menu item" Boot Device Priority"By pressing the button" Enter»We get to the boot menu. Here we choose so that the computer boots by default with hard disk.

    If you have a stationary PC, then it will be enough to install the latest drivers on the webcam, if there is a camera.

    For laptop owners, you will have to install a little more drivers: for a video card, webcam, pointpad, Wi-Fi, and possibly for some other device. All of them can be downloaded from the laptop manufacturer's website.

    Now you can use your computer.

    And if you have any questions about Windows installation 7, then be sure to watch this video.