-
Notifications
You must be signed in to change notification settings - Fork 62
/
swap
169 lines (76 loc) · 3.46 KB
/
swap
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
157
158
159
160
161
162
163
164
165
166
167
168
169
1. Create a linuxacademy.com lab server and mount a disk.
2. The linuxacademy.com lab servers already have swap enabled so first run swapoff to disable the /swapfile in the /etc/fstab file.
[root@localhost etc]# swapoff -a
Note: swapoff -a will disable the swap space listed in /etc/fstab
3. Remove the entry /swapfile from the /etc/fstab file.
[root@localhost etc# vim fstab
#
# /etc/fstab
# Created by anaconda on Fri Oct 17 18:33:48 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=668dbd02-c201-44bc-be76-f606fc9ab8db / xfs defaults 1 1
4. Verify there is no current swap space available
[root@localhost etc]# free -m
total used free shared buffers cached
Mem: 992 225 767 12 1 82
-/+ buffers/cache: 141 851
Swap: 0 0 0
5. Using fdisk create a partition that uses the entire /dev/xvdf disk and make sure to label the device correctly.
[root@localhost dev]# fdisk xvdf
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x69baf224.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost dev]#
6. Format the device with the swap signature.
[root@localhost dev]# mkswap /dev/xvdf1
Setting up swapspace version 1, size = 1047548 KiB
no label, UUID=5713eae2-de6b-4485-af5d-1c659765cd92
7. Activate the swap space.
[root@localhost dev]# swapon /dev/xvdf1
[root@localhost dev]# free -m
total used free shared buffers cached
Mem: 992 216 776 12 0 79
-/+ buffers/cache: 135 857
Swap: 3046 0 3046
8. Add swap space to the /etc/fstab so that it is a persistent mount.
[root@localhost dev]# blkid
/dev/xvda2: UUID="" TYPE="xfs" PARTUUID="9146b810-9a31-4c10-a206-01b0bbaca807"
/dev/xvdf1: UUID="" TYPE="swap"
Grab the UUID to mount the swap device.
[root@localhost dev]# vim /etc/fstab
#
# /etc/fstab
#
UUID=668dbd02-c201-44bc-be76-f606fc9ab8db / xfs defaults 1 1
UUID=YOUR-UUID swap swap defaults 0 0
9. Activate the swap space that is added in the /etc/fstab file.
Since we activated it manually already let's manually deactivate it then activate it based on the /etc/fstab file.
[root@localhost dev]# swapoff /dev/xvdf1
Now activate it persistently based off the /etc/fstab entry.
[root@localhost dev]# swapon -a
-a will activate all swap spaces located in the /etc/fstab