Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mke2fs v mkfs.ext2
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
vcg3rd
n00b
n00b


Joined: 21 Jan 2015
Posts: 3

PostPosted: Wed Jan 21, 2015 4:48 pm    Post subject: mke2fs v mkfs.ext2 Reply with quote

Apologies if this is covered. I searched the forums for mke2fs and saw no obvious candidates for an answer. This section of the handbook is unclear to me.

Quote:
When using ext2, ext3 or ext4 on a small partition (less than 8GB), then the file system must be created with the proper options to reserve enough inodes. The mke2fs application uses the "bytes-per-inode" setting to calculate how many inodes a file system should have. On smaller partitions, it is advised to increase the calculated number of inodes.

On ext2, this can be done using the following command:
Code:
root #mke2fs -T small /dev/<device>


Then after a table this:

Quote:
For instance, to have the boot partition (/dev/sda2) in ext2 and the root partition (/dev/sda4) in ext4 as used in the example partition structure, the following commands would be used:
Code:
root #mkfs.ext2 /dev/sda2


The boot partition I created is less than 8GB, so after thinking it over and reading several times I went ahead and used the first command above. Then, and my ignorance is showing, I got worried I needed to actually run mkfs.ext2 also so I did. It told me there was already a filesystem present, and I proceeded to see what would happen. The output was the same as mke2fs except for the UUID, obviously, or it wouldn't be a unique identifier I guess.

So, since both commands create an ext2fs, I decided it was probably better to create a filesystem designed for partitions less than 8GB, so I ran the first command again.

Is that the best choice?

If so, and maybe I'm just dense, perhaps the handbook, since it lays out default options and the default boot partition is 128MiB, could indicate that if the default partitioning is used then mke2fs -T should be used to create the boot filesystem.

I'm used to easy installs, which is why I'm finally giving Gentoo a whirl--to learn--but when in uncharted waters I tend to get very literal with the maps until I learn my way, so apologies again if this was too obvious to be asked.

TIA!
Back to top
View user's profile Send private message
Keruskerfuerst
Advocate
Advocate


Joined: 01 Feb 2006
Posts: 2288
Location: near Augsburg, Germany

PostPosted: Wed Jan 21, 2015 5:15 pm    Post subject: Reply with quote

As usual, the /boot partition does not contain many files: grub, one or two kernels, maybe a initrd, a config file for the kernel.
The boot partition size should be in the area of 100-200MB.
Back to top
View user's profile Send private message
vcg3rd
n00b
n00b


Joined: 21 Jan 2015
Posts: 3

PostPosted: Wed Jan 21, 2015 5:36 pm    Post subject: Reply with quote

Keruskerfuerst wrote:
As usual, the /boot partition does not contain many files: grub, one or two kernels, maybe a initrd, a config file for the kernel.
The boot partition size should be in the area of 100-200MB.


Right, so mke2fs -T small /dev/sda2 is the better command than mkfs.ext2 for creating a filesystem on it?
Back to top
View user's profile Send private message
Keruskerfuerst
Advocate
Advocate


Joined: 01 Feb 2006
Posts: 2288
Location: near Augsburg, Germany

PostPosted: Wed Jan 21, 2015 5:43 pm    Post subject: Reply with quote

You should use ext3 or ext4 for filesystems, since ext2 is not developed any more.
Back to top
View user's profile Send private message
gotyaoi
Tux's lil' helper
Tux's lil' helper


Joined: 01 Apr 2013
Posts: 137

PostPosted: Wed Jan 21, 2015 6:46 pm    Post subject: Reply with quote

vcg3rd wrote:
Right, so mke2fs -T small /dev/sda2 is the better command than mkfs.ext2 for creating a filesystem on it?

as Keruskerfuerst says, you may not want to use ext2 anymore. That aside, there is a simple answer to your question. If you do ls -l /sbin/mkfs.ext*, you will get something like the following:
Code:
lrwxrwxrwx 1 root root 6 Jul 23 16:17 /sbin/mkfs.ext2 -> mke2fs
lrwxrwxrwx 1 root root 6 Jul 23 16:17 /sbin/mkfs.ext3 -> mke2fs
lrwxrwxrwx 1 root root 6 Jul 23 16:17 /sbin/mkfs.ext4 -> mke2fs
lrwxrwxrwx 1 root root 6 Jul 23 16:17 /sbin/mkfs.ext4dev -> mke2fs

Notice that these files are symlinks to mke2fs. mke2fs changes it's behavior to create the appropriate fs type based on how it was invoked, so the mkfs.ext* programs are simply shortcuts to invoking mke2fs with certain options already set. The mkfs.ext* programs should accept the same arguments and options as mke2fs in most cases, so there is really no difference between them besides convenience.
Back to top
View user's profile Send private message
vcg3rd
n00b
n00b


Joined: 21 Jan 2015
Posts: 3

PostPosted: Wed Jan 21, 2015 9:36 pm    Post subject: Reply with quote

That all makes sense. Thanks! I haven't proceeded any further, so I will change the FS on boot to ext3. However, I still don't understand:

Quote:
"When using ext2, ext3 or ext4 on a small partition (less than 8GB), then the file system must be created with the proper options to reserve enough inodes."


Am I to assume when making boot an ext3, and well under 8GB, I should still use the -T small option?
Back to top
View user's profile Send private message
gotyaoi
Tux's lil' helper
Tux's lil' helper


Joined: 01 Apr 2013
Posts: 137

PostPosted: Thu Jan 22, 2015 7:19 pm    Post subject: Reply with quote

Well, it sort of depends. By default, mke2fs will assign the -T option on it's own. according to the man page:
Code:
-T usage-type[,...]
              Specify how the filesystem is going to be used, so that mke2fs can choose optimal filesystem parameters for that use.  The usage types that are supported are defined in the configuration file /etc/mke2fs.conf.  The user may specify one or more usage types using a comma separated list.

              If this option is is not specified, mke2fs will pick a single default usage type based on the size of the filesystem to be created.  If the filesystem size is less than  or equal  to 3 megabytes, mke2fs will use the filesystem type floppy.  If the filesystem size is greater than 3 but less than or equal to 512 megabytes, mke2fs(8) will use the filesystem type small.  If the filesystem size is greater than or equal to 4 terabytes but less than 16 terabytes, mke2fs(8) will use  the  filesystem  type  big.   If  the filesystem size is greater than or equal to 16 terabytes, mke2fs(8) will use the filesystem type huge.  Otherwise, mke2fs(8) will use the default filesystem type default.

So the default cutoff for small is <=512MB. If we look in /etc/mke2fs.conf, we see:
Code:
[defaults]
        base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr
        default_mntopts = acl,user_xattr
        enable_periodic_fsck = 0
        blocksize = 4096
        inode_size = 256
        inode_ratio = 16384

[fs_types]
...
        small = {
                blocksize = 1024
                inode_size = 128
                inode_ratio = 4096
        }

Here we can see that on a "small" file system, the block size, inode size and inode ratio are reduced. So what does this affect eh?

  1. Block size is the size of a block on disk. A higher block size usually means more efficient reads of large files, but more wasted space for small files. A file takes up one block, regardless of how small it is, and they can't really share blocks. If there were a lot of small files, a large value could prove to be space inefficient, while if there were big files, a small value could lead to less efficient reads. Block size also affects max filesize ranging from 16GB for a small value to 2TB for a large value.

  2. Inode ratio is the number of bytes per inode. Let's look at a few examples here. Let's say your boot partition is 256MB. With the default ratio of 16384, that's
    Code:
    268435456 bytes/16384 inodes per byte=16384 inodes
    vs
    Code:
    268435456 bytes/4096 inodes per byte=65536 inodes

    Since we need 1 inode per file, even with the default settings this gives us 16384 files. For reference, my /boot partition has ~400 files. This matters for exceedingly small file systems, but for larger filesystems, lowering the inode ratio is a waste of space. You can do these calculations with your actual partition size.

  3. Inode size has to be a power of 2 > 128. Larger inode sizes allow the filesystem to store extended metadata in the inode, which can save space, or waste space, depending on the number of inodes you're using vs how many you have. Having the extra info in the inode can also help performance. Using the number of inodes from the last point, we can calculate how much space the inode table would take. At the default 256 bytes per inode, that's
    Code:
    16384 inodes* 256 bytes per inode=4194304 bytes

    or about 4MB, and
    Code:
    65536 inodes*256 bytes per inode=16777216 bytes

    or about 16MB. Using 128 bytes per inode, those values are halved to 2MB and 8MB respectively. Again, you can do the calculations with your own partition size.


Generally, the options for a small filesystem are designed to minimize wasted space, while the default ones are slightly more performant. In my opinion, the default choices that mke2fs makes are usually pretty good, but if you have more information about how a partition is to be used, you can tune things further. By this I don't mean to specify the -T option, but to change things like the inode ratio or block size individually. Again, just my opinion, but I think the need to do such a tweak is quite rare.

But hey, opinions differ. You should act as best you can determine given the data available to you.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum