Redimensionando a partição do novo disco rígido

1

Acabei de substituir meu disco de 500 GB por um de 1TB. Eu usei um duper para copiar os 500GB para o 1TB. Agora estou tentando expandir a partição ( /dev/sda3 ) para aproveitar o novo espaço. Aqui estão os comandos (mais recentes) que eu tentei. Eu gostaria de fazer sem gparted porque eu só tenho acesso SSH para a máquina.

tiny@ubuntu:~$ lsblk
NAME                 MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                    8:0    0 931.5G  0 disk 
├─sda1                 8:1    0   512M  0 part /boot/efi
├─sda2                 8:2    0   488M  0 part /boot
└─sda3                 8:3    0 929.4G  0 part 
  └─ubuntu--vg-root 252:0    0 464.8G  0 lvm  /
tiny@ubuntu:~$ sudo resize2fs /dev/mapper/ubuntu--vg-root 
resize2fs 1.42.13 (17-May-2015)
The filesystem is already 121839616 (4k) blocks long.  Nothing to do!

tiny@ubuntu:~$ sudo lvextend /dev/mapper/ubuntu--vg-root /dev/sda3
  No free extents on physical volume "/dev/sda3".
  No specified PVs have space available.
tiny@ubuntu:~$ 
    
por TinyTheBrontosaurus 15.12.2017 / 18:01

1 resposta

3

Veja o que aconteceu:

sudo pvresize /dev/sda3
sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-root
sudo resize2fs /dev/mapper/ubuntu--vg-root

e aqui está a saída:

tiny@ubuntu:~$ lsblk
NAME                 MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                    8:0    0 931.5G  0 disk 
├─sda1                 8:1    0   512M  0 part /boot/efi
├─sda2                 8:2    0   488M  0 part /boot
└─sda3                 8:3    0 929.4G  0 part 
  └─ubuntu--vg-root 252:0    0 464.8G  0 lvm  /
tiny@ubuntu:~$ df -h
Filesystem                    Size  Used Avail Use% Mounted on
udev                           95G     0   95G   0% /dev
tmpfs                          19G   11M   19G   1% /run
/dev/mapper/ubuntu--vg-root  458G  239G  198G  55% /
tmpfs                          95G     0   95G   0% /dev/shm
tmpfs                         5.0M     0  5.0M   0% /run/lock
tmpfs                          95G     0   95G   0% /sys/fs/cgroup
/dev/sda2                     473M  120M  329M  27% /boot
/dev/sda1                     511M  3.4M  508M   1% /boot/efi
tmpfs                          19G     0   19G   0% /run/user/1000
tiny@ubuntu:~$ sudo pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
tiny@ubuntu:~$ sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-root
  Size of logical volume ubuntu-vg/root changed from 464.78 GiB (118984 extents) to 929.41 GiB (237929 extents).
  Logical volume root successfully resized.
tiny@ubuntu:~$ lsblk
NAME                 MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                    8:0    0 931.5G  0 disk 
├─sda1                 8:1    0   512M  0 part /boot/efi
├─sda2                 8:2    0   488M  0 part /boot
└─sda3                 8:3    0 929.4G  0 part 
  └─ubuntu--vg-root 252:0    0 929.4G  0 lvm  /
tiny@ubuntu:~$ df -h
Filesystem                    Size  Used Avail Use% Mounted on
udev                           95G     0   95G   0% /dev
tmpfs                          19G   11M   19G   1% /run
/dev/mapper/ubuntu--vg-root  458G  239G  198G  55% /
tmpfs                          95G     0   95G   0% /dev/shm
tmpfs                         5.0M     0  5.0M   0% /run/lock
tmpfs                          95G     0   95G   0% /sys/fs/cgroup
/dev/sda2                     473M  120M  329M  27% /boot
/dev/sda1                     511M  3.4M  508M   1% /boot/efi
tmpfs                          19G     0   19G   0% /run/user/1000
tiny@ubuntu:~$ sudo resize2fs /dev/mapper/ubuntu--vg-root
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mapper/ubuntu--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 30, new_desc_blocks = 59
The filesystem on /dev/mapper/ubuntu--vg-root is now 243639296 (4k) blocks long.

tiny@ubuntu:~$ df -h
Filesystem                    Size  Used Avail Use% Mounted on
udev                           95G     0   95G   0% /dev
tmpfs                          19G   11M   19G   1% /run
/dev/mapper/ubuntu--vg-root  915G  239G  637G  28% /
tmpfs                          95G     0   95G   0% /dev/shm
tmpfs                         5.0M     0  5.0M   0% /run/lock
tmpfs                          95G     0   95G   0% /sys/fs/cgroup
/dev/sda2                     473M  120M  329M  27% /boot
/dev/sda1                     511M  3.4M  508M   1% /boot/efi
tmpfs                          19G     0   19G   0% /run/user/1000
tiny@ubuntu:~$
    
por TinyTheBrontosaurus 15.12.2017 / 18:22