Правильно измените размер виртуального диска Azure VM

Я просто изменил размер диска, подключенного к виртуальной машине Linux (Ubuntu 18.04) в Azure, с помощью портала. Нужно ли переразбивать его? сейчас?

Я освободил машину и установил размер диска 200 ГБ в поле «Конфигурация», затем перезагрузил его. На портале размер диска теперь отображается как 200 ГБ. Но когда я запускаю df -h на виртуальной машине, он по-прежнему показывает исходный размер диска в 100 Гб ('/ dev / sdb1', ниже).

Я довольно не осведомлен о дисках Linux и не знаю, что такое Azure позаботится по умолчанию.

Спасибо!

$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs   28G     0   28G   0% /dev
tmpfs          tmpfs     5.5G  1.2M  5.5G   1% /run
/dev/sda1      ext4       97G   32G   66G  33% /
tmpfs          tmpfs      28G  8.0K   28G   1% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs      28G     0   28G   0% /sys/fs/cgroup
/dev/loop0     squashfs   40M   40M     0 100% /snap/hub/43
/dev/loop1     squashfs   94M   94M     0 100% /snap/core/9066
/dev/loop2     squashfs   13M   13M     0 100% /snap/hub/29
/dev/loop3     squashfs   98M   98M     0 100% /snap/core/9289
/dev/sdb1      ext4       99G   96G     0 100% /data
/dev/sdc1      ext4     1007G  792G  164G  83% /cdata
/dev/sdd1      ext4      334G   69M  317G   1% /mnt
tmpfs          tmpfs     5.5G   28K  5.5G   1% /run/user/113
tmpfs          tmpfs     5.5G     0  5.5G   0% /run/user/1003
0
задан 27 June 2020 в 06:09

1 ответ

I found an answer; first a couple of key points:

  • OS disks on Azure VMs are automatically re-partitioned when they are resized
  • Other disks including the default /data disk that comes with a DSVM are not automatically re-partioned, so once you've resized a data disk, you have to re-partition it to use the space you created.
  • A warning that your home directory is probably on /data; therefore by un-mounting the disk in the first step of the instructions, you can lock yourself out of SSH (as I did) if you have disabled password access and your private SSH key is in the ~/.ssh/ directory, as it probably is. If that happens, you can get back in through the Azure portal (find your VM, look near the bottom of the sidebar under Support and Troubleshooting —> Reset Password, then check “Configuration Only”, then "Update".)

The rest of the process is explained quite well in these Azure docs. They expect you to know is that the disk itself is probably called something like /dev/sba and any partitions on it will have the same name with a number added (for example /dev/sba1, /dev/sba2), and so on. Warning: these names are assigned asynchronously, and they can change if you restart your VM.

For people in a hurry, the procedure to resize the existing partition is:

#Find the name of your disk:  
df -Th 

#Unmount the disk (in this example it's "sdc1")  
sudo umount /dev/sdc1  

#Call the interactive 'parted' command  
sudo parted /dev/sdc
   #1. Type "print" and note the size of the disk
   #2. Type "resizepart"
   #      A. Type the partition number
   #      B. Type the size from the "print" command to make a full-size partition
   #3. Type "quit" to exit

#Clean up any errors and check the consistency
sudo e2fsck -f /dev/sdc1

#Resize the file system, finally
sudo resize2fs /dev/sdc1

#Remount the disk
sudo mount /dev/sdc1 /data #or whatever you want to call it

#Check to make sure it worked
df -h

It looks (and is) a bit scary, but it only takes a couple of minutes. I'd recommend backing up your disk first.

0
ответ дан 30 July 2020 в 22:20

Другие вопросы по тегам:

Похожие вопросы: