There's nothing to fix, and this is perfectly normal.
ext4 creates a lot of overhead before any files are created. It does not mean it is "worse" than ext3. If you fill that partition with files, you will notice that ext3's (and NTFS's) overhead will grow proportionally with the files, as with ext4 it will basically remain constant forever.
By "pre-allocating" the overhead, it can manage it much better than a growing one. So ext4 is just doing now what ext3 would do later.
Besides, 27G may look a lot, but it's still a mere 1.5% overhead. Compare that to the old days of FAT, where slack space could eat anything from 5% to 30% of your partition space, and you'll notice how greatly things have evolved since then.
Also, I strongly recommend against using -m 0
. Reserved space is there for a reason: it lowers the fragmentation chances and saves some space for fsck
. It is reserved only from users, but root (and thus all your software installs) can fully use it. If you think 5% is excessive, leave at least 1% .
Remember: there's no fragmentation nightmares in ext
. But this beauty comes at a price. It needs free space as room for proper management. Give it to him and things will run much smoother. Besides, who ever uses their HDD beyond 90% before buying a larger one? So what's the problem about a 5% reserved space? It may save you the next time you accidentally create a dozen-GB file that fills up the whole partition and end up crashing the OS due to lack of space for other processes.
For a more detailed, further technical reading, read here
Maybe you're doing the things in the wrong order. When you create a file system with mkfs.ext4
, everything inside it is owned by user root and group root with your system default permissions set.
When you mount that file system on a directory, you see file system permissions and owner, regardless of the original owner and permissions on that directory.
So doing something like this won't work:
sudo mkfs.ext4 /dev/some/data
sudo mkdir /media/data
sudo chown -R :users /media/data
sudo chmod -R g+rw /media/data
sudo mount /dev/some/data /media/data
The right thing to do is create the file system, mount it, and then change permissions and ownership on it. It doesn't matter what you do in /etc/fstab.
The right way to do it is this:
sudo mkfs.ext4 /dev/some/data
sudo mkdir /media/data
sudo mount /dev/some/data /media/data
sudo chown -R :users /media/data
sudo chmod -R g+rw /media/data
This should answer your question. If you need more details, read on.
To better understand what happens, let's experiment a little with an image file
Create an empty file to format and mount using fallocate -l 100MB /tmp/filesystem.img
. Then format it as an ext4 file system with sudo mkfs.ext4 /tmp/filesystem.img
(it's not a block device, but if you answer yes you can put a working ext4 file system on it anyway) and create a directory to use as mount point mkdir /tmp/experiment
.
Now try to change the owner and permissions on that directoy with sudo chown -R :users /tmp/experiment
and sudo chmod -R g+rw /tmp/experiment
, and check permissions with ls -la /tmp/experiment
. You'll get something like this:
ls -la /tmp/experiment/
total 0
drwxrwx--x 2 gerlos users 40 feb 19 10:37 .
drwxrwxrwt 8 root root 180 feb 19 10:38 ..
This tells you that /tmp/experiment is owned by user gerlos and group users, and group members can read, write and execute on it. You can put files in it, for example with touch /tmp/experiment/somefile
.
Now mount the file system on that directory with sudo mount /mnt/filesystem.img /tmp/experiment
, and look again at ls
output:
$ ls -la /tmp/experiment/
total 13
drwxr-xr-x 3 root root 1024 feb 19 10:41 .
drwxrwxrwt 8 root root 180 feb 19 10:41 ..
drwx------ 2 root root 12288 feb 19 10:41 lost+found
As you can see, now /tmp/experiment seems owned by root, with different permissions! Why? Because we are not looking at /tmp/experiment itself, but at the root directory of the file system contained in /mnt/filesystem.img, mounted on /mnt/experiment.
Additionally, your normal user won't be able to put files there with touch /tmp/experiment/anotherfile
.
If you now try again to run chown
and chmod
as above, you will change owner and permissions not on the mount point, but on the mounted file system, and your users will be able to use the file system. To confirm this look at ls output one last time:
$ ls -la /tmp/experiment/
total 13
drwxrwxr-x 3 root users 1024 feb 19 10:41 .
drwxrwxrwt 8 root root 180 feb 19 10:45 ..
drwxrw---- 2 root users 12288 feb 19 10:41 lost+found
As you can see, now members of users group can put files on the file system! In fact, nothing prevents your normal user from creating a new file there with touch /tmp/experiment/myfile
:
$ ls -la /tmp/experiment/
total 13
drwxrwxr-x 3 root users 1024 feb 19 11:05 .
drwxrwxrwt 8 root root 180 feb 19 11:02 ..
drwxrw---- 2 root users 12288 feb 19 10:41 lost+found
-rw-rw---- 1 gerlos gerlos 0 feb 19 11:02 myfile
Mission accomplished! :-)
Best Answer
First and foremost:
!! WARNING !!
These commands are EXAMPLES. DELETING partitions, MODIFYING and FORMATTING filesystems destroys data and/or may prevent your machine from booting. Make backups. Use at own risk. Try on a machine you don't mind losing all data on. caveat admin.
To quickly set up a drive up as a single ext4 partition...
View detected devices of class "DISK"
View existing partition table(s)
Edit the partition table for my chosen device (in this case, "sdx")
Within FDISK, press:
d
...to delete the current partitionn
...to create a new partitionp
...to specify it as a PRIMARY partition1
...to set it as the 1ST primary partitionw
...to write the changes.Display the new partition table:
Format the new partition's filesystem as type
ext4
Create a new directory where the new drive will mount into:
TUNING
Remove reserved blocks (i.e. set to 0%), since this drive is just for user data
Since server is on UPS, Set write-back so apps don't wait for actual disk writes
Mount at boot up using
/etc/fstab
and also set write-back policyFind (or add) the relevant line in
fstab
for your drive. Parameters in fstab are separated by white space, for example the drive described above might appear as:dump
schedule for backups; and,fsck
order).Change the options (4th parameter) to:
Reboot to check that everything went well.
Remember these commands are destructive! Have backups and be careful!