- Si tenemos una instancia Debian en AWS y necesitamos agrandar el disco tenemos que ingresar a la consola de AWS EC2 => Elastic block store => Volumes => seleccionar el volumen a modificar y cambiar el size
- Entramos a la instancia por ssh y verificamos la capacidad total del disco 99G
[root@h0wt0 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
udev 487M 0 487M 0% /dev
tmpfs 100M 4.1M 96M 5% /run
/dev/xvda1 99G 5.2G 90G 6% /
tmpfs 498M 0 498M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 498M 0 498M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/3004
- con el comando lsblk vemos si tomo el cambio que realizamos en el panel de AWS.
[root@h0wt0 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 150G 0 disk
└─xvda1 202:1 0 100G 0 part /
- Con fdisk borramos la particion actual fdisk /dev/xvda => p => d => n => p => default => default => N => w
[root@h0wt0 ~]# fdisk /dev/xvda
Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/xvda: 150 GiB, 161061273600 bytes, 314572800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3249c0f8
Device Boot Start End Sectors Size Id Type
/dev/xvda1 * 2048 209715166 209713119 100G 83 Linux
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): p
Disk /dev/xvda: 150 GiB, 161061273600 bytes, 314572800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3249c0f8
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-314572799, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-314572799, default 314572799):
Created a new partition 1 of type 'Linux' and of size 150 GiB.
Partition #1 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: N
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
- ejecutamos partx y resize2fs
[root@h0wt0 ~]# partx -u /dev/xvda
[root@h0wt0 ~]# resize2fs /dev/xvda1
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 19
The filesystem on /dev/xvda1 is now 39321344 (4k) blocks long.
- Y por ultimo con el comando df -h verificamos que la partición / tenga el nuevo tamaño.
[root@h0wt0 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
udev 487M 0 487M 0% /dev
tmpfs 100M 4.1M 96M 5% /run
/dev/xvda1 148G 5.2G 137G 4% /
tmpfs 498M 0 498M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 498M 0 498M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/3004