Product SiteDocumentation Site

8.8. پیکربندی راه‌انداز اولیه

این قابلیت هم‌اکنون فعال است، اما دانستن اینکه چطور می‌توان در زمان بروز مشکل در راه‌انداز اولیه یا پاک شدن آن از روی MBR آن را عیب‌زدایی و نصب مجدد کرد بسیار مفید است. این اتفاق زمانی می‌افتد که یک سیستم عامل دیگر مانند ویندوز را نصب کنید. اطلاعات پیش رو به شما کمک می‌کنند که راه‌انداز اولیه را به صورت صحیح پیکربندی کنید.

8.8.1. شناسایی دیسک‌ها

پیکربندی راه‌انداز اولیه باید هارد درایوهای مختلف با پارتیشن‌های مربوطه را شناسایی کند. لینوکس از فایل‌های ویژه “بلاک” که در /dev/ ذخیره می‌شوند به این منظور استفاده می‌کند. به این منظور، از دبیان Squeeze، شیوه نامگذاری هارد درایوها توسط کرنل لینوکس یکپارچه شده است و تمام هارد درایوها (IDE/SATA، SATA، SCSI، USB، IEEE 1394) اکنون توسط /dev/sd* شناخته می‌شوند.
هر پارتیشن با عدد مخصوص به خود روی دیسک شناسایی می‌گردد: برای نمونه، /dev/sda1 اولین پارتیشن روی اولین دیسک و /dev/sdb3 سومین پارتیشن روی دومین دیسک است.
معماری PC (یا “i386” به همراه “amd64”) تنها محدود به استفاده از قالب جدول پارتیشن “MS-DOS” بوده است، که تنها اجازه چهار پارتیشن “اولیه” روی هر دیسک را می‌دهد. برای غلبه بر این محدودیت یکی از پارتیشن‌ها باید به صورت “گسترش‌یافته” درآید و در آنجا می‌تواند شامل پارتیشن‌های “ثانویه” باشد. این پارتیشن‌های ثانویه از شماره ۵ آغاز می‌گردند. بنابراین اولیه پارتیشن ثانویه روی دیسک با /dev/sda5 شناخته می‌شود و به همین شکل ادامه می‌یابد.
دیگر محدودیت قالب جدول پارتیشن‌بندی MS-DOS این است که تنها قادر به شناسایی دیسک‌های تا ۲ ترابایت حافظه جانبی است که این مشکل امروزه با توجه به افزایش حجم دیسک‌ها جدی شده است.
A new partition table format called GPT (GUID Partition Table) loosens these constraints on the number of partitions (it allows up to 128 partitions when using standard settings) and on the size of the disks (up to 8 ZiB, which is more than 8 billion terabytes). If you intend to create many physical partitions on the same disk, you should therefore ensure that you are creating the partition table in the GPT format when partitioning your disk.
It is not always easy to remember what disk is connected to which SATA controller, or in third position in the SCSI chain, especially since the naming of hotplugged hard drives (which includes among others most SATA disks and external disks) can change from one boot to another. Fortunately, udev creates, in addition to /dev/sd*, symbolic links with a fixed name, which you could then use if you wished to identify a hard drive in a non-ambiguous manner. These symbolic links are stored in /dev/disk/by-id/. On a machine with two physical disks, for example, one could find the following:
mirexpress:/dev/disk/by-id# ls -l
total 0
lrwxrwxrwx 1 root root  9 23 jul. 08:58 ata-STM3500418AS_9VM3L3KP -> ../../sda
lrwxrwxrwx 1 root root 10 23 jul. 08:58 ata-STM3500418AS_9VM3L3KP-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 23 jul. 08:58 ata-STM3500418AS_9VM3L3KP-part2 -> ../../sda2
[...]
lrwxrwxrwx 1 root root  9 23 jul. 08:58 ata-WDC_WD5001AALS-00L3B2_WD-WCAT00241697 -> ../../sdb
lrwxrwxrwx 1 root root 10 23 jul. 08:58 ata-WDC_WD5001AALS-00L3B2_WD-WCAT00241697-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 23 jul. 08:58 ata-WDC_WD5001AALS-00L3B2_WD-WCAT00241697-part2 -> ../../sdb2
[...]
lrwxrwxrwx 1 root root  9 23 jul. 08:58 scsi-SATA_STM3500418AS_9VM3L3KP -> ../../sda
lrwxrwxrwx 1 root root 10 23 jul. 08:58 scsi-SATA_STM3500418AS_9VM3L3KP-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 23 jul. 08:58 scsi-SATA_STM3500418AS_9VM3L3KP-part2 -> ../../sda2
[...]
lrwxrwxrwx 1 root root  9 23 jul. 08:58 scsi-SATA_WDC_WD5001AALS-_WD-WCAT00241697 -> ../../sdb
lrwxrwxrwx 1 root root 10 23 jul. 08:58 scsi-SATA_WDC_WD5001AALS-_WD-WCAT00241697-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 23 jul. 08:58 scsi-SATA_WDC_WD5001AALS-_WD-WCAT00241697-part2 -> ../../sdb2
[...]
lrwxrwxrwx 1 root root  9 23 jul. 16:48 usb-LaCie_iamaKey_3ed00e26ccc11a-0:0 -> ../../sdc
lrwxrwxrwx 1 root root 10 23 jul. 16:48 usb-LaCie_iamaKey_3ed00e26ccc11a-0:0-part1 -> ../../sdc1
lrwxrwxrwx 1 root root 10 23 jul. 16:48 usb-LaCie_iamaKey_3ed00e26ccc11a-0:0-part2 -> ../../sdc2
[...]
lrwxrwxrwx 1 root root  9 23 jul. 08:58 wwn-0x5000c50015c4842f -> ../../sda
lrwxrwxrwx 1 root root 10 23 jul. 08:58 wwn-0x5000c50015c4842f-part1 -> ../../sda1
[...]
mirexpress:/dev/disk/by-id# 
Note that some disks are listed several times (because they behave simultaneously as ATA disks and SCSI disks), but the relevant information is mainly in the model and serial numbers of the disks, from which you can find the peripheral file. While the links in /dev/disk/by-id/ are created using the device' serial number and physical path, there are more convenience links in e.g. /dev/disk/by-label/ (based on given labels), /dev/disk/by-uuid/ (based on unique identifiers, which can change when reformatting a device using mkfs.* or mkswap), /dev/disk/by-path/ (based on shortest physical path), and /dev/disk/by-partlabel/ and /dev/disk/by-partuuid/ (only partitions with GPT labels and their unique identifiers). If you use these links, e.g. in /etc/fstab, always prefer unique identifiers over labels. You can also obtain and change this information for each partition or device using the lsblk and blkid commands.
فایل‌های پیکربندی نمونه که در قسمت‌های بعدی به آن‌ها اشاره می‌شود بر اساس یک تنظیم یکسان هستند: یک دیسک SATA واحد، که اولین پارتیشن آن یک نصب قدیمی از ویندوز است و پارتیشن دوم شامل دبیان گنو/لینوکس است.

8.8.2. پیکربندی GRUB2

GRUB (GRand Unified Bootloader) is more recent. It is not necessary to invoke it after each update of the kernel; GRUB knows how to read the filesystems and find the position of the kernel on the disk by itself. To install it on the MBR of the first disk, simply type grub-install /dev/sda. This will overwrite the MBR, so be careful not to overwrite the wrong location. While it is also possible to install GRUB into a partition boot record, beware that it is usually a mistake and doing grub-install /dev/sda1 has not the same meaning as grub-install /dev/sda.
GRUB 2 configuration is stored in /boot/grub/grub.cfg, but this file (in Debian) is generated from others. Be careful not to modify it by hand, since such local modifications will be lost the next time update-grub is run (which may occur upon update of various packages). The most common modifications of the /boot/grub/grub.cfg file (to add command line parameters to the kernel or change the duration that the menu is displayed, for example) are made through the variables in /etc/default/grub. To add entries to the menu, you can either create a /boot/grub/custom.cfg file or modify the /etc/grub.d/40_custom file. For more complex configurations, you can modify other files in /etc/grub.d, or add to them; these scripts should return configuration snippets, possibly by making use of external programs. These scripts are the ones that will update the list of kernels to boot: 10_linux takes into consideration the installed Linux kernels; 20_linux_xen takes into account Xen virtual systems, and 30_os-prober adds other existing operating systems (Windows, OS X, Hurd), kernel images, and BIOS/EFI access options to the menu.

8.8.3. Using GRUB with EFI and Secure Boot

Using GRUB to boot either a traditional BIOS system (legacy or UEFI-CSM) or a UEFI system is quite different. Fortunately the user doesn't need to know the differences because Debian provides different packages for each purpose and the installer automatically cares about which one(s) to choose. The grub-pc package is chosen for legacy systems, where GRUB is installed into the MBR, while UEFI systems require grub-efi-arch, where GRUB is installed into the EFI System Partition (ESP). The latter requires a GTP partition table as well as an EFI partition.
To switch an existing system (supporting UEFI) from legacy to UEFI boot mode not only requires to switch the GRUB packages on the system, but also to adjust the partition table and the to create an EFI partition (probably including resizing existing partitions to create the necessary free space). It is therefore quite an elaborate process and we cannot cover it here. Fortunately, there are some manuals by bloggers describing the necessary procedures.
If you are using a system with “Secure Boot“ enabled and have installed shim-signed (see sidebar CULTURE Secure Boot and the shim bootloader), you must also install grub-efi-arch-signed. This package is not pulled in automatically, only if the installation of recommended package has been enabled.