extend disk space in VMWare with no Volume groups
If you want to make /dev/sda3 bigger, you have to delete or move /dev/sda4. The point that Mattias doesn't explicitly call out is his guide doesn't help you when your disk isn't already using LVM. You can't easily extend /dev/sda3 without risking destroying data. It can be done, but it is a bit more advanced.
Are you using /dev/sda4 at all? It appears to be an unused 30GB partition that you may have created and marked as LVM, but haven't configured yet.
The simplest way to make more space is to initialize LVM on /dev/sda4.
How to setup LVM on the unused partition
Warning: Make sure /dev/sda4 doesn't have any data you want to keep. These steps are destructive.
volgr0 is the arbitrary name I am using for the Volume Group.
logvol0 is the arbitrary name I am using for the Logical Volume.
- Initialize /dev/sda4 as a Physical Volume
pvcreate /dev/sda4
- Create the Volume Group and allocate the PV from step 1 to it
vgcreate volgr0 /dev/sda4
- Create a logical volume on your new Volume Group
lvcreate -L +20G -n logvol0 volgr0
- Initialize (format) the logical volume
mkfs.xfs /dev/volgr0/logvol0
You now have a 10GB logical volume that can be used just like a regular disk partition (e.g. /dev/hda3, /dev/vda2, etc.) It's device mapper path is probably /dev/mapper/volgr0-logvol0 or you can use the symlinks /dev/volgr0/lgvol0 (depends on your exact OS and configuration, but this is pretty typical for Fedora/Cent/RHEL/SciLinux)
Now it's just a matter of mounting a folder in the current filesystem on this volume and using it, e.g. mount /dev/volgr0/logvol0 /opt
. This would mount the /opt directory onto your lvol0.
How to extend the size of a regular partition
Warning: Make sure /dev/sda4 doesn't have any data you want to keep. These steps are destructive. It's a good idea to have a backup of the whole .vmdk in fact.
- Reboot your VM using a Live OS image. I prefer System Rescue CD myself for this sort of thing, but there are plenty of other good options.
- Using fdisk, delete /dev/sda3 and /dev/sda4
- Using fdisk, create a new partition #3 (it will be /dev/sda3) using all of the available disk space (accept the defaults fdisk offers)
- Reboot your VM with the local OS
- Resize your /dev/sda3 filesystem
xfs_growfs /dev/sda3
(Mattias blogged about this)
Voila!
Yes, deleting a partition with fdisk from the rescue image is scary...but in this case, all you are doing is deleting the entries in the partition table itself, not the actual partitions.
So, at the end of it all is a lesson I like to repeat often: when in doubt, go ahead and use LVM.
Related videos on Youtube
flashburn
Updated on September 18, 2022Comments
-
flashburn over 1 year
I have CentOS7 installed as guest in VMWare Fusion. Need to increase the size of my disk. Following this guide. Got to step 3) Extend your Logical Volume with the new partition and created a physical volume. However my
sudo vgdisplay
shows the following:[sudo] password for user:
i.e bupkis. Looks like I don't have any volume groups.
I tried doing
sudo vgcreate vg1 /dev/sda3 /dev/sda4
but I got the following result:[sudo] password for user: Can't open /dev/sda3 exclusively. Mounted filesystem?
I'm not very savvy in this area. Does anyone know how do I proceed? Would appreciate any help.
Here is the output of
fdisk -l
Device Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 83 Linux /dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris /dev/sda3 4810752 41943039 18566144 83 Linux /dev/sda4 41943040 104857599 31457280 8e Linux LVM
Output of
file -sL
for each partition[user@localhost ~]$ sudo file -sL /dev/sda1 /dev/sda1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs) [user@localhost ~]$ sudo file -sL /dev/sda2 /dev/sda2: Linux/i386 swap file (new style), version 1 (4K pages), size 524287 pages, no label, UUID=<blacked-out> [user@localhost ~]$ sudo file -sL /dev/sda3 /dev/sda3: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs) [user@localhost ~]$ sudo file -sL /dev/sda4 /dev/sda4: LVM2 PV (Linux Logical Volume Manager), UUID: <blacked-out>, size: 32212254720
EDIT
Output of
df -hTP | grep -v tmpfs
Filesystem Type Size Used Avail Use% Mounted on /dev/sda3 xfs 18G 18G 257M 99% / /dev/sda1 xfs 297M 204M 94M 69% /boot .host:/ vmhgfs 233G 167G 66G 72% /mnt/hgfs
Output of
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 50G 0 disk ├─sda1 8:1 0 300M 0 part /boot ├─sda2 8:2 0 2G 0 part [SWAP] ├─sda3 8:3 0 17.7G 0 part / └─sda4 8:4 0 30G 0 part sr0 11:0 1 1024M 0 rom
-
Jeff Schaller about 7 yearsdid you enter the user's password?
-
Alxs about 7 years/dev/sda3 is a mounted Linux filesystem. You can't change its type to LVM without destroying the data on it. Is that what you're trying to do?
-
0xSheepdog about 7 yearsPlease provide the output from the following two commands:
df -hTP | grep -v tmpfs
andlsblk
-
Nils about 7 yearsDo want to extend sda3? No need for an additional partition or LVM in that case.
-
flashburn about 7 years@Nils How do I extend it then without additional partition?
-
flashburn about 7 years@Alxs I'm trying to extend /dev/sda3.
-
flashburn about 7 years@0xSheepdog command output is provided at the end of the post.
-
0xSheepdog about 7 yearsI will update answer with how to move files to decrease use in /dev/sda3 if you know where all your space is being eaten up (music files, ISOs, videos, etc.)
-
Nils about 7 yearsI added an answer.
-