aboutsummaryrefslogtreecommitdiffstats
path: root/core/reboot.html
blob: c60265a0a0693eb68eb7a59f746f89bdc964d6c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html dir="ltr" lang="en">
    <head>
        <meta charset='utf-8'>
        <title>1.4. Prepare Reboot</title>
    </head>
    <body>

        <a href="index.html">Core OS Index</a>

        <h1>1.4. Prepare for Reboot</h1>

        <p>Follow this instructions with active chroot,
        first <a href="configure.html#chroot">mount partitions</a>
        and before chroot mount follow file systems;</p>

        <pre>
        $ sudo mount --bind /dev $CHROOT/dev
        $ sudo mount -vt devpts devpts $CHROOT/dev/pts
        $ sudo mount -vt tmpfs shm $CHROOT/dev/shm
        $ sudo mount -vt proc proc $CHROOT/proc
        $ sudo mount -vt sysfs sysfs $CHROOT/sys
        </pre>

        <p>Now you can chroot;</p>

        <pre>
        $ sudo chroot $CHROOT /usr/bin/env -i \
          HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
          PATH=/bin:/usr/bin:/sbin:/usr/sbin \
          /bin/bash --login
        </pre>

        <h2 id="linux">1.4.1. Port kernel</h2>

        <p>Core ports have two
        <a href="linux.html">linux kernels</a>,
        <a href="ports/linux-libre">linux-libre</a> and
        <a href="ports/linux-blob">linux-blob</a>.
        Port linux-libre kernel is a true source based kernel that
        respects your freedoms, is x86_64 but not generic configured,
        select modules (drivers) for your hardware, for example
        correct graphic driver and disk. Port linux-blob is dangerous,
        contain blobs (from bad corporations).</p>

        <p>Both ports apply grsecurity patch and are configured in
        a way that break building some packages and have performance
        impact in building process. Solution is to have several kernels,
        production, testing, debug with one of them without grsecurity.</p>

        <pre>
        # cd /usr/ports/c9-ports/linux-libre
        # pkgmk -d
        # pkgadd /usr/ports/packages/linux-libre#4.9.11-2.pkg.tar.gz
        </pre>

        <h2 id="grub">1.4.3. Configuring Grub2</h2>

        <p>Create grub file in /etc/default/grub with values;</p>

        <pre>
        GRUB_DISABLE_LINUX_UUID=false
        GRUB_ENABLE_LINUX_LABEL=false
        </pre>

        <p><a href="http://www.gnu.org/software/grub/manual/grub.html">Grub Manual</a>,
        install grub on MBR of disk sdb;</p>

        <pre>
        # grub-install /dev/sdb
        Installation finished. No error reported.
        </pre>

        <p>If you are installing on removable media;</p>

        <pre>
        # grub-install --removable /dev/sdb
        Installation finished. No error reported.
        </pre>

        <p>grub-mkconfig generates grub.cfg, it will try to discover
        available kernels and attempt to generate menu entries for
        them;</p>

        <pre>
        # grub-mkconfig -o /boot/grub/grub.cfg
        Generating grub.cfg ...
        Found linux image: /boot/vmlinuz-4.1.30-crux
        Found initrd image: /boot/initramfs-4.1.30-crux.img
        done
        #
        </pre>

        <p>Check /boot/grub/grub.cfg, if is wrong add menu to
        /etc/grub.d/40_custom, replace correct partition from grub-prob
        output and correct UUID from fstab or blkid</p>

        <pre>
        # grub-probe --target=hints_string /
        </pre>

        <h3>Rescue iso</h3>

        <p>Simple way to have "resque" system is to mount boot as read only,
        this assures that even as root nothing can be changed without remount.
        To have different system independent from host grub will have entry to
        boot small iso on /boot partition;</p>

        <p>Crux iso is not used because at the moment it fails to
        find "crux-media" during or after init.</p>

        <pre>
        $ wget http://ftp.nluug.nl/os/Linux/distr/tinycorelinux/7.x/x86/release/CorePlus-current.iso
        $ sudo mv CorePlus-current.iso /boot/tinycore.iso
        </pre>

        <p>Edit /etc/grub.d/40_custom</p>

        <pre>

        menuentry "Rescue" {
            load_video
            set gfxpayload=keep

            set isofile="/tinycore.iso"
            loopback loop $isofile
            linux (loop)/boot/vmlinuz64 loglevel=3 cde
            initrd (loop)/boot/corepure64.gz
        }

        <h2 id="checkup">1.4.4. Checkup</h2>

        <p>If you have qemu installed you can see if it boots, in this
        example sdb is usb external drive;</p>

        <pre>
        # qemu-system-x86_64 -kernel /boot/vmlinuz-linux -initrd /boot/initramfs-linux.img -append root=/dev/sdb /dev/sdb2
        </pre>

        <h3>Debug Grub</h3>

        <h3>Debug initram</h3>

        <pre>
        /usr/lib/dracut/skipcpio /boot/initramfs-4.9.11-blob.img | gunzip -c | cpio -i -d
        36875 blocks
        </pre>

        <a href="index.html">Core OS Index</a>
        <p>This is part of the c9-doc Manual.
        Copyright (C) 2017
        c9 team.
        See the file <a href="../fdl-1.3-standalone.html">Gnu Free Documentation License</a>
        for copying conditions.</p>
    </body>
</html>