Difference between revisions of "Incrementare la velocità di boot (Italiano)"

From ArchWiki
Jump to: navigation, search
(Redirect instead of duplication. See Help:i18n)
Line 1: Line 1:
[[Category:Boot process]]
#REDIRECT [[Improve Boot Performance (Italiano)]]
[[ar:Improve Boot Performance]]
[[cs:Improve Boot Performance]]
[[es:Improve Boot Performance]]
[[ja:Improve Boot Performance]]
[[ru:Improve Boot Performance]]
[[zh-CN:Improve Boot Performance]]
{{Article summary start}}
{{Article summary text|Questo articolo prova ad aggregare vari metodi per migliorare i tempi di boot di un sistema Arch Linux.}}
{{Article summary end}}
{{translateme | Questo articolo è in fase di traduzione. Seguite per ora le istruzioni della versione inglese. | Talk:ArchWiki Translation Team (Italiano)#Pagine Marcate come "out of date" e "Traslateme"}}
Incrementare la velocità di boot di un sistema riduce i tempi di attesa e significa conoscere meglio come certi files di sistema  e scripts interagiscono gli uni con gli altri. Questo articolo prova ad aggregare vari metodi per migliorare i tempi di boot di un sistema Arch Linux.
=== Analizzare il processo di boot ===
==== systemd-analyze ====
Systemd fornisce una utilità chiamata {{ic|systemd-analyze}} che permette di analizzare il proprio processo d'avvio al fine di evidenziare quali unità stanno causando rallentamenti nel processo di avvio stesso. E' possibile quindi ottimizzare il sistema tenendo conto di ciò.
Per vedere quanto tempo ha impiegato il boot del kernelspace e dello userspace, semplicemente si usi:
$ systemd-analyze
* Se si aggiunge l'hook {{ic|timestamp}} al proprio  {{ic|HOOKS}} array in {{ic|/etc/[[mkinitcpio]].conf}} e si ricostruisce l'initramfs con {{ic|mkinitcpio -p linux}}, systemd-analyze è in grado di mostrare anche quanto tempo è passato nell'initramfs.
* Se si fa il boot tramite[[UEFI]] e si usa un boot loader che implementi systemds' [http://www.freedesktop.org/wiki/Software/systemd/BootLoaderInterface Boot Loader Interface] (attualmente solo [[Gummiboot]]), systemd-analyze può mostrare in aggiunta quanto tempo è trascorso nel firmware EFI firmware e nel boot loader stesso.}}
Per elencare le unità avviate, ordinate a seconda del tempo che impiegano ad avviarsi:
$ systemd-analyze blame
Si può inoltre creare un file SVG che descriva il processo di boot graficamente, similmente a [[Bootchart]]:
$ systemd-analyze plot > plot.svg
====Usare systemd-bootchart====
Bootchart è stato implementato in systemd dal 17 Ottobre 2012, e si può utilizzarlo per il boot proprio come si farebbe con il bootchart originale. Aggiongere alla linea del kernel:
  initcall_debug printk.time=y init=/usr/lib/systemd/systemd-bootchart
==== Usare bootchart2 ====
E' possibile usare una versione di bootchart per visualizzare la sequenza di boot. Da quando non è più possibile inserire un secondo "init" nel comando del kernel non c'è più la possibilità di usare alcuna configurazione standard di bootchart. Tuttavia il pacchetto {{AUR|bootchart2}} di [[AUR]] nasce con un non documentato service di systemd. Dopo aver installato bootchart2 fare:
# systemctl enable bootchart
Leggere la [https://github.com/mmeeks/bootchart documentazione di bootchart] per ulteriori dettagli sull'uso di questa versione di bootchart.
=== Readahead ===
Systemd nasce con la propria implementazione di readahead , questo dovrebbe principalmente migliorare il tempo d'avvio. Tuttavia, in relazione alla versione del kernel e al tipo di disco rigido, i tempi possono variare (per esempio potrebbe essere più lento). Per attivarlo, fare:
# systemctl enable systemd-readahead-collect systemd-readahead-replay
Ricorda che prima che readahead sprigioni la sua magia, occorre riavviare un paio di volte.
== Compiling a custom kernel ==
Compiling a custom kernel can reduce boot time and memory usage. Though with the standardization of the 64 bit architecture and the modular nature of the Linux kernel, these benefits may not be as great as expected. [[Kernel Compilation|Read more about compiling a kernel]].
== Early start for services ==
One central feature of systemd is [[D-Bus]] and socket activation. This causes services to be started when they are first accessed and is generally a good thing. However, if you know that a service (like [[UPower]]) will always be started during boot, then the overall boot time might be reduced by starting it as early as possible. This can be achieved (if the service file is set up for it, which in most cases it is) by issuing:
# systemctl enable upower
This will cause systemd to start UPower as soon as possible, without causing races with the socket or D-Bus activation.
== Staggered spin-up ==
Some hardware implements [[Wikipedia:Spin-up#Staggered spin-up|staggered spin-up]], which causes the OS to probe ATA interfaces serially, which can spin up the drives one-by-one and reduce the peak power usage. This slows down the boot speed, and on most consumer hardware provides no benefits at all since the drives will already spin-up immediately when the power is turned on. To check if SSS is being used:
$ dmesg | grep SSS
If it wasn't used during boot, there will be no output.
To disable it, add {{ic|1=libahci.ignore_sss=1}} to the [[kernel line]].
== Filesystem mounts ==
Thanks to [[mkinitcpio]]'s {{ic|fsck}} hook, you can avoid a possibly costly remount of the root partition by changing {{ic|ro}} to {{ic|rw}} on the kernel line and removing it from {{ic|/etc/fstab}}. Options can be set with {{ic|1=rootflags=mount options...}} on the kernel line. Remember to remove the entry from your /etc/fstab file, else the systemd-remount-fs.service will continue to try to apply those settings. Alternatively, one could try to mask that unit.
If btrfs is in use for the root filesystem, there is no need for a fsck on every boot like other filesystems. If this is the case, [[mkinitcpio]]'s {{ic|fsck}} hook can be removed. You may also want to mask the {{ic|systemd-fsck-root.service}}, or tell it not to fsck the root filesystem from the kernel command line using {{ic|fsck.mode=skip}}. Without [[mkinitcpio]]'s {{ic|fsck}} hook, systemd will still fsck any relevant filesystems with the {{ic|systemd-fsck@.service}}
You can also remove API filesystems from {{ic|/etc/fstab}}, as systemd will mount them itself (see {{ic|pacman -Ql systemd <nowiki>|</nowiki> grep '\.mount$'}} for a list). It is not uncommon for users to have a /tmp entry carried over from sysvinit, but you may have noticed from the command above that systemd already takes care of this. Ergo, it may be safely removed.
Other filesystems like {{ic|/home}} can be mounted with custom mount units. Adding {{ic|noauto,x-systemd.automount}} will buffer all access to that partition, and will fsck and mount it on first access, reducing the number of filesystems it must fsck/mount during the boot process.
{{Note|this will make your {{ic|/home}} filesystem type {{ic|autofs}}, which is ignored by [[mlocate]] by default. The speedup of automounting {{ic|/home}} may not be more than a second or two, depending on your system, so this trick may not be worth it.}}
== Initramfs ==
As mentioned above, boot time can be decreased by slimming the kernel, thereby reducing the amount of data that must be loaded. This is also true for your initramfs (result of mkinitcpio), as this is loaded immediately after the kernel, and takes care of recognizing your root filesystem and mounting it. To boot, very little is actually needed and includes the storage bus, block device, and filesystem. Falconindy (Dave Reisner) has begrudgingly created a [http://blog.falconindy.com/articles/optmizing-bootup-with-mkinitcpio.html short tutorial] on how to achieve this on his blog.
{{Note|If you are using anything that requires udev to be included in the initramfs (for example, lvm2, mdadm_udev, or even just specifying the filesystem label with {{ic|/dev/disk/by-label}}), trying to strip down your initramfs will not be a worthwhile endeavor.}}
== Less output during boot ==
Change {{ic|verbose}} to {{ic|quiet}} on the bootloader's kernel line. For some systems, particularly those with an SSD, the slow performance of the TTY is actually a bottleneck, and so less output means faster booting.
== See also ==
* [[systemd]]
* [[e4rat]]
* [[udev]]
* [[Daemon]]
* [[mkinitcpio]]
* [[Maximizing Performance]]
* [[Bootchart]] - Tool to assist in profiling the boot process
* [[Kexec]] - Tool to reboot very quickly without waiting for the whole BIOS boot process to finish.

Revision as of 05:21, 26 September 2013