Put MKFS_OPTS after filesystem type

mkfs's arguments are

 mkfs [options] [-t type] [fs-options] device [size]

So it seems our MKFS_OPTS are really supposed to be fs-options, rather
than options to mkfs itself.

Why didn't we notice?  It's quite a trap -- mkfs.ext2 has a "-t"
option, so when we're calling

 $ mkfs -i 4096 ... -t ext4 ...

We actually just fall-back to the default from the mkfs wrapper which
is mkfs.ext2 which works!  But when you make that, say, xfs, we're not
calling the right wrapper at all.

Also update documentation

Closes-Bug: #1648287
Change-Id: I3ea5807088ab361bd9c235c07fb1553fbaf9178b
This commit is contained in:
Ian Wienand 2016-12-08 15:59:15 +11:00
parent 8c74c8e409
commit 5e2330d89c
2 changed files with 17 additions and 10 deletions

View File

@ -417,7 +417,7 @@ LOOPDEV=$(sudo losetup --show -f $TMP_IMAGE_PATH)
export EXTRA_UNMOUNT="detach_loopback $LOOPDEV"
export IMAGE_BLOCK_DEVICE=$LOOPDEV
eval_run_d block-device "IMAGE_BLOCK_DEVICE="
sudo mkfs $MKFS_OPTS -t $FS_TYPE -L ${DIB_ROOT_LABEL} ${IMAGE_BLOCK_DEVICE}
sudo mkfs -t $FS_TYPE $MKFS_OPTS -L ${DIB_ROOT_LABEL} ${IMAGE_BLOCK_DEVICE}
# Tuning the rootfs uuid works only for ext filesystems.
if echo "$FS_TYPE" | grep -q "^ext"; then
sudo tune2fs -U ${DIB_IMAGE_ROOT_FS_UUID} ${IMAGE_BLOCK_DEVICE}

View File

@ -58,18 +58,25 @@ formats are:
Filesystem Caveat
-----------------
By default, disk-image-create uses a 4k byte-to-inode ratio when creating the
filesystem in the image. This allows large 'whole-system' images to utilize
several TB disks without exhausting inodes. In contrast, when creating images
intended for tenant instances, this ratio consumes more disk space than an
end-user would expect (e.g. a 50GB root disk has 47GB avail.). If the image is
intended to run within a tens to hundrededs of gigabyte disk, setting the
byte-to-inode ratio to the ext4 default of 16k will allow for more usable space
on the instance. The default can be overridden by passing --mkfs-options like
this::
By default, disk-image-create uses a 4k byte-to-inode ratio when
creating the filesystem in the image. This allows large 'whole-system'
images to utilize several TB disks without exhausting inodes. In
contrast, when creating images intended for tenant instances, this
ratio consumes more disk space than an end-user would expect (e.g. a
50GB root disk has 47GB avail.). If the image is intended to run
within a tens to hundrededs of gigabyte disk, setting the
byte-to-inode ratio to the ext4 default of 16k will allow for more
usable space on the instance. The default can be overridden by passing
``--mkfs-options`` like this::
disk-image-create --mkfs-options '-i 16384' <distro> vm
You can also select a different filesystem by setting the ``FS_TYPE``
environment variable.
Note ``--mkfs-options`` are options passed to the mfks *driver*,
rather than ``mkfs`` itself (i.e. after the initial `-t` argument).
Speedups
--------
If you have 4GB of available physical RAM (as reported by /proc/meminfo