我创建了一个具有8GB根卷的AWS EC2 Linux实例。然后我将EBS音量增加到9GB,然后进入完成状态。它的体积很小,所以调整大小需要几分钟才能完成。
现在,我尝试使用提到的here指令调整卷大小后扩展linux文件系统。但是,我收到以下错误消息。我尝试了两次,整个过程。但它完全一样。
import csv
import re
from robobrowser import RoboBrowser
import time
def rechCadastre(data,result):
time.sleep(0.01)
form=browser.get_form(id="rech")
repetition = ''
if data[2]!='':
repetition = data[2][0]
param={'numeroVoie':data[1],'nomVoie':data[0],'ville':data[3], 'indiceRepetition':repetition}
for x in iter(param):
form[x]=param[x]
time.sleep(0.01)
browser.submit_form(form)
success = browser.select('#onglet')
if not success:
result += "NS,NS"
else:
answer = browser.select('.nomcol')[0]
parcelle= re.split('(\W+)',re.search("Parcelle n\W [0-9]{1,4}",answer.text).group(0))[4]
feuille = re.split('(\W+)',re.search("Feuille [0-9]{1,4} [A-Z]{1,4}",answer.text).group(0))[4]
result += feuille+","+parcelle
browser.back()
return result
data = []
url = "https://www.cadastre.gouv.fr/scpc/accueil.do"
browser = RoboBrowser()
browser.open(url)
infile = open("treated.csv",'rb')
reader=csv.reader(infile)
for row in reader:
data.append(row)
#compt=0
for data_point in data:
# if compt == 20:
# break
# data_point = data[i]
result = data_point[0] + "," + data_point[1] + "," + data_point[2] + "," + data_point[3] + ",,"
nd = data_point[0] == "#N/D"
rep = (data_point[2] == '') or (data_point[2] == 'BIS') or (data_point[2] == 'TER') or (data_point[2] == 'QUATER') and (data_point[2] == 'B')
acceptable = rep and (not nd)
if acceptable:
result = rechCadastre(data_point,result)
print result
# compt += 1
这是图像的屏幕截图。
有人可以帮助我吗?
答案 0 :(得分:2)
只需重启实例,因为它会在启动时自动调整根文件系统的大小。
我自己尝试过。以下是8GB卷的实例:
[ec2-user@ip-172-31-15-216 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 8G 0 disk
└─xvda1 202:1 0 8G 0 part /
[ec2-user@ip-172-31-15-216 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 236M 56K 236M 1% /dev
tmpfs 246M 0 246M 0% /dev/shm
/dev/xvda1 7.8G 985M 6.7G 13% /
修改EBS卷后:
[ec2-user@ip-172-31-15-216 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 9G 0 disk
└─xvda1 202:1 0 8G 0 part /
[ec2-user@ip-172-31-15-216 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 236M 56K 236M 1% /dev
tmpfs 246M 0 246M 0% /dev/shm
/dev/xvda1 7.8G 985M 6.7G 13% /
重启后:
[ec2-user@ip-172-31-15-216 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 9G 0 disk
└─xvda1 202:1 0 9G 0 part /
[ec2-user@ip-172-31-15-216 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 236M 56K 236M 1% /dev
tmpfs 246M 0 246M 0% /dev/shm
/dev/xvda1 8.8G 984M 7.7G 12% /
另请参阅:increase EC2 EBS volume after cloning - resize2fs not working
答案 1 :(得分:1)
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/storage_expand_partition.html
# Before goging to do this, detach and attach the root volume to anothe instance
# Note:
# 1) Before detach the volume, please make a note of device name which going to
# detch from the machine, why because we should mention same name when attaching back, otherwise data will be lost
# 2)
# Identifying device name which we want to expand
lsblk
# Running parted command on the device
sudo parted /dev/xvdf
# Changing the parted units of measure to sectors.
unit s
# Run the print command to list the partitions on the device
print
# if it shows warning, chose fix
# Delete the partition entry for the partition using the number (1) from the previous step
rm 1 # number 1 will change based the partition we want to delete
# Create a new partition that extends to the end of the volume
mkpart Linux 4096s 100%
# Run the print command again to verify your partition
print
# Check to see that any flags that were present earlier are still
# present for the partition that you expanded. In some cases the boot
# flag may be lost. If a flag was dropped from the partition when it was expanded,
# add the flag with the following command, substituting your partition number and the flag name.
# For example, the following command adds the boot flag to partition 1
set 1 boot on
#Run the quit command to exit parted.
quit
# verfiying the device
sudo e2fsck -f /dev/xvdf1