Extended Partition of Linux Data Disk
Overview
The scaling up is only to scale up the storage capacity of the disk, not the zone and file system. You can use the disk only after you manually complete the following operations.
Note:
- Before the scaling up of partition, we strongly recommend you to create a snapshot for the disk. For the details, please refer to Create a Disk Snapshot;
- Before the scaling up of partition, please confirm the existing partition mode of the Cloud Disk Stoarge (CDS), and the current partition operation mode should keep consistent with the existing mode;
- If you have any questions, please submit a "Ticket" in the console to contact the professional technical support staff.
If you operate on the Windows system instance, please view Windows Data Disk Partition.
Operation Guide
This document takes the scaling up of data disk in CentOS 6.5 x86_64 (64bit) system as an example, and the rest operation modes in Linux system are similar.
Log in to the Instance and View the Status
1.Log in to the BCC instance
You can log in to the BCC instance by various modes, and for the specific log-in mode, you can view "Log in to Instance".
2.View the current partition status and the partition mode
Execute fdisk -l
to view the current partition size. Currently, the data disk/dev/vde has been mounted, and the disk has been scaled up to 100GB from 50GB.
[root@instance-xxxx ~]# fdisk -l
Disk/dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units=sector of 1 * 512 = 512 bytes
Sector size (logic/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk label type: dos
Disk identifier: 0x000b8163
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886046 41941999+ 83 Linux
Disk/dev/vde: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units=sector of 1 * 512 = 512 bytes
Sector size (logic/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk label type: dos
Disk identifier: 0x63ffc036
Device Boot Start End Blocks Id System
/dev/vde1 2048 104857599 52427776 83 Linux
Note:
- If your disk capacity is smaller than 2TB, you can use MBR or GPT mode to complete partition and scale up the file system; if the capacity of your scaled-up disk is greater than 2TB but the existing partition mode is MBR, you should switch the partition mode to GPT. At this time, if you should retain data, we recommend you to create a new disk, adopt the GPT mode to initialize the new disk partition, and then copy the existing data to the new disk.
3.View the file system type
Execute blkid
command to view the type of the current file system. The file system type of the current data disk/dev/vde1 is ext4
.
[root@instance-xxxx ~]# blkid
/dev/vda1: UUID="84953f78-xxxx-4dbd-ac60-aaabc2e4cb9c" TYPE="ext4"
/dev/vde1: UUID="cb664382-xxxx-49f0-874e-d68d8cba0141" TYPE="ext4"
4.View the running status of the file system
If your file system is ext file system, you can execute e2fsck -n/dev/vd*
command for view; if your file system is xfs file system, you can execute xfs_repair -n/dev/vd*
command for view. When the running result displays "clean", it proves that your current file system runs normally; if the status is not "clean", please timely make a check.
[root@instance-xxxx ~]# e2fsck -n /dev/vde1
e2fsck 1.42.9 (28-Dec-2013)
Warning!/dev/vde1 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
/dev/vde1: clean, 11/3276800 files, 251790/13106944 blocks
After completing the steps above, you should confirm the specific operation mode of the current disk. The selection of the operation mode relies on the current status of the data disk and the running status of the mounted file system, and meanwhile depends on the disk partition mode that you want to implement after completing the scaling up of partition. In combination with the three factors above, you can select the corresponding operation mode.
data disk status | file system status | partition mode to be implemented | operation mode |
---|---|---|---|
partitioned | created | When the existing partition mode of the disk is MBR, and you want to scale up the current existing partition capacity, | Scale up the existing MBR disk partition. |
When the existing partition mode of the disk is MBR, and you want to add the region in the current status of "Scaling up" as one independent new MBR disk partition. | Add a new MBR disk partition. | ||
When the existing partition mode of the disk is GPT, and you want to scale up the current existing partition capacity, | Scale up the existing GPT disk partition. | ||
When the existing partition mode of the disk is GPT, and you want to add the region in the current status of "Scaling up" as one independent new GPT disk partition. | Add a new GPT disk partition. | ||
Unpartitioned | Uncreated | If you want to partition the disk and create a file system, | Format the disk. |
Unpartitioned | Created | If you want to directly scale up the file system based on the existing file system, | Scale up the file system of the raw device. |
When your data disk is not partitioned and the file system is not created, for the specific operation mode, please view Format Disk. For the following operation steps of other operation modes, please directly click the corresponding operation name in the right directory for view.
Scale up the Existing MBR Disk Partition
This example scales up the existing partition to 100GB from 50GB.
1.View the mount target of the current file system
Executive the command mount.| grep "/dev/vde"
to view the mount target of the current disk /dev/vde
. Then, you can view the mount target of /mnt
.
[root@instance-xxxx ~]# mount| grep "/dev/vde"
/dev/vde1 on /mnt type ext4 (rw,relatime,data=ordered)
2.Uninstall the current file system
[root@instance-xxxx ~]# umount /dev/vde1
Note:
- If you want to scale up the existing MBR partition, in order to prevent the data loss, please first cancel the mounting partition, and mount the partition again after scaling up.
- If you are using an unpartitioned disk (such as / dev / vde), in order to prevent data loss during capacity expansion, please align the drive letter of the unpartitioned disk (/ dev / vde), and then mount again after the expansion.
3.Resize a partition
Executive the command fdisk/dev/vde
to start resizing the disk partition. After entering the fdisk environment, respectively enter the following commands:
- Enter p: Print the current partition table.
- Enter d: Delete the current partition. When the screen displays "selected partition 1, partition 1 deleted", it indicates that the existing partition of 50GB has been deleted;
- Enter n: Create a partition;
- Enter p: Select the partition type as the main partition;
- Enter the partition number: The current input value is the default value 1, and you can directly press Enter key. The system will directly select the current default value;
- Enter the starting sector position: The current input value is the default value 2048, and you can directly press Enter key. The system will directly select the current default value;
- Enter the Last sector position: You can directly press Enter key, and the system will directly select the current default value;
- Enter w: Save the modification and withdraw. Up to this point, you have resized the partition, and the new partition has been resized to 100GB.
[root@instance-xxxx ~]# fdisk /dev/vde
Welcome to use fdisk (util-linux 2.23.2).
The change will stay in the memory until you decide to write the change to the disk.
Please twice before using the write command.
Command (enter m for help): p
Disk/dev/vde: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units=sector of 1 * 512 = 512 bytes
Sector size (logic/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk label type: dos
Disk identifier: 0x63ffc036
Device Boot Start End Blocks Id System
/dev/vde1 2048 104857599 52427776 83 Linux
Command (enter m for help): d
Selected partition 1
Partition 1 deleted
Command (enter m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
Starting sector (2048-209715199, 2048 by default): 2048
The default value 2048 will be used.
Last sector, + sector or + size or +size{K, M, G} (2048-209715199, 209715199 by default):
The default value 209715199 will be used.
The partition 1 has been set as Linux type, with the size set as 100 GiB.
Command (enter m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
The disk is being synchronized.
4.View the partition and check the file system
Execute the command lsblk/dev/vde
to view whether the partition table has been added to the current file system. You can see that the/vde1 partition table has been added below.
Execute the command e2fsck -n/dev/vde1
to view whether the status of the current file system is clean.
[root@instance-xxxx ~]# lsblk /dev/vde
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vde 253:64 0 100G 0 disk
└─vde1 253:65 0 100G 0 part
[root@instance-xxxx ~]# e2fsck -n /dev/vde1
e2fsck 1.42.9 (28-Dec-2013)
/dev/vde1: clean, 11/3276800 files, 251790/13106944 blocks
5.Notify the core of updating the partition table
Execute the command partprobe/dev/vde
to notify the core of synchronizing the partition table information of the data disk.
6.Scale up the size of the file system
This disk uses the ext file system and can execute the command resize2fs/dev/vde1
to scale up the size of the file system. Then, execute the command mount/dev/vde1/mnt
to mount the new partition to /mnt
node.
[root@instance-xxxx ~]# resize2fs /dev/vde1
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vde1 to 26214144 (4k) blocks.
The filesystem on /dev/vde1 is now 26214144 blocks long.
[root@instance-xxxx ~]# mount /dev/vde1 /mnt
For the xfs file system, you should first run the command mount/dev/vde1/mnt/
to rerun xfs_growfs/dev/vde1
to scale up the file system.
7.View the size of the adjusted partition
At this time, execute the command df -h
to view the size of the adjusted partition. You can see that /dev/vde
partition has been scaled up to 100GB below, and been mounted to /mnt
node.
[root@instance-xxxx~]# df -h
File system Capacity Used Available Used % mount target
/dev/vda1 40G 1.8G 36G 5% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 17M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/vde1 99G 60M 94G 1% /mnt
tmpfs 396M 0 396M 0% /run/user/0
Up to this point, you have completed all operations of scaling up for all the existing MBR disk partitions. You can start to use the disk normally.
Add a New MBR Disk Partition
If you want to add the disk space which is being scaled up as a new MBR disk partition, you can operate according to the following steps. In the operation, you don't need to uninstall the existing file system of the disk, and can directly partition the added new disk space and create a file system.
The following example is under the condition that the existing partition 1 of capacity 100GB and the file system in the disk /dev/vdb
keep unchanged. A new partition 2 is added and the size of new partition 2 is 100GB. A file system is created for the new partition.
1.Resize a partition
Executive the command fdisk/dev/vdb
to start resizing the disk partition. After entering the fdisk environment, respectively enter the following commands:
- Enter p: Print the current partition table.
- Enter n: Create a partition;
- Enter p: Select the partition type as the main partition;
- Enter the partition number: The current input value is default value 2 and it means that a new partition with the number of is created beside the existing partition 1.You can also directly press Enter key, and the system will directly select the current default value;
- Enter the starting sector position: You can directly press Enter key, and the system will directly select the current default value;
- Enter the Last sector position: You can directly press Enter key, and the system will directly select the current default value;
- Enter w: Save the modification and withdraw. Up to this point, you have resized the partition, and the new partition has been resized to 100GB. Meanwhile, the size of the existing partition 1 remains 100GB.
[root@instance-xxxx ~]# fdisk /dev/vdb
Welcome to use fdisk (util-linux 2.23.2).
The change will stay in the memory until you decide to write the change to the disk.
Please twice before using the write command.
Command (enter m for help): p
Disk/dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units=sector of 1 * 512 = 512 bytes
Sector size (logic/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk label type: dos
Disk identifier: 0x63ffc036
Device Boot Start End Blocks Id System
/dev/vdb1 2048 209715199 104856576 83 Linux
Command (enter m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number ( 2-4, default 2):
Starting sector (209715200-419430399, 209715200 by default):
The default value 209715200 will be used.
Last sector, + sector or + size or +size{K, M, G} (209715200-419430399, 419430399 by default):
The default value 419430399 will be used.
The partition 2 has been set as Linux type, with the size set as 100 GiB.
Command (enter m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
The disk is being synchronized.
2.View the partition
Executive the command lsblk/dev/vdb
to view the partition, and you can see that the current new partition dev/vdb2
has been added to the partition table.
[root@instance-xxxx ~]# lsblk /dev/vdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdb 253:16 0 200G 0 disk
├─vdb1 253:17 0 100G 0 part /mnt
└─vdb2 253:18 0 100G 0 part
3.Create and mount a file system for a new partition
Execute the command mkfs.ext4/dev/vdb2to create a file system of
ext4type for the new partition
/dev/vdb2. After creation, you can execute the command
mount/dev/vdb2/xxxto mount the partition to
/xxxnode. In this example, the new partition is mounted to
/mnt` node.
[root@instance-xxxx ~]# mkfs.ext4 /dev/vdb2
mke2fs 1.42.9 (28-Dec-2013)
File system label=
OS type: Linux
Block size=4096 (log=2)
Blocking size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode table: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@instance-xxxx ~]# mount /dev/vdb2 /mnt
4.View the size of the adjusted partition
At this time, execute the command df -h
to view the size of the adjusted partition. You can see /dev/vdb2
below.
The partition has been scaled up to 100GB below, and been mounted to /mnt
node.
[root@instance-xxxx ~]# df -h
File system Capacity Used Available Used % mount target
/dev/vda1 40G 1.8G 36G 5% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 17M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/vdb2 99G 61M 94G 1% /mnt
tmpfs 396M 0 396M 0% /run/user/0
Up to this point, you have completed all operations of scaling up for adding the MBR disk partitions. You can start to use the disk normally.
Scale up the Existing GPT Disk Partition
When you have scaled up the disk in the console, execute the command fdisk -l
to display that the capacity of the current disk is the scaled-up capacity. In this example, the /dev/vdb
disk which has used the GPT partition mode is scaled up. Before the following partition operation, the capacity of the disk is scaled up to 2500GB from 2000GB.
1.View the mount target of the current file system
Executive the command mount.| grep "/dev/vdb"
to view the mount target of the current disk /dev/vdb
. Then, you can view the mount target of /mnt
.
[root@instance-xxxx ~]# mount| grep "/dev/vdb"
/dev/vdb on /mnt type ext4 (rw,relatime,data=ordered)
2.Uninstall the current file system
[root@instance-xxxx ~]# umount /dev/vdb
Note:
- If you want to scale up the existing GPT partition, in order to prevent the data loss, please first cancel the mounting partition, and mount the partition again after scaling up.
3.Resize a partition
You should use parted tool for operation of scaling up partition for /dev/vdb
disk, and enter the following commands respectively:
- Execute the command
parted/dev/vdb
to start scaling up the partition; - Execute the command
print
to view the partition number (Number) and capacity (Size) to be scaled up. In this example, the disk/dev/vdb/is scaled up to 2500GB from 2000GB, and the existing partition number is 1; - Execute the command
resizepart 1 100%
to scale up the partition. You can change the partition number in the command statement according to your own requirements; - Execute
print
to view the current partition number and capacity status.
[root@instance-xxxx ~]# parted /dev/vdb
GNU Parted 3.1
Use/dev/vdb.
Welcome to GNU Parted!Type 'help' to view a list of commands.
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2684GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flag
1 0.00B 2684GB 2684GB ext4
(parted) resizepart 1 100%
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 2684GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flag
1 0.00B 2684GB 2684GB ext4
(parted) quit
Information: You may need to update/etc/fstab.
4.Mount the file system
- Execute the command
fsck -f/dev/vdb1
to check whether the file system is consistent; - If your file system is the
ext
type, please first execute the commandresize2fs/dev/vdb1
to scale up the file system corresponding to the parties. Then, executemount/dev/vdb1/mnt
to mount the file system to the mount target. You can also mount the file system to other mount targets, or create a new mount target bymkdir<mount target>
; - If your file system is the
xfs
type, please first execute the commandmount/dev/vdb1/mnt/
, and then execute the commandxfs_growfs/dev/vdb1
.
In the following example, the ext
file system type is used.
[root@instance-xxxx ~]# fsck -f /dev/vdb1
fsck, coming from util-linux 2.23.2.
e2fsck 1.42.9 (28-Dec-2013)
Step 1: Check inode, block and size.
Step 2: Check the directory structure.
Step 3: Check the directory connectivity.
Pass 4: Checking reference counts
Step 5: Check the summary information of cluster.
/dev/vdb1: 11/131072000 files (0.0% non-contiguous), 8282274/524288000 blocks
[root@instance-xxxx ~]# resize2fs /dev/vdb1
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vdb1 to 655360000 (4k) blocks.
The filesystem on /dev/vdb1 is now 655360000 blocks long.
[root@instance-hnl92ipp ~]# mount /dev/vdb1 /mnt
5.View the adjusted partition
After completing the steps above, you can execute the command df -h
to view the adjusted partition.
Add a New GPT Disk Partition
If you want to add the disk space which is being scaled up as a new GPT disk partition, you can operate according to the following steps. In the operation, you don't need to uninstall the existing file system of the disk, and can directly partition the added new disk space and create a file system.
The following example is under the condition that the existing partition 1 of capacity 2500GB and the file system in the /dev/vdb1
keep unchanged. A new partition 2 is added and the size of new partition 2 is 500GB. A file system of ext
type is created for the new partition.
1.Resize a partition
You should use parted tool to add a new partition for the disk, and please execute parted/dev/vdb
for operation. Please respectively execute the following commands for partition operation:
- Execute the command
print
to view the current status of the data disk. At this time, the system will pop up one prompt and enter Ignore to ignore the prompt. At this time, you can see that the capacity of the current disk has been scaled up to 3000 GB; - Record the end position of
/dev/vdb1
at this time, namely, the corresponding disk position of End. This position is the starting position of the new partition. In this example, the end position of/dev/vdb1
is 2147GB; - Enter
mkpart
to start creating a partition. If the prompt continues to appear, please continue to ignore it; - Enter a new partition name: In this example, enter 2;
- Enter the file system type of the new partition: In this example, enter
ext4
, and the system defaults toext2
; - Enter the starting position of the new partition: It is 2147GB in this example;
- Execute print` to view the current disk status;
- Execute
quit
to exit the parted partition tool.
[root@instance-xxxx ~]# parted /dev/vdb
GNU Parted 3.1
Use/dev/vdb.
Welcome to GNU Parted!Type 'help' to view a list of commands.
(parted) print
Warning: Not all of the space available to/dev/vdb appears to be used, you can fix the GPT to use all of the space (an extra 2097152000 blocks) or continue with the current setting?
Modify/Fix/Ignore/Ignore? Ignore
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Mark
1 1049kB 2147GB 2147GB ext4 primary
(parted) mkpart
Partition name? []?2
File system type? [ext2]?ext4
Starting point? 2147GB
End point? 100%
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 3221GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Mark
1 1049kB 2147GB 2147GB ext4 primary
2 2147GB 3221GB 1074kB 2
(parted) quit
2.Mount a file system for a new partition
You can execute the command mount/dev/vdb2/xxx
to mount the partition to /xxx
node. In this example, the new partition is mounted to /mnt
node.
[root@instance-xxxx ~]# mount /dev/vdb2 /mnt
3.View the size of the adjusted partition
At this time, execute the command df -h
to view the size of the adjusted partition.
Up to this point, you have completed all operations of scaling up for adding the GPT disk partitions. You can start to use the disk normally.
Scale up the File System of the Raw Device
If your data disk is not partitioned but a file system has been created, you can directly scale up the file system in this disk.
1.If you have created the ext file system
Please use the root permission to execute the command resize2fs
to scale up the file system.
resize2fs /dev/vdb
2.If you have created the xfs file system
Use the root permission to execute the command xfs_growfs
to scale up the file system.
xfs_growfs /dev/vdb