Browse code

Added documentation on expanding disk partition

Change-Id: Ifdf0759a1401d4010270913be47e328f6e226140
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5064
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Sharath George

DĂȘnis Volpato Martins authored on 2017/01/25 05:49:24
Showing 1 changed files
... ...
@@ -67,6 +67,7 @@
67 67
     -   [Checking Disk Space](#checking-disk-space)
68 68
     -   [Adding a Disk and Partitioning
69 69
         It](#adding-a-disk-and-partitioning-it)
70
+    -   [Expanding Disk Partition](#expanding-disk-partition)
70 71
     -   [fdisk](#fdisk)
71 72
     -   [fsck](#fsck)
72 73
     -   [Fixing File System Errors When fsck
... ...
@@ -1080,6 +1081,66 @@ Check your work:
1080 1080
 	tmpfs            35M     0   35M   0% /run/user/0
1081 1081
 	/dev/sdb1       945M  1.3M  895M   1% /newdata
1082 1082
 
1083
+### Expanding Disk Partition
1084
+
1085
+If you need more space, you can expand the last partition of your disk after resizing the disk. In the examples we are assuming `sda` as disk device.
1086
+
1087
+After the disk is resized in the virtual machine, it's necessary to tell the system to recognize the new disk ending boundary without rebooting:
1088
+
1089
+	echo 1 > /sys/class/block/sda/device/rescan
1090
+
1091
+You will need to install the parted package to resize the disk partition, which is not available by default. Just run the following command to install it: `tdnf install parted`.
1092
+
1093
+	# parted /dev/sda
1094
+	GNU Parted 3.2
1095
+	Using /dev/sda
1096
+	Welcome to GNU Parted! Type 'help' to view a list of commands.
1097
+
1098
+List all partitions available to fix the GPT and check the last partition number:
1099
+
1100
+	(parted) print
1101
+
1102
+	Warning: Not all of the space available to /dev/sda appears to be used, you can
1103
+	fix the GPT to use all of the space (an extra 4194304 blocks) or continue with
1104
+	the current setting? 
1105
+	Fix/Ignore?
1106
+
1107
+Press `f` to fix the GPT layout.
1108
+
1109
+	Model: VMware Virtual disk (scsi)
1110
+	Disk /dev/sda: 34.4GB
1111
+	Sector size (logical/physical): 512B/512B
1112
+	Partition Table: gpt
1113
+	Disk Flags: 
1114
+
1115
+	Number  Start   End     Size    File system  Name  Flags
1116
+	1      1049kB  3146kB  2097kB                     bios_grub
1117
+	2      3146kB  8590MB  8587MB  ext4
1118
+
1119
+In this case we have the partition `2` as last, then we extend the partition to 100% of the remaining size:
1120
+
1121
+	(parted) resizepart 2 100%
1122
+
1123
+Finally, expand the filesystem to the new size:
1124
+
1125
+	resize2fs /dev/sda2
1126
+	resize2fs 1.42.13 (17-May-2015)
1127
+	Filesystem at /dev/sda2 is mounted on /; on-line resizing required
1128
+	old_desc_blocks = 1, new_desc_blocks = 2
1129
+	The filesystem on /dev/sda2 is now 8387835 (4k) blocks long.
1130
+
1131
+The new space is already available in the system:
1132
+
1133
+	df -h
1134
+	Filesystem      Size  Used Avail Use% Mounted on
1135
+	/dev/root        32G  412M   30G   2% /
1136
+	devtmpfs       1001M     0 1001M   0% /dev
1137
+	tmpfs          1003M     0 1003M   0% /dev/shm
1138
+	tmpfs          1003M  252K 1003M   1% /run
1139
+	tmpfs          1003M     0 1003M   0% /sys/fs/cgroup
1140
+	tmpfs          1003M     0 1003M   0% /tmp
1141
+	tmpfs           201M     0  201M   0% /run/user/0
1142
+
1083 1143
 ### fdisk
1084 1144
 
1085 1145
 The `fdisk` command manipulates the disk partition table. You can, for example, use `fdisk` to list the disk partitions so that you can identify the root Linux file system. Here is an truncated example showing `/dev/sda1` to be the root Linux partition: