... | @@ -222,6 +222,126 @@ Finally resize the filesystem: |
... | @@ -222,6 +222,126 @@ Finally resize the filesystem: |
|
|
|
|
|
See also the [LVM howto](howto/lvm).
|
|
See also the [LVM howto](howto/lvm).
|
|
|
|
|
|
|
|
#### What if lvm is not available?
|
|
|
|
|
|
|
|
If is possible to resize a partition using fdisk. In the following example we have a sda1 partition that we want to extend from 10G to 20G to fill up the free space on /dev/sda
|
|
|
|
|
|
|
|
```
|
|
|
|
# lsblk -a
|
|
|
|
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
|
|
|
fd0 2:0 1 4K 0 disk
|
|
|
|
sda 8:0 0 20G 0 disk
|
|
|
|
└─sda1 8:1 0 10G 0 part /
|
|
|
|
sdb 8:16 0 2G 0 disk [SWAP]
|
|
|
|
sdc 8:32 0 40G 0 disk /srv
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
We use fdisk on the device:
|
|
|
|
|
|
|
|
```
|
|
|
|
# fdisk /dev/sda
|
|
|
|
|
|
|
|
Welcome to fdisk (util-linux 2.33.1).
|
|
|
|
Changes will remain in memory only, until you decide to write them.
|
|
|
|
Be careful before using the write command.
|
|
|
|
|
|
|
|
|
|
|
|
Command (m for help): p # prints the partition table
|
|
|
|
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
|
|
|
|
Disk model: QEMU HARDDISK
|
|
|
|
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: 0x73ab5f76
|
|
|
|
|
|
|
|
Device Boot Start End Sectors Size Id Type
|
|
|
|
/dev/sda1 * 2048 20971519 20969472 10G 83 Linux # note the starting sector for later
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Now we delete the partition. Note that the data will not be delete only the partition table will be altered.
|
|
|
|
|
|
|
|
```
|
|
|
|
Command (m for help): d
|
|
|
|
Selected partition 1
|
|
|
|
Partition 1 has been deleted.
|
|
|
|
|
|
|
|
Command (m for help): p
|
|
|
|
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
|
|
|
|
Disk model: QEMU HARDDISK
|
|
|
|
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: 0x73ab5f76
|
|
|
|
```
|
|
|
|
|
|
|
|
Now we create the new partition:
|
|
|
|
|
|
|
|
```
|
|
|
|
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): 1
|
|
|
|
First sector (2048-41943039, default 2048): 2048 # this is the starting sector from above.
|
|
|
|
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): 41943039
|
|
|
|
|
|
|
|
Created a new partition 1 of type 'Linux' and of size 20 GiB.
|
|
|
|
Partition #1 contains a ext4 signature.
|
|
|
|
|
|
|
|
Do you want to remove the signature? [Y]es/[N]o: n # we want to keep the previous signature
|
|
|
|
|
|
|
|
Command (m for help): p
|
|
|
|
|
|
|
|
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
|
|
|
|
Disk model: QEMU HARDDISK
|
|
|
|
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: 0x73ab5f76
|
|
|
|
|
|
|
|
Device Boot Start End Sectors Size Id Type
|
|
|
|
/dev/sda1 2048 41943039 41940992 20G 83 Linux
|
|
|
|
|
|
|
|
Command (m for help): w
|
|
|
|
The partition table has been altered.
|
|
|
|
Syncing disks.
|
|
|
|
```
|
|
|
|
Now we check the partitions for the machine:
|
|
|
|
|
|
|
|
```
|
|
|
|
# lsblk -a
|
|
|
|
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
|
|
|
fd0 2:0 1 4K 0 disk
|
|
|
|
sda 8:0 0 20G 0 disk
|
|
|
|
└─sda1 8:1 0 20G 0 part /
|
|
|
|
sdb 8:16 0 2G 0 disk [SWAP]
|
|
|
|
sdc 8:32 0 40G 0 disk /srv
|
|
|
|
```
|
|
|
|
|
|
|
|
If we check the free disk space on the device we will notice it has not changed yet:
|
|
|
|
```
|
|
|
|
# df -h /
|
|
|
|
Filesystem Size Used Avail Use% Mounted on
|
|
|
|
/dev/sda1 9.8G 8.5G 874M 91% /
|
|
|
|
```
|
|
|
|
|
|
|
|
We need to resize it:
|
|
|
|
|
|
|
|
```
|
|
|
|
# resize2fs /dev/sda1
|
|
|
|
resize2fs 1.44.5 (15-Dec-2018)
|
|
|
|
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
|
|
|
|
old_desc_blocks = 2, new_desc_blocks = 3
|
|
|
|
The filesystem on /dev/sda1 is now 5242624 (4k) blocks long.
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Adding disks
|
|
### Adding disks
|
|
|
|
|
|
A disk can be added to an instance with the `modify` command as
|
|
A disk can be added to an instance with the `modify` command as
|
... | | ... | |