https://www.funtoo.org/api.php?action=feedcontributions&user=97.82.197.142&feedformat=atomFuntoo - User contributions [en]2024-03-19T02:24:02ZUser contributionsMediaWiki 1.36.2https://www.funtoo.org/index.php?title=Emerge&diff=939Emerge2014-01-28T17:13:57Z<p>97.82.197.142: </p>
<hr />
<div>== Getting started with emerge ==<br />
Emerge is the front-end for funtoo's portage package manager. With emerge it is easy to install, update or remove packages.<br />
<br />
=== Update package database ===<br />
'''Sync local package database. This will update your local Portage tree with the latest Funtoo ebuilds.'''<br />
<console><br />
###i## emerge --sync<br />
</console><br />
<br />
=== Search packages ===<br />
'''Search packages by name.'''<br />
<console><br />
###i## emerge -s firefox<br />
###i## emerge --search firefox<br />
</console><br />
<br />
'''Search packages by description.'''<br />
<console><br />
###i## emerge -S web browser<br />
###i## emerge --searchdesc web browser<br />
</console><br />
<br />
=== Install packages ===<br />
'''Install package.'''<br />
<console><br />
###i## emerge firefox<br />
</console><br />
<br />
'''Install multiple packages.'''<br />
<console><br />
###i## emerge firefox thunderbird<br />
</console><br />
<br />
'''Install package. Ask for confirmation before performing any changes. Show verbose output.'''<br />
<console><br />
###i## emerge -av firefox<br />
###i## emerge --ask firefox<br />
</console><br />
<br />
=== Remove packages ===<br />
'''Remove package.'''<br />
<console><br />
###i## emerge -C firefox<br />
###i## emerge --unmerge firefox<br />
</console><br />
<br />
'''Remove package. Ask for confirmation before performing any changes.'''<br />
<console><br />
###i## emerge -aC firefox<br />
</console><br />
<br />
'''Remove orphaned packages. Ask for confirmation before performing any changes.'''<br />
<console><br />
###i## emerge -a --depclean<br />
</console><br />
<br />
=== Update packages ===<br />
'''Update all packages.'''<br />
<console><br />
###i## emerge -uDN @world<br />
</console><br />
<br />
'''Update all packages. Ask for confirmation before performing any changes. Show verbose output.'''<br />
<console><br />
###i## emerge -uavDN @world<br />
</console><br />
<br />
== Emerge options ==<br />
<br />
; --sync<br />
: Updates the portage tree that is located in /usr/portage by default.<br />
<br />
; --search -s<br />
: Searches for matches of the supplied string in the portage tree.<br />
<br />
; --searchdesc -S<br />
: Matches the search string against the description field as well as the package name.<br />
<br />
; --ask -a<br />
: Ask for confirmation before performing any changes.<br />
<br />
; --pretend -p<br />
: Instead of actually performing the merge, simply display what *would* have been installed if --pretend weren't used.<br />
<br />
; --unmerge -C<br />
: Removes all matching packages.<br />
<br />
; --update -u<br />
: Updates packages to the best version available, which may not always be the highest version number due to masking for testing and development.<br />
<br />
; --deep [DEPTH] -D<br />
: force emerge to consider the entire dependency tree of packages, instead of checking only the immediate dependencies of the packages.<br />
<br />
; --newuse -N<br />
: Tells emerge to include installed packages where USE flags have changed since compilation.<br />
<br />
; --depclean -c<br />
: Remove orphaned packages. Cleans the system by removing packages that are not associated with explicitly merged packages.<br />
<br />
; --autounmask-write<br />
: Automatically write package.use settings as necessary to satisfy dependencies.<br />
<br />
; --resume -r<br />
: Resumes the most recent merge list that has been aborted due to an error.<br />
<br />
; --jobs[=JOBS] -j [JOBS]<br />
: Specifies the number of packages to build simultaneously.<br />
<br />
; --load-average [LOAD]<br />
: Specifies that no new builds should be started if there are other builds running and the load average is at least LOAD (a floating-point number).<br />
<br />
== Configuration ==<br />
=== make.conf ===<br />
Emerge can be configured with <code>/etc/portage/make.conf</code><br />
{{File<br />
|/etc/portage/make.conf|<pre><br />
CFLAGS="-march=native -O2 -pipe"<br />
CXXFLAGS="-march=native -O2 -pipe"<br />
<br />
MAKEOPTS="-j2"<br />
EMERGE_DEFAULT_OPTS="--jobs 2 --load-average 2"<br />
INPUT_DEVICES="evdev synaptics"<br />
VIDEO_CARDS="intel i965"<br />
LINGUAS="en en_US en_GB"<br />
ACCEPT_LICENSE="*"<br />
<br />
USE="mmx mmxext sse sse2 sse3 ssse3 threads alsa X gtk xcb dri opengl vaapi udev \<br />
svg x264 xvid gstreamer webm vpx icu bash-completion vim-pager \<br />
-gnome -xscreensaver -cups -fortran -deprecated -iptables -ipv6 -geoloc \<br />
-mta -sendmail -kmod -tiff -live -quicktime -real -gpm -themes"<br />
</pre>}}<br />
<br />
=== package.use ===<br />
Per-package use flags can be configured with <code>/etc/portage/package.use</code><br />
<console><br />
###i## nano /etc/portage/package.use<br />
x11-wm/dwm savedconfig<br />
media-sound/ncmpcpp visualizer clock taglib<br />
</console><br />
<br />
=== package.accept_keywords ===<br />
If you want to install package that has not been tested on your architecture you need to edit <code>/etc/portage/package.accept_keywords</code><br />
<console><br />
###i## nano /etc/portage/package.accept_keywords<br />
=app-misc/screenfetch-9999 **<br />
</console><br />
<br />
== Further info ==<br />
For further info see emerge man page.<br />
<console>$##i## man emerge</console><br />
<br />
[[Category:Portage]]<br />
<br />
[[Category:HOWTO]]<br />
[[Category:Tutorial]]<br />
[[Category:System]]</div>97.82.197.142https://www.funtoo.org/index.php?title=Netboot_image_creation_for_SPARC_machines&diff=1056Netboot image creation for SPARC machines2014-01-26T21:31:23Z<p>97.82.197.142: </p>
<hr />
<div>If your SPARC machine has a dead CD/DVD ROM drive or no CD/DVD ROM drive at all or if, for various reasons, you wish to build a netboot image from scratch the following paragraphs should help you.<br />
<br />
= Concepts = <br />
<br />
Basically, a netboot image is the sum of :<br />
<br />
* Some bootstrap code (loader)<br />
* An '''uncompressed''' kernel image<br />
* An optional ramdisk / initrd image. <br />
<br />
When the machine is powered-on, a Power On Self Test (POST) of the machine is done then, if nothing has been found defective Open Boot checks what the variable ''boot-device'' look like and take appropriate actions. If the machine has been set to boot via the network several situations can happen :<br />
<br />
* if Open Boot has no WAN boot (Open Boot prior 4.17.1 ?) support and no DHCP support, a RARP request is emitted on the network to get an IP address from a RARP server then the machine starts a TFTP session on the machine who provided the IP and request to download a file named after the provided IP address (e.g. 192.168.4.101 => C0A80465).<br />
<br />
* if Open Boot has been set to boot from the network using a DHCP request (''boot-device'' is set to '''net:dhcp''' or '''boot net:dhcp''' has been entered at the Open Boot prompt), the machine will grab its network parameters using a DHCP request then starts to download the file according the DHCP response (filename and TFTP server), or by default adopt the same behavior than above. <br />
<br />
* if Open Boot has been setup to perform a WAN boot, it uses what is contained in the variable ''network-boot-arguments'' to determine what to download from which location and with what networking parameters.<br />
<br />
Once the netboot image has been downloaded, Open Boot transfers the execution the netboot image loader, which, at its turn will transfer to the Linux kernel which will run /sbin/init (or whatever else specified through the kernel command line). On most of the Funtoo machines in the world, /sbin/init will launch Open RC at the end do various things. <br><br />
<br />
Short story:<br />
<pre>OpenBoot -> Netboot loader -> Linux kernel -> /sbin/init -> Open RC -> Login on a tty (agetty+login) or whatever else suitable</pre><br />
<br />
The process is very similar to what happens when booting the machine from its hard drive, nothing magic here. The form varies, but the philosophy remains the same.<br />
<br />
= Limitations =<br />
<br />
According to various sources on the internet and experience returns, it looks like that :<br />
<br />
* sun4u machines (e.g. UltraSPARC I/II/III/IV servers and workstations) do not initialize the processor MMU and thus, '''this ''requires'' the whole netboot image to fit within 4 megabytes'''. What happens if this rule is enforced? Simple: as the buffer where the netboot image is loaded into acts as a 4 megabytes ring-buffer, any byte exceeding the limit will overwrite the previously netboot image loaded data leading to the so famous "Fast Data Access MMU Miss" a couple of seconds after the machine started to download the netboot image.<br />
<br />
* sun4v machines (e.g. UltraSPARC T1 and later) initialize their MMU and thus, are not subject to the above limitation. Pay attention to the startup messages when you power on the machine you will see something like "Init MMU" (assuming you are connected to the virtual console from ALOM):<br />
<br />
<pre><br />
...<br />
0:0>VBSC selecting POST MIN Testing.<br />
0:0>POST enabling threads: ffffffff<br />
0:0>VBSC setting verbosity level 2<br />
0:0>Start Selftest.....<br />
0:0>Master CPU Tests Basic....Done<br />
0:0>Init MMU.....<br />
...<br />
</pre><br />
<br />
Fortunately for us : SPARC machines relies on a very small set of hardware from an model to another (modulo extension cards).<br><br />
Unfortunately for us : 2.6 kernels, tends to be big even with an aggressive strip down of features and aggressive size optimizations.<br />
<br />
= Producing the netboot image =<br />
<br />
== Kernel configuration ==<br />
<br />
It is highly suggested to use modules as much as possible. Of course don't forget to:<br />
<br />
* pull in the correct modules and firmware to handle your network adapter :-)<br />
* Activate the following in General setup:<br />
** Initial RAM filesystem and RAM disk (initramfs/initrd) support<br />
** Embedded system (''Support initial ramdisks compressed...'' choices won't show up until that option is activated)<br />
** Support initial ramdisks compressed using XZ (or what suits the compression you use)<br />
* Put the filesystem used for your RAM disk built-in (suggested: ext2, do not use cramfs unless you want a readonly filesystem).<br />
<br />
== Preparing a ramdisk image ==<br />
<br />
You have two strategies for the initramfs image. You can either create it from:<br />
<br />
# A cpio archive of a live filesystem (so far we didn't succeed in producing a usable compressed cpio archive, the kernel panics on boot)<br />
# A minimalistic raw image created through dd and a loopback device<br />
<br />
=== Raw image creation ===<br />
<br />
First you need to create a flat file which can hold a few megabytes (we us 16 MB here but you '''can''' take less space), associate it to a loopback device and then create a filesystem on it (ext2 in our case):<br />
<br />
<pre><br />
# dd if=/dev/zero of=/usr/src/root.img bs=1M count=16<br />
# losetup /usr/src/root.img /dev/loop0<br />
# mkfs.ext2 /dev/loop0<br />
# mkdir /mnt/netboot-rootfs<br />
# mount /dev/loop0 /mnt/netboot-rootfs<br />
</pre><br />
<br />
=== Structure creation ===<br />
<br />
First, you need to create a bare minimal file system structure in a working directory of you choice, although '''/mnt/netboot-rootfs''' is used here, anything left at of your choice can be used. You will need :<br />
<br />
* <tt>/bin</tt><br />
* <tt>/dev</tt><br />
* <tt>/dev/pts</tt><br />
* <tt>/etc</tt><br />
* <tt>/sbin</tt><br />
* <tt>/lib</tt><br />
* <tt>/usr/bin</tt><br />
* <tt>/usr/sbin</tt><br />
* <tt>/tmp</tt><br />
<br />
<pre><br />
# cd /mnt/netboot-rootfs<br />
netboot-rootfs # mkdir -p bin dev dev/pts etc sbin usr/bin usr/sbin tmp <br />
</pre><br />
<br />
Second, copy your /etc/passwd (shadow password are used, so only the logins are stored here) and /etc/groups :<br />
<br />
<pre><br />
netboot-rootfs # cp /etc/passwd /etc/group etc<br />
</pre><br />
<br />
Although it not mandatory required to copy those two files, it will, however help BusyBox' mdev.<br />
<br />
=== Populating /dev ===<br />
<br />
You have two ways to populate /dev:<br />
<br />
# Let the kernel manages everything for you (devtmpfs): A temporary tmpfs containing special devices entries are created very early at system start up and are then moved in the /dev directory once the root filesystem has been mounted. <br />
# Manually create some entries in what will be included with the ramdisk and let mdev so the rest when the netboot image has been booted. <br />
<br />
For the first alternative, just enable '''Maintain a devtmpfs filesystem to mount at /dev''' and ''Automount devtmpfs at /dev, after the kernel mounted the rootfs'' (see ''Device drivers / Generic Devices Options'') in your kernel configuration. For the second alternative, just use mknod to create some basic devices which are:<br />
<br />
<pre><br />
<br />
</pre><br />
<br />
<br />
=== Mandatory shared object files coming from /lib ===<br />
<br />
In this example dynamically linked binaries are used so the shared objects files their refer to must be copied. As of writing you must copy the following files from /lib to the lib directory located in your working space<br />
<br />
* libblkid.so.1.1.0<br />
* libblkid.so.1 (symlink to libblkid.so.1.1.0)<br />
* libc-2.11.2.so<br />
* libc.so.6 (symlink to libc-2.11.2.so)<br />
* libcom_err.so.2.1<br />
* libcom_err.so.2 (symlink to libcom_err.so.2.1)<br />
* libcrypt.so.1<br />
* libe2p.so.2<br />
* libext2fs.so.2<br />
* ld-2.11.2.so<br />
* ld-linux.so.2 (symlink to ld-2.11.2.so)<br />
* libm.so.6<br />
* libpthread.so.0<br />
* libutil.so.1<br />
* libuuid.so.1<br />
* libz.so.1.2.5<br />
* libz.so.1 (symlink to libz.so.1.2.5)<br />
<br />
<pre><br />
netboot-rootfs # cd /lib<br />
lib # cp libc-2.11.2.so libc-2.11.2.so ld-2.11.2.so ld-linux.so.2 libblkid.so.1.1.0 ..... /mnt/netboot-rootfs/lib<br />
</pre><br />
<br />
You can safely ignore libpam and libnss (if you don't copy the later, you will have to refer the remote hosts by their IP addresses only as libnss handles names resolution facilities). libpam will be unused because BusyBox won't be compiled with Pluggable Authentication Modules support.<br />
<br />
=== Configuring and emerging BusyBox ===<br />
BusyBox (sys-apps/busybox) is a Swiss Knife that regroup in a single compact binary more than 30 well-known utilities (grep, ls, fdisk....). BusyBox does not mimic 100% of the original tools functionalities but supports the most used ones, as such it fits will memory constrained environments such as embedded systems or everywhere else where every byte of code loaded in memory matters. As such it fits very well to a netboot image.<br />
<br />
A recommended configuration for BusyBox can be found in the [[Talk:Netboot image creation for SPARC machines | talk section]] of this page. Just copy the recommended settings in <br />
'''/etc/portage/savedconfig/sys-apps/busybox-1.18.3''' (assuming sys-apps/busybox-1.18.3 is the version available on your system).A few various points on suggested BusyBox configuration:<br />
<br />
* '''No "Standalone shell" (CONFIG_FEATURE_SH_STANDALONE)''': if this option would be set, BusyBox will give the priority to the internal applets having the same name than the external commands (standalone scripts or binaries) you would add to your minimalist environment. A way to circumvent would be to launch the external commands with their absolute path but it is not a convenient way to use from a final user point of view.<br />
<br />
* '''No support for ext2 utilities''': As of writing, the BusyBox ext2 filesystem creation applet has an unwanted behaviour that makes it overwrite the first 1024 bytes of a partition. Creating an ext2 filesystem on the first partition of a hard drive starting at cylinder 0 (required if you want to boot your machine from it) with this applet would simply overwrite the Sun disklabel on the drive, thus killing the partition table on it. <br />
<br />
* '''No support for ReiserFS''': As of writing, the BusyBox ReiserFS is experimental and showed us some glitches.<br />
<br />
* '''No support for fdisk''': As of writing, the BusyBox fdisk applet is unable to generate proper Sun disklabels, thus making OpenBoot protest if you try too make to boot from the hard drive.<br />
<br />
* '''No support for daemons''' like http, telnetd, dhcpd, ftpd or ntpd (not exhaustive) : this is a client only environment.<br />
<br />
The time has now come to emerge BusyBox, this is achieved by:<br />
<pre><br />
# CFLAGS="-mcpu=v9 -O2 -pipe" FEATURES="nodoc noinfo noman" USE="-pam make-symlinks mdev savedconfig" \ <br />
emerge -1 --root=/mnt/netboot-rootfs sys-apps/busybox<br />
</pre><br />
<br />
Here we are asking Portage to:<br />
* Use generic SPARC v9 optimizations (all SPARC v9 processors share the same instruction set modulo specific extensions that are not in the SPARC v9 specification like VIS or VIS II)<br />
* Not deploy any manpages, infopages or any kind of docuementation (see /usr/share) etc.<br />
* Not use PAM (netboot environment is single administrative user only)<br />
* Make symlinks for enabled BusyBox applets in the '''bin''' and '''sbin''' subdirectories of /mnt/netboot-rootfs (BusyBox is a multicall binary)<br />
* Use /mnt/netboot-rootfs as the root directory for the deployment<br />
* Not register sys-apps/busybox in the world file of the Funtoo "mini-instance" located under /mnt/netboot-rootfs /mnt/netboot-rootfs/var/lib/portage/world)<br />
<br />
The backslash and the 2 lines form of the command line is present only for the sake of clarity, you can put everything on a single (long) line.<br />
<br />
=== Putting the kernel modules and firmware images inside the ramdisk image ===<br />
<br />
{{fancywarning|You will need to pass though this section even your kernel has no support for modules because some device drivers in the kernel need a firmware image (this is the case with Broadcom Tigeon 3 network adapters or QLogic Fibre Channel HBA for example).}}<br />
<br />
Go in your kernel source directory and issue the following command<br />
<br />
<pre><br />
# cd /usr/src/linux<br />
linux # make modules_install INSTALL_MOD_PATH=/mnt/netboot-rootfs<br />
</pre><br />
<br />
=== Adding extra mandatory libs ===<br />
<br />
If you add extra binaries to your netboot RAM disk, your are likely due to copy extra shared objects comming for /lib (and/or /usr/lib). To know the dependencies of your binary program, just run ldd on it :<br />
<br />
<pre><br />
# ldd /sbin/fdisk<br />
libblkid.so.1 => /lib/libblkid.so.1 (0xf7f68000)<br />
libc.so.6 => /lib/libc.so.6 (0xf7de8000)<br />
libuuid.so.1 => /lib/libuuid.so.1 (0xf7dd0000)<br />
/lib/ld-linux.so.2 (0xf7fa4000)<br />
</pre><br />
<br />
If you see the output "VDSO" '''do not search for the file existence''', VDSO stands for Virtual Dynamic Shared Object (this virtual shared object is provided by the Linux kernel itself through the remapping of some its code in the userland).<br />
<br />
=== Compressing the initramfs image ===<br />
<br />
Now unmount the raw image and compress it with '''xz''':<br />
<br />
<pre><br />
# cd /usr/src<br />
src # umount /mnt/netboot-rootfs<br />
src # xz --check=none --lzma2=dict=1MiB root.img<br />
src # mv root.img.xz root.img<br />
</pre><br />
<br />
Because we use the xz compression '''must''' use :<br />
<br />
* A CRC32 or no CRC at all (like here)<br />
* A reasonable dictionary size (kernel documentation talks about a dictionary having no more than 1 Mbyte in size, see Documentation/xz.txt).<br />
<br />
{{fancywarning|You must use root.img as the filename and you must put it under /usr/src, else the TFTP image construction process will fail. }}<br />
<br />
== Gluing things together ==<br />
<br />
The root.img is seated, the kernel is rebuilt, now the most exciting part begins: generate the final netboot image. You have several options to get the job being done:<br />
<br />
# Use the command ''tilo'' which comes with sys-boot/silo <br />
# Use the facilities provided with the Linux kernel source code<br />
<br />
At date of writing (February 2011) tilo has a bug that makes one the internal commands it uses to segfault when building over-sized images (> 4 Mbytes), so let's use the Linux kernel black magic. Simply :<br />
<br />
* Go in your /usr/src/linux (Again: simply go there, '''do not change anything''' or rebuild a brand new kernel) <br />
* Do the following incantation : <br />
<br />
<pre><br />
# make tftpboot.img<br />
</pre><br />
<br />
Various things will be checked and after a couple of seconds a file named '''tftpboot.img''' is produced in arch/sparc/boot.<br />
<br />
== What to do next? ==<br />
<br />
Simply copy the freshly produced '''tftpboot.img''' in the right directory of your TFTP server and, if you use symlinks to refer the image, make sure they points on the right file.<br><br />
<br />
That's it!<br />
<br />
At system start-up pay attention to :<br />
<br />
<pre><br />
....<br />
[ 81.921360] Trying to unpack rootfs image as initramfs...<br />
[ 81.922859] rootfs image is not initramfs (no cpio magic); looks like an initrd<br />
[ 81.943133] Freeing initrd memory: 3846k freed<br />
...<br />
[ 103.079351] RAMDISK: xz image found at block 0<br />
[ 107.384859] VFS: Mounted root (ext2 filesystem) on device 1:0.<br />
....<br />
</pre><br />
<br />
= Strategy suggestion =<br />
<br />
As netboot images are required to be as compact as possible a 3 phases strategy is suggested:<br />
# Build a minimalist netboot (you barely need your network card driver, an IP stack, plus the required filesystems for step 2)<br />
# This minimalist netboot will grab another ramdisk image (using NFS for example), eventually unpack it and put it in the VFS (using Union FS for example) which include everything you need like kernel modules you IDE/SCSI/SAS controllers or additional filesystems<br />
# Once everything is in place, just exec what you need (i.e. Open RC, a set of homebrew scripts...)<br />
<br />
<br />
[[Category:HOWTO]]<br />
[[Category:SPARC]]</div>97.82.197.142