Parted, LVM Y XFS: Redimensionado Particiones
Este es un buen motivo para escribir un post. Hoy he dejado de usar definitivamente fdisk y ahora uso parted lo cual, es un salto cualitativo.
Y como tenia que redimensionar un par de nodos de Hadoop, desde la particion del disco hasta el FS pasando por el LVM, que mejor que escribirlo en un post :)
Vamos al lio, seleccionar vuestra victima, ssh dentro y empezamos
- Vamos a
partedy escribirmosresizepart1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20DEV root@hadoop-2:/home/me# parted
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) version
GNU Parted 3.1
Copyright (C) 1998 - 2006 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
(parted) rescue
align-check disk_set disk_toggle help mklabel mkpart mktable name print quit rescue rm select set toggle unit version
(parted) exit - Whoopps…..
resizepartparece que no existe y solo estarescue…
Actualiza a la ultima version :)1
2
3
4
5
6...
Resolving Dependencies
--> Running transaction check
---> Package parted.x86_64 0:3.1-28.el7 will be updated
---> Package parted.x86_64 0:3.1-29.el7 will be an update
... - Ahora si….volvemos a parted
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21<<< NEW-DEV >>> root@hadoop-2:/home/nicolast# parted
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit b
(parted) print free
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 214748364800B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
32256B 1048575B 1016320B Free Space
1 1048576B 1074790399B 1073741824B primary xfs boot
2 1074790400B 42949672959B 41874882560B primary lvm
3 42949672960B 107374182399B 64424509440B primary lvm
4 107374182400B 171798691839B 64424509440B primary lvm
171798691840B 214748364799B 42949672960B Free Space
(parted) - cambiamos a
unit bpara ver los Bytes y redimensionamos la particion 4…1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16(parted) resizepart 4 214748364799B
(parted) print free
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 214748364800B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
32256B 1048575B 1016320B Free Space
1 1048576B 1074790399B 1073741824B primary xfs boot
2 1074790400B 42949672959B 41874882560B primary lvm
3 42949672960B 107374182399B 64424509440B primary lvm
4 107374182400B 214748364799B 107374182400B primary lvm
(parted) - Comprobamos que efectivamente, ya tenemos la particion redimensionada; Vamonos de aqui a los volumenes…
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<<< NEW-DEV >>> root@hadoop-2:/home/nicolast# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name cl
PV Size <39.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 9983
Free PE 0
Allocated PE 9983
PV UUID Rq1dIO-PtRe-Ua2A-sgGb-QPwm-UyD4-GNuHuV
--- Physical volume ---
PV Name /dev/sda3
VG Name cl
PV Size 60.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 15359
Free PE 0
Allocated PE 15359
PV UUID ybGtAm-Xkbx-Gnx5-BDAi-tLAT-f85x-xqMddu
--- Physical volume ---
PV Name /dev/sda4
VG Name cl
PV Size 60.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 15359
Free PE 10239
Allocated PE 5120
PV UUID ZPWYYD-h1jW-jPYt-yBVG-tyM9-Ue68-LwVitX - Ahora vamos agrandar el volumen fisico (PV)
/dev/sda41
2
3<<< NEW-DEV >>> root@hadoop-2:/home/nicolast# pvresize /dev/sda4
Physical volume "/dev/sda4" changed
1 physical volume(s) resized / 0 physical volume(s) not resized - Y hacemos lo propio con el Volumen (LV) pero primero miramos cual es el que queremos
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<<< NEW-DEV >>> root@hadoop-2:/home/nicolast# lvdisplay
--- Logical volume ---
LV Path /dev/cl/var
LV Name var
VG Name cl
LV UUID 72OFxo-afGU-q32Z-Mmxa-wK9k-kSwS-pVbviw
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2017-02-17 09:49:41 +0000
LV Status available
# open 1
LV Size 24.11 GiB
Current LE 6173
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:4
--- Logical volume ---
LV Path /dev/cl/hadoop
LV Name hadoop
VG Name cl
LV UUID 2xd80b-B9cK-HX0E-A9b3-jIsD-IvJa-lll3PP
LV Write Access read/write
LV Creation host, time hadoop-2.dev1.knockout.local, 2017-08-29 13:11:57 +0000
LV Status available
# open 1
LV Size <60.01 GiB
Current LE 15362
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:5 - Vamos a por el
/dev/cl/hadoop, asi que ejecutamos este comando:lvresize -l +100%FREE {{ volume }}1
2
3<<< NEW-DEV >>> root@hadoop-2:/home/nicolast# lvresize -l +100%FREE /dev/cl/hadoop
Size of logical volume cl/hadoop changed from <60.01 GiB (15362 extents) to 140.00 GiB (35841 extents).
Logical volume cl/hadoop successfully resized. - Y ahora toca agrandar el sistema de ficheros, que en nuestro caso es XFS
1
2
3
4
5
6
7
8
9
10
11<<< NEW-DEV >>> root@hadoop-2:/home/nicolast# xfs_growfs /dev/mapper/cl-hadoop
meta-data=/dev/mapper/cl-hadoop isize=512 agcount=4, agsize=3932672 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=15730688, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=7681, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 15730688 to 36701184 - Listo! ya tenemos la particion, volumen y fs agrandado.