Vamos a suponer que tenemos un servidor con una partición de SWAP que queremos eliminar, no la necesitamos.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
root@admsistemas:~# ls -lh /dev/sda* brw-rw---- 1 root disk 8, 0 Jul 18 10:50 /dev/sda brw-rw---- 1 root disk 8, 1 Jul 18 10:50 /dev/sda1 brw-rw---- 1 root disk 8, 2 Jul 18 10:50 /dev/sda2 brw-rw---- 1 root disk 8, 2 Jul 18 10:50 /dev/sda5 root@admsistemas:~# parted -l /dev/sda Model: ATA VBOX HARDDISK (scsi) Disk /dev/sda: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size Type File system Flags 1 1049kB 20.4GB 20.4GB primary ext4 boot 2 20.4GB 21.5GB 1072MB extended 5 20.4GB 21.5GB 1072MB logical linux-swap(v1) root@admsistemas:~# free -m total used free shared buff/cache available Mem: 996 30 776 1 189 832 Swap: 1021 0 1021 |
Primero, vamos a desmontar la SWAP.
1 2 3 4 5 6 7 8 |
root@admsistemas:~# swapoff -a root@admsistemas:~# free -m total used free shared buff/cache available Mem: 996 30 777 1 188 832 Swap: 0 0 0 |
Para eliminar la partición 5 que corresponde a la SWAP, vamos a usar la herramienta parted.
1 |
root@admsistemas:~# apt-get update && apt-get install -y parted |
Empezamos:
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 |
# Podemos ejecutar directamente "parted" o especificar el dispositivo "parted /dev/sda" # Sino especificamos nada, por defecto será /dev/sda root@admsistemas:~# parted GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) help align-check TYPE N check partition N for TYPE(min|opt) alignment help [COMMAND] print general help, or help on COMMAND mklabel,mktable LABEL-TYPE create a new disklabel (partition table) mkpart PART-TYPE [FS-TYPE] START END make a partition name NUMBER NAME name partition NUMBER as NAME print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition quit exit program rescue START END rescue a lost partition near START and END resizepart NUMBER END resize partition NUMBER rm NUMBER delete partition NUMBER select DEVICE choose the device to edit disk_set FLAG STATE change the FLAG on selected device disk_toggle [FLAG] toggle the state of FLAG on selected device set NUMBER FLAG STATE change the FLAG on partition NUMBER toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER unit UNIT set the default unit to UNIT version display the version number and copyright information of GNU Parted # Podemos cambiar de dispositivo en cualquier momento dentro de 'parted' (parted) select /dev/sda Using /dev/sda # Listamos las particiones del dispositivo seleccionado. (parted) print Model: ATA VBOX HARDDISK (scsi) Disk /dev/sda: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size Type File system Flags 1 1049kB 20.4GB 20.4GB primary ext4 boot 2 20.4GB 21.5GB 1072MB extended 5 20.4GB 21.5GB 1072MB logical linux-swap(v1) # Borramos la partición 5, corresponde a la antigua SWAP (parted) rm 5 # Volvemos a listar la tabla de particiones, ahora sin la 5 (parted) print Model: ATA VBOX HARDDISK (scsi) Disk /dev/sda: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 20.4GB 20.4GB primary ext4 boot 2 20.4GB 21.5GB 1072MB extended # Salimos, automáticamente se guarda (parted) quit Information: You may need to update /etc/fstab. |
Eso es todo, podemos verificar como el sistema ya no detecta la partición 5 de la antigua SWAP.
1 2 3 4 |
root@admsistemas:~# ls -lh /dev/sda* brw-rw---- 1 root disk 8, 0 Jul 18 15:56 /dev/sda brw-rw---- 1 root disk 8, 1 Jul 18 15:56 /dev/sda1 brw-rw---- 1 root disk 8, 2 Jul 18 15:56 /dev/sda2 |