First let’s understand the 3 different roles of disk i.e. the data
disk, the OS disk, and the temporary disk.
- A data disk is a managed disk that's attached to a virtual machine to store application data, or other data you need to keep.
- OS disk has pre-installed OS and contain boot volume.
- Every VM contains a temporary disk, which is not a managed disk. The temporary disk provides short-term storage for applications and processes and is intended to only store data such as page or swap files. Data on the temporary disk may be lost during a maintenance event event or when you redeploy a VM. This is the reason temporary disk is not recommended to be used for application or other data storage. During a successful standard reboot of the VM, the data on the temporary disk will persist. On Azure Linux VMs, the temporary disk is typically /dev/sdb and on Windows VMs the temporary disk is D: by default.
Scenario: Expanded OS disk from 32G
to 50G on Azure Platform
Environment: Red Hat Enterprise Linux
Server release 7.6 (Maipo) / Linux version 3.10.0-957.el7.x86_64
WARNING: Before
performing any change to the disk, please take a Snapshot to backup the disk.
[root@redhat76
hasi]#
|
df -h
|
//
verify that “sda2” is to be expanded
|
||||||
Filesystem
|
Size
|
Used Avail Use%
|
Mounted on
|
|||||
/dev/sda2
|
32G
|
2.2G
|
30G
|
7%
|
/
|
|||
devtmpfs
|
948M
|
0
|
948M
|
0%
|
/dev
|
|||
tmpfs
|
959M
|
0
|
959M
|
0%
|
/dev/shm
|
|||
tmpfs
|
959M
|
9.0M
|
950M
|
1%
|
/run
|
|||
tmpfs
|
959M
|
0
|
959M
|
0%
|
/sys/fs/cgroup
|
|||
/dev/sda1
|
497M
|
73M
|
425M
|
15%
|
/boot
|
|||
/dev/sdb1
|
3.9G
|
2.1G
|
1.7G
|
56%
|
/mnt/resource
|
|||
tmpfs
|
192M
|
0
|
192M
|
0%
|
/run/user/1000
|
|||
[root@redhat76
hasi]#
|
sudo
fdisk /dev/sda
|
//
enter
|
fdisk
|
||||
The device presents
a logical sector size
|
that is smaller
than
|
||||||
the physical sector
size. Aligning
|
to
|
a physical sector
(or optimal
|
|||||
I/O) size boundary
is recommended,
|
or
|
performance
may
|
be impacted.
|
||||
Welcome to
fdisk (util-linux 2.23.2).
Changes will remain in
memory only, until you decide to write them.
Be careful before using the
write command.
Command (m for help):
print // list all partition, enter “u” to change display unit to sector
Disk /dev/sda:
|
53.7
GB
|
, 53687091200
bytes, 104857600
|
sectors
|
//
verify the new disk size
|
|||||||||||
Units = sectors of
1 * 512 = 512 bytes
|
|||||||||||||||
Sector size
(logical/physical): 512 bytes / 4096 bytes
|
|||||||||||||||
I/O size
(minimum/optimal): 4096 bytes / 4096 bytes
|
|||||||||||||||
Disk label type:
dos
|
|||||||||||||||
Disk identifier:
0x000ae42d
|
|||||||||||||||
Device
|
Boot
|
Start
|
End
|
Blocks
|
Id
|
System
|
|||||||||
/dev/sda1
|
*
|
2048
|
1026047
|
512000
|
83
|
Linux
|
|||||||||
/dev/sda2
|
1026048
|
67108863
|
33041408
|
83
|
Linux
|
||||||||||
Command
(m for
|
help):
d
|
//
delete partition
|
|||||||||||||
Partition
|
number
(1,2, default 2): 2
|
// select partition 2
|
|||||||||||||
Partition
|
2 is
|
deleted
|
|||||||||||||
Command
(m for
|
help):
n
|
//
create new partition
|
|||||||||||||
Partition
|
type:
|
pprimary (1 primary, 0
extended, 3 free) e extended
Select
(default p): p
|
// select primary
|
|||||||||||||||
Partition
number (2-4, default 2): 2
|
// set partition number as 2 which was deleted
|
|||||||||||||||
First
sector (1026048-104857599, default 1026048):
|
// use default value
|
|||||||||||||||
Using
default value 1026048
|
||||||||||||||||
Last
sector, +sectors or +size{K,M,G}
|
(1026048-104857599, default
104857599):
|
// use default value
|
||||||||||||||
Using
default value 104857599
|
||||||||||||||||
of size
|
49.5
GiB is set
|
|||||||||||||||
Command
(m for help): p
|
//
|
verify new partition is created
|
Disk /dev/sda: 53.7 GB,
53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512
= 512 bytes
Sector size
(logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal):
4096 bytes / 4096 bytes
Disk
label type: dos
Disk identifier: 0x000ae42d
Device Boot
|
Start
|
End
|
Blocks
|
Id
|
System
|
||
/dev/sda1
|
*
|
2048
|
1026047
|
512000
|
83
|
Linux
|
|
/dev/sda2
|
1026048
|
104857599
|
51915776
|
83
|
Linux
|
Command (m for help):
w // save
the change, it will be applied after a reboot The partition table has been
altered!
Calling ioctl()
to re-read partition table.
WARNING: Re-reading the
partition table failed with error 16: 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)
Syncing
disks.
|
||||||
[root@redhat76
hasi]# reboot
|
// reboot
|
|||||
[hasi@redhat76
|
~]$ cat
/etc/fstab
|
// verify the root filesystem type is xfs
|
#
#/etc/fstab
#Created by anaconda on Wed
Oct 31 08:36:45 2018
#Accessible filesystems, by
reference, are maintained under '/dev/disk'
#See man pages fstab(5),
findfs(8), mount(8) and/or blkid(8) for more info
UUID=437f5efe-afcb-4d8f-99e0-a44d73dda2f9
/
|
xfs
|
defaults
|
0
0
|
||||||||||||||
UUID=f7f27132-9ca2-4de3-9a55-4a90d35fc73d
/boot
|
xfs
|
defaults
|
0
0
|
||||||||||||||
[root@redhat76
hasi]# sudo xfs_growfs
|
/dev/sda2
|
//
expand the partition
|
|||||||||||||||
meta-data=/dev/sda2
|
isize=512
|
agcount=4,
agsize=2065088 blks
|
|||||||||||||||
=
|
sectsz=512
|
attr=2,
projid32bit=1
|
|||||||||||||||
=
|
crc=1
|
finobt=0 spinodes=0
|
|||||||||||||||
data
|
=
|
bsize=4096
|
blocks=8260352,
imaxpct=25
|
||||||||||||||
=
|
sunit=0
|
swidth=0 blks
|
|||||||||||||||
naming
|
=version 2
|
bsize=4096
|
ascii-ci=0 ftype=1
|
||||||||||||||
log
|
=internal
|
bsize=4096
|
blocks=4033,
version=2
|
||||||||||||||
=
|
sectsz=512
|
sunit=0
blks, lazy-count=1
|
|||||||||||||||
realtime =none
|
extsz=4096
|
blocks=0,
rtextents=0
|
|||||||||||||||
data
blocks changed from 8260352
|
to
12978944
|
||||||||||||||||
[root@redhat76
hasi]# df -h
|
//
verify the change
|
||||||||||||||||
Filesystem
|
Size
|
Used
Avail Use%
|
Mounted on
|
||||||||||||||
/dev/sda2
|
50G
|
2.2G
|
48G
|
5%
|
/
|
||||||||||||
devtmpfs
|
948M
|
0
|
948M
|
0%
|
/dev
|
||||||||||||
tmpfs
|
959M
|
0
|
959M
|
0%
|
/dev/shm
|
||||||||||||
tmpfs
|
959M
|
9.0M
|
950M
|
1%
|
/run
|
||||||||||||
tmpfs
|
959M
|
0
|
959M
|
0%
|
/sys/fs/cgroup
|
||||||||||||
/dev/sda1
|
497M
|
73M
|
425M
|
15%
|
/boot
|
||||||||||||
/dev/sdb1
|
3.9G
|
2.1G
|
1.7G
|
56%
|
/mnt/resource
|
||||||||||||
tmpfs
|
192M
|
0
|
192M
|
0%
|
/run/user/1000
|
[NOTE]
If the filesystem type is ext4, use the following command to expand
the partition:
[root@redhat76
hasi]# sudo resize2fs
/dev/sda2 // expand the partition
1 Comments
Great info. Thanks for Sharint
ReplyDeletePost a Comment
Thanks for your comment !
I will review your this and will respond you as soon as possible.