windows系统请参考:http://blog.iis7.com/"margin-top: 0px; margin-bottom: 0px; padding: 0px; line-height: 25px; color: rgb(43, 43, 43); font-size: 14px; font-family: "Microsoft Yahei", "Hiragino Sans GB", "Helvetica Neue", Helvetica, tahoma, arial, Verdana, sans-serif, "WenQuanYi Micro Hei", 宋体; white-space: normal; background-color: rgb(255, 255, 255);">windows数据盘扩容请参考:http://blog.iis7.com/"margin-top: 0px; margin-bottom: 0px; padding: 0px; line-height: 25px; color: rgb(43, 43, 43); font-size: 14px; font-family: "Microsoft Yahei", "Hiragino Sans GB", "Helvetica Neue", Helvetica, tahoma, arial, Verdana, sans-serif, "WenQuanYi Micro Hei", 宋体; white-space: normal; background-color: rgb(255, 255, 255);">linux数据盘扩容请参考:http://blog.iis7.com/"margin-top: 0px; margin-bottom: 0px; padding: 0px; line-height: 25px; color: rgb(43, 43, 43); font-size: 14px; font-family: "Microsoft Yahei", "Hiragino Sans GB", "Helvetica Neue", Helvetica, tahoma, arial, Verdana, sans-serif, "WenQuanYi Micro Hei", 宋体; white-space: normal; background-color: rgb(255, 255, 255);">
警告:
1.调整过分区管理方式的,例如lvm管理方式,请忽略此教程。
2.ubuntu20系统暂不支持脚本扩容,请手动扩容,参看下面ubuntu20部分,用fdisk操作
脚本自动处理(推荐)
SSH登录服务器下载自动执行脚本 :
wget -O auto_expansion.sh http://downinfo.myhostadmin.net/vps/auto_expansion.sh && bash auto_expansion.sh && rm -rf auto_expansion.sh
手工处理方法
红色为您要键入的指令,绿色为需要注意的内容,蓝色为说明
特别提醒:删除分区后一定要先建立分区再保存,删除后点了保存会导致数据丢失,如果对linux不熟悉的,建议提交维护工单我司手工处理,费用100元。该操作有风险,为避免误操作导致数据丢失,操作前请对您的重要数据进行备份!
以下操作仅适用于centos6.x ,若是是使用的centos7.x版本请使用fdisk工具完成,操作流程一致。
Centos:
[root@ebs ~]#yum -y install gdisk //安装分区工具
[root@ebs ~]#gdisk /dev/vda //操作根分区磁盘
Command (? for help): p //查看分区
Disk /dev/vda: 104857600 sectors, 50.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): B7172F0B-2C30-4535-981D-F0ED8B4A6065
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 104857566
Partitions will be aligned on 2048-sector boundaries
Total free space is 41945021 sectors (20.0 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 62914559 30.0 GiB 8300 Linux filesystem //注意这个值
Command (? for help): d //删除分区
Using 1
Command (? for help): 1
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-104857566, default = 2048) or {+-}size{KMGTP}: 2048 //刚才记录的
Last sector (2048-104857566, default = 104857566) or {+-}size{KMGTP}: //直接回车
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): //直接回车
Changed type of partition to 'Linux filesystem'
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/vda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.
[root@ebs ~]#reboot //重启让分区生效
[root@ebs ~]#resize2fs -f /dev/vda1 //开始扩容根分区,如果是centos8.x系统需要使用这个命令:xfs_growfs /dev/vda1
resize2fs -f /dev/vda1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 4
Performing an on-line resize of /dev/vda1 to 13106939 (4k) blocks.
The filesystem on /dev/vda1 is now 13106939 blocks long.
[root@ebs ~]#df -vh //完成,查看新的根分区大小
Ubuntu:
root@ebs-888:~# parted /dev/vda
(parted) unit b
(parted) print
Model: Virtio 块设备 (virtblk)
磁盘 /dev/vda: 107374182400B
Sector size (logical/physical): 512B/512B
分区表:msdos
数字 开始: End 大小 类型 文件系统 标志
1 1048576B 32211206143B 32210157568B primary ext4 启动
(parted) rm 1 //删除1分区,记1的开始 删除2分区,记2分区的开始
警告: Partition /dev/vda1 is being used. Are you sure you want to continue?
是/Yes/否/No? yes
错误: Partition(s) 1 on /dev/vda have been written, but we have been unable to inform the kernel of the change,
probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot
now before making further changes.
忽略/Ignore/放弃/Cancel? I
(parted) mkpart
分区类型? primary/主分区/extended/扩展分区? p
文件系统类型? [ext2]?
起始点? 1048576B //删除1分区,记1的开始 删除2分区,记2分区的开始
结束点? 100%
(parted) print
Model: Virtio 块设备 (virtblk)
磁盘 /dev/vda: 107374182400B
Sector size (logical/physical): 512B/512B
分区表:msdos
数字 开始: End 大小 类型 文件系统 标志
1 1048576B 107374182399B 107373133824B primary ext4
(parted) quit
信息: You may need to update /etc/fstab.
root@ebs-888:~# reboot
重启完,重新登陆服务器
root@ebs-888:~# resize2fs -f /dev/vda1
root@ebs-888:~# df -vh
ubuntu20(系统盘存在两个分区vda1,vda2):
root@ebs-888:~# fdisk /dev/vda
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Command (m for help): p
Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 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: gpt
Disk identifier: D9024514-1844-4FE3-9E82-CBF236D8C09C
Device Start End Sectors Size Type
/dev/vda1 2048 4095 2048 1M BIOS boot
/dev/vda2 4096 62914526 62910431 30G Linux filesystem
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
Command (m for help): n
Partition number (2-128, default 2): 2
First sector (4096-83886046, default 4096): 4096
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4096-83886046, default 83886046): 83886046
Created a new partition 2 of type 'Linux filesystem' and of size 40 GiB.
Partition #2 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.
Syncing disks.
root@ebs-888:~# reboot
重启完,重新登陆服务器
root@ebs-888:~# resize2fs -f /dev/vda2
root@ebs-888:~# df -vh
debian:
root@ebs-888:~# apt-get -y install parted
root@ebs-888:~# parted /dev/vda
GNU Parted 3.2
Using /dev/vda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 26GB 26GBGB primary ext4
2 26GB 30GB 4GB primary ext4
5 30GB 34GB 4GB primary ext4
(parted) rm 5
警告: Partition /dev/vda1 is being used. Are you sure you want to continue?
是/Yes/否/No? yes
错误: Partition(s) 1 on /dev/vda have been written, but we have been unable to inform the kernel of the change,
probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot
now before making further changes.
忽略/Ignore/放弃/Cancel? I
(parted) rm 2
警告: Partition /dev/vda1 is being used. Are you sure you want to continue?
是/Yes/否/No? yes
错误: Partition(s) 1 on /dev/vda have been written, but we have been unable to inform the kernel of the change,
probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot
now before making further changes.
忽略/Ignore/放弃/Cancel? I
(parted) rm 1
警告: Partition /dev/vda1 is being used. Are you sure you want to continue?
是/Yes/否/No? yes
错误: Partition(s) 1 on /dev/vda have been written, but we have been unable to inform the kernel of the change,
probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot
now before making further changes.
忽略/Ignore/放弃/Cancel? I
(parted) mkpart
分区类型? primary/主分区/extended/扩展分区? p
文件系统类型? [ext2]?
起始点? 1049kB
结束点? 100%
(parted) print
Model: Virtio 块设备 (virtblk)
磁盘 /dev/vda: 107374182400B
Sector size (logical/physical): 512B/512B
分区表:msdos
数字 开始: End 大小 类型 文件系统 标志
1 1049kB 42.9GB 42.9GB primary ext4
(parted) quit
信息: You may need to update /etc/fstab.
root@ebs-888:~# reboot
重启完,重新登陆服务器
root@ebs-888:~# resize2fs -f /dev/vda1
root@ebs-888:~# df -vh
上一篇:go语言如何删除切片
下一篇:没有了