文件服务器虚拟机扩展磁盘容量,vmware虚拟机扩容磁盘空间

主要步骤:

vmware宿主机编辑虚拟机配置扩容服务器磁盘并启动虚拟机

fdisk新建分区

pvcreate新建物理卷

vgextend扩展卷组

lvextend扩容逻辑卷

xfs_growfs扩容文件系统

1.fdisk新建分区

[root@6_90 ~]# fdisk /dev/sda

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): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 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

Disk label type: dos

Disk identifier: 0x0007b2cf

Device Boot Start End Blocks Id System

/dev/sda1 * 2048 1026047 512000 83 Linux

/dev/sda2 1026048 419430399 209202176 8e Linux LVM

Command (m for help): n

Partition type:

p primary (2 primary, 0 extended, 2 free)

e extended

Select (default p): p

Partition number (3,4, default 3):

First sector (419430400-838860799, default 419430400):

Using default value 419430400

Last sector, +sectors or +size{K,M,G} (419430400-838860799, default 838860799):

Using default value 838860799

Partition 3 of type Linux and of size 200 GiB is set

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 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

Disk label type: dos

Disk identifier: 0x0007b2cf

Device Boot Start End Blocks Id System

/dev/sda1 * 2048 1026047 512000 83 Linux

/dev/sda2 1026048 419430399 209202176 8e Linux LVM

/dev/sda3 419430400 838860799 209715200 83 Linux

Command (m for help): t

Partition number (1-3, default 3): 3

Hex code (type L to list all codes): 8e

Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 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

Disk label type: dos

Disk identifier: 0x0007b2cf

Device Boot Start End Blocks Id System

/dev/sda1 * 2048 1026047 512000 83 Linux

/dev/sda2 1026048 419430399 209202176 8e Linux LVM

/dev/sda3 419430400 838860799 209715200 8e Linux LVM

Command (m for help): w

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@6_90 ~]# partprobe

[root@6_90 ~]# fdisk -l

Disk /dev/sda: 429.5 GB, 429496729600 bytes, 838860800 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

Disk label type: dos

Disk identifier: 0x0007b2cf

Device Boot Start End Blocks Id System

/dev/sda1 * 2048 1026047 512000 83 Linux

/dev/sda2 1026048 419430399 209202176 8e Linux LVM

/dev/sda3 419430400 838860799 209715200 8e Linux LVM

Disk /dev/mapper/centos-root: 193.2 GB, 193248362496 bytes, 377438208 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

Disk /dev/mapper/centos-swap: 21.0 GB, 20971520000 bytes, 40960000 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

[root@6_90 ~]# pvscan

PV /dev/sda2 VG centos lvm2 [199.51 GiB / 0 free]

Total: 1 [199.51 GiB] / in use: 1 [199.51 GiB] / in no VG: 0 [0 ]

[root@6_90 ~]# pvdisplay

--- Physical volume ---

PV Name /dev/sda2

VG Name centos

PV Size 199.51 GiB / not usable 3.00 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 51074

Free PE 0

Allocated PE 51074

PV UUID U7l4WJ-kwxY-DgvQ-eZX3-F3YG-71GI-O54rin

2.pvcreate新建物理卷

[root@6_90 ~]# pvcreate /dev/sda3

Physical volume "/dev/sda3" successfully created

3.vgextend扩展卷组

[root@6_90 ~]# vgscan

Reading all physical volumes. This may take a while...

Found volume group "centos" using metadata type lvm2

[root@6_90 ~]# vgextend centos /dev/sda3

Volume group "centos" successfully extended

4.lvextend扩容逻辑卷

[root@6_90 ~]# lvscan

ACTIVE '/dev/centos/swap' [19.53 GiB] inherit

ACTIVE '/dev/centos/root' [179.98 GiB] inherit

[root@6_90 ~]# ls /dev/mapper/centos-root

/dev/mapper/centos-root

[root@6_90 ~]# lvextend -l +100%FREE /dev/mapper/centos-root

Size of logical volume centos/root changed from 179.98 GiB (46074 extents) to 379.97 GiB (97273 extents).

Logical volume root successfully resized.

5.xfs_growfs扩容文件系统

[root@6_90 ~]# df -hT

Filesystem Type Size Used Avail Use% Mounted on

/dev/mapper/centos-root xfs 180G 3.7G 177G 3% /

devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev

tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm

tmpfs tmpfs 3.9G 281M 3.6G 8% /run

tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup

/dev/sda1 xfs 497M 126M 371M 26% /boot

tmpfs tmpfs 783M 0 783M 0% /run/user/1000

[root@6_90 ~]# xfs_growfs /dev/mapper/centos-root

meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=11794944 blks

= sectsz=512 attr=2, projid32bit=1

= crc=0 finobt=0

data = bsize=4096 blocks=47179776, imaxpct=25

= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0 ftype=0

log =internal bsize=4096 blocks=23037, version=2

= sectsz=512 sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

data blocks changed from 47179776 to 99607552

[root@6_90 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/centos-root 380G 3.7G 377G 1% /

devtmpfs 3.9G 0 3.9G 0% /dev

tmpfs 3.9G 0 3.9G 0% /dev/shm

tmpfs 3.9G 281M 3.6G 8% /run

tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup

/dev/sda1 497M 126M 371M 26% /boot

tmpfs 783M 0 783M 0% /run/user/1000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 在Ubuntu 18.04服务器上,要扩展虚拟机磁盘容量,可以按照以下步骤进行: 1. 首先,在虚拟机的管理界面中,将虚拟机关机。 2. 然后,找到虚拟机磁盘文件(通常是以.vmdk、.vdi或.qcow2为后缀),并复制一份备份。 3. 使用虚拟化管理工具或命令行工具(例如`qemu-img`)对备份文件进行扩展,命令如下: ``` qemu-img resize <disk_file> +<additional_size> ``` 其中,`<disk_file>`是磁盘文件的路径,`<additional_size>`是要增加的额外空间大小,以字节为单位。 4. 打开虚拟机的管理界面,找到虚拟机的设置。 5. 在设置中,选择磁盘选项,并添加一个新的磁盘。 6. 在新添加的磁盘中,选择使用现有的磁盘文件,选择步骤2中扩展过的备份文件。 7. 完成以上设置后,启动虚拟机。在虚拟机内部,可以看到新增的磁盘。 8. 使用命令行工具(例如`fdisk`)对新增的磁盘进行分区和格式化。先使用命令`fdisk -l`查看磁盘设备名(如`/dev/sdb`),然后运行以下命令: ``` fdisk /dev/sdb n p <enter> <enter> w ``` 9. 格式化新增的磁盘,例如使用以下命令: ``` mkfs.ext4 /dev/sdb1 ``` 10. 创建一个新的挂载点目录,例如`/mnt/new_disk`: ``` mkdir /mnt/new_disk ``` 11. 将新增的磁盘挂载到新的目录,例如使用以下命令: ``` mount /dev/sdb1 /mnt/new_disk ``` 12. 可以通过修改`/etc/fstab`文件来设置开机自动挂载。在文件中添加以下一行: ``` /dev/sdb1 /mnt/new_disk ext4 defaults 0 0 ``` 至此,你已经成功在Ubuntu 18.04服务器虚拟机扩展磁盘容量。你可以使用`df -h`命令来查看新增的磁盘空间。 ### 回答2: 要在Ubuntu 18.04服务器虚拟机扩展磁盘容量,你可以按照以下步骤进行操作: 1. 首先,确认你的虚拟机磁盘的当前容量情况。你可以使用命令 `lsblk` 来查看已安装的磁盘和其当前容量。 2. 关闭虚拟机。在对磁盘进行扩展之前,确保虚拟机处于关闭状态。 3. 打开虚拟机虚拟化软件,如VirtualBox或VMware,并选择扩展虚拟磁盘容量的选项。在这一步中,你需要为虚拟磁盘分配更多的空间。具体的步骤和界面可能因软件版本而异,但通常都能在虚拟机设置中找到。 4. 打开虚拟机并登录到Ubuntu系统。请注意,磁盘扩展只是增加了虚拟磁盘的大小,并不会自动将其反映到操作系统中。 5. 使用命令 `sudo fdisk -l` 查看虚拟磁盘的分区情况。确认新分配的磁盘空间已在显示中。 6. 运行命令 `sudo parted /dev/sda`(如果你的磁盘设备是 "/dev/sda")。这将打开磁盘分区工具。 7. 在 parted 命令行中,输入 `resizepart 分区号 新大小`,将“分区号”替换为你的虚拟磁盘分区号,而“新大小”是你想要分配给分区的新容量大小。如果你只有一个分区,则将其设置为1。例如,`resizepart 1`。 8. 确认指定的新分区大小。重新启动虚拟机。 9. 使用命令 `sudo resize2fs /dev/sda1`(如果你的分区号是1)。这将调整文件系统以适应新的分区大小。 10. 使用命令 `df -h` 查看文件系统的新容量。你应该能够看到磁盘容量扩展的变化。 通过这些步骤,你可以在Ubuntu 18.04服务器虚拟机上成功扩展磁盘容量。 ### 回答3: 要在Ubuntu 18.04服务器虚拟机扩展磁盘容量,以下是步骤: 1. 首先,在虚拟化平台(如VMware、VirtualBox)中停止该虚拟机。 2. 在虚拟机管理界面,调整虚拟机磁盘大小。这可以通过编辑虚拟机设置来完成。 3. 重新启动虚拟机,并登录到Ubuntu 18.04服务器。 4. 运行命令sudo parted -l获取当前磁盘和分区的信息。找到需要扩展的分区的名称,通常是/dev/sdX(X是分区字母)。 5. 运行命令sudo fdisk /dev/sdX(将X替换为相应的分区字母)进入磁盘分区调整界面。 6. 在命令提示符下,按下d键删除需要扩展的分区。 7. 按下n键创建一个新的分区。 8. 设置新分区的大小,可以选择使用默认值,即直接按回车键,或者输入自定义的大小(以M或G为单位)。 9. 按下w键保存并退出fdisk。 10. 运行命令sudo partprobe来重新读取分区表。 11. 运行命令sudo resize2fs /dev/sdX(将X替换为相应的分区字母)来调整文件系统大小。 12. 等待调整过程完成,可以通过运行df -h命令来验证磁盘容量是否扩展成功。 以上步骤将帮助您在Ubuntu 18.04服务器虚拟机扩展磁盘容量。请记得在进行这些操作之前备份重要数据,并小心操作以避免意外损失。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值