DEV Community

Raphael Carvalho
Raphael Carvalho

Posted on

Redimensionando espaço em disco em servidor linux sem LVM


  1. Primeiramente, redimensione o espaço em disco do server no wmware, ou outro virtualizador;

  2. Inicia o server;

  3. Inicia o parted na vm:

root@srvubuntu02:~# parted /dev/sda
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
Enter fullscreen mode Exit fullscreen mode
  1. Comando print para ver o esquema de partição e o tamanho dos volumes atuais:
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 26.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  21.5GB  21.5GB  ext4
(parted)
Enter fullscreen mode Exit fullscreen mode

4.1 Após perceber que o "End" é menor que o tamanho real do Disk sda, devemos inserir o comando resizepart 2 100%:

(parted) resizepart 2 100%
Warning: Partition /dev/sda2 is being used. Are you sure you want to continue?
Enter fullscreen mode Exit fullscreen mode

4.2. Ao ser questionado se deseja mesmo fazer as mudanças, digite Yes:

Yes/No? `Yes`
Enter fullscreen mode Exit fullscreen mode

4.3. Escreva o novo tamanho total com "GB" ao final:

End?  [21.5GB]? 26.8GB
Enter fullscreen mode Exit fullscreen mode
  1. Por fim, saia do parted com o comando quit
(parted) quit
Information: You may need to update /etc/fstab.
Enter fullscreen mode Exit fullscreen mode
  1. Para ver as mudanças em disco:
root@srvubuntu02:~# fdisk -l /dev/sda | grep ^/dev
/dev/sda1   2048     4095     2048   1M BIOS boot
/dev/sda2   4096 52343750 52339655  25G Linux filesystem
Enter fullscreen mode Exit fullscreen mode
  1. Percebe que não houve alteração real:
root@srvubuntu02:~# df -h

Filesystem      Size  Used Avail Use% Mounted on
udev            933M     0  933M   0% /dev
tmpfs           196M  1.3M  195M   1% /run
/dev/sda2        20G  4.6G   14G  25% /
tmpfs           977M     0  977M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           977M     0  977M   0% /sys/fs/cgroup
/dev/loop0       55M   55M     0 100% /snap/core18/1880
/dev/loop1       30M   30M     0 100% /snap/snapd/8542
/dev/loop2       72M   72M     0 100% /snap/lxd/16099
tmpfs           196M     0  196M   0% /run/user/1000
Enter fullscreen mode Exit fullscreen mode
  1. Por fim, aplica o comando para redimensionar o disco(sda2 neste caso):
root@srvubuntu02:~# `resize2fs /dev/sda2` _#Agora sim, redimensiona o disco_
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 4
The filesystem on /dev/sda2 is now 6542456 (4k) blocks long.
Enter fullscreen mode Exit fullscreen mode
  1. Veja aplicado:
root@srvubuntu02:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            933M     0  933M   0% /dev
tmpfs           196M  1.3M  195M   1% /run
/dev/sda2        25G  4.6G   19G  20% /
tmpfs           977M     0  977M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           977M     0  977M   0% /sys/fs/cgroup
/dev/loop0       55M   55M     0 100% /snap/core18/1880
/dev/loop1       30M   30M     0 100% /snap/snapd/8542
/dev/loop2       72M   72M     0 100% /snap/lxd/16099
tmpfs           196M     0  196M   0% /run/user/1000
root@srvubuntu02:~#
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
rapha__carvalho profile image
Raphael Carvalho

Para adicionar um disco no vmware:
tutorialspoint.com/how-to-create-a...