I have an vmware ext4 file system that non-lvm, non-partitioned file system that resides on a virtual 300GB disk. In other words, there is no partition and the file system was probably created by:mkfs.ext4 /dev/sdd1The disk is barely used (1%) but I would like to keep the data on it. Is there a safe way to shrink it? I was thinking of resizing the disk in Vmware from 300 to 100 and running resize2fs /dev/sdd1 but am not certain if I will not lose anything on it.Any pieces of advice would be highly appreciated.P.
Shrink/reduce non-lvm disk file system
linux;partition;resize2fs
Your question is inconsistent: if there's a partition, the filesystem was created by a command like mkfs.ext4 /dev/sdd1. If there's no partition, the filesystem was created by a command line mkfs.ext4 /dev/sdd. Check the output of df /path/to/some/directory/on/that/filesystem to see which one it is.Either way, you can call resize2fs to shrink the filesystem. This is independent of any use of LVM. You can only shrink the filesystem while it's unmounted, so if it's your root filesystem, you need to do that from a rescue system. Note that the disk letter might be different in the rescue system, e.g. sdb instead of sdd.After shrinking the filesystem to the desired size, if it's on a partition, you need to shrink the partition. You can use fdisk for that, but it's a bit delicate: you need to delete and recreate the partition, making sure that you don't change its start location. You can also use parted, which combines filesystem resizing and partition resizing, but it's also cumbersome to use because you need to compute the target start address.After this, you can shrink the size of the disk image in VMware. Make sure that the filesystem (and partition, if applicable) fit inside the disk image; if there's a partition, remember that the partition table uses an extra 512B at the beginning.