about summary refs log tree commit diff stats
path: root/tools/storage.html
blob: f90bca081a6ced6778788ba943bc261ccc9fe9e1 (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
<!DOCTYPE html>
<html dir="ltr" lang="en">
    <head>
        <meta charset='utf-8'>
        <title>Storage</title>
    </head>
    <body>
        <a href="index.html">Tools Index</a>

        <h1>Storage</h1>

        <h2 id="fsck">1. Maintenance</h2>

        <p>SMART provides statistics of disk firmware,
        this system handle errors has their occur. Badblocks        are detected by writing and reading from disk in
        a destructive test. Example of how to view SMART
        statistics of a disk;</p>

        <pre>
        # smartctl -t long /dev/sdb1
        # smartctl -a /dev/sdb1 | less
        # hdparm -I /dev/sda | less
        </pre>

        <p>Mechanical hard drives spindown disks
        and put heads in hold position to save energy
        and protect the disk. This spindow spinup
        can shorter the life expectancy of the hard
        drive. Relevant output from smartctl;</p>

        <p>Settings with hdparm [options] [device];</p>

        <dl>
            <dt>-B</dt>

            <dd>Set the Advanced Power Management feature.
            Possible values are between 1 and 255, low
            values mean more aggressive power management
            and higher values mean better performance.
            Values from 1 to 127 permit spin-down, whereas
            values from 128 to 254 do not. A value of 255
            completely disables the feature.</dd>

            <dt>-S</dt>

            <dd>Set the standby (spindown) timeout for
            the drive. The timeout specifies how long to
            wait in idle (with no disk activity) before
            turning off the motor to save power. The value
            of 0 disables spindown, the values from 1 to
            240 specify multiples of 5 seconds and values
            from 241 to 251 specify multiples of 30
            minutes.</dd>

            <dt>-M</dt>

            <dd>Set the Automatic Acoustic Management
            feature. Most modern hard disk drives have the
            ability to speed down the head movements to
            reduce their noise output. The possible value
            depends on the disk, some disks may not support
            this feature.</dd>
        </dl>

        <pre>
        # hdparm -S 0 /dev/sda
        # hdparm -B 255 /dev/sda
        </pre>

        <p>Set persistent values using udev, edit /etc/udev/rules.d/69-hdparm.rules;</p>

        <pre>
        ACTION=="add", SUBSYSTEM=="block", KERNEL=="sda", RUN=="/usr/bin/hdparm -B 255 -S 0 /dev/sda"
        </pre>

        <p>Search for bad blocks using
        <a href="https://wiki.archlinux.org/index.php/Badblocks">non destructive test;</a></p>

        <pre>
        # badblocks -nsv /dev/sdb1
        </pre>


        <h2 id="mv">2. Moving data</h2>

        <p>Temp partition with 20M-50M;</p>

        <pre>
        (parted) mkpart primary ext4 4000MiB 4050MiB
        </pre>

        <p>Ports partition with 120G allows to host sources, package
        backups and ports;</p>

        <pre>
        (parted) mkpart primary ext4 192000MiB 312000MiB
        </pre>


        <p>Reboot into single-user mode where services aren't started and networking is offline.<p>

        <pre>
        # init 1
        </pre>

        <p>Copy the data:</p>

        <pre>
        # cp -apx /srv/* /mnt/srv
        </pre>

        <p>Rename directory, for later backup;</p>

        <pre>
        # mv /srv /srv.old
        # mkdir /srv
        </pre>

        <p>Edit the <a href="../conf/etc/fstab">/etc/fstab</a>file:</p>

        <pre>
        # Temporary Data /tmp
        UUID=50bf6e55-6461-4dd4-b315-65b53cac0995 /tmp            ext4    defaults,nodev,nosuid,noexec	0	0

        # Server Data /srv
        UUID=6fadcb98-e442-4af7-a5f2-1ddb6100a8c4 /srv            ext4    defaults        0       2

        # Ports Data /usr/ports
        UUID=d1df6743-d3cb-4d5a-badb-96cef3181095 /usr/ports       ext4    defaults,nodev,nosuid,noexec	0       0
        </pre>

        <p>Reboot in normal mode.</p>

        <h2 id="resize">2. Resize filesystem</h2>

        <p>If partition is using lvm read
        <a href="lvm.html#resize">lvm resize</a>, if you are using qemu
        images read <a href="qemu.html#resize">resize images</a></p>

        <pre>
        # resize2fs /dev/sda3
        # e2fsck /dev/sda3
        </pre>

        <a href="index.html">Tools Index</a>
        <p>
        This is part of the Hive System Documentation.
        Copyright (C) 2018
        Hive Team.
        See the file <a href="../fdl-1.3-standalone.html">Gnu Free Documentation License</a>
        for copying conditions.</p>
    </body>
</html>