Format a partition with EXT#
mouse 1879 · person cloud · link
Last update
2018-03-18
2018
03-18
« — »
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# create the filesystem
mkfs.extX -v    \ # verbose
  -j            \ # explicitly create the filesystem with an ext3 journal
  -b 4096       \ # block size (see /sys/block/sdXY/queue/physical_block_size)
  -E nodiscard  \ # do not TRIM encrypted SSD (ext4 only)
  -L nice_label \ # set a volume label
  /dev/sdXY

# tune options
tune2fs           \
  -c 60           \ # check filesystem every 60 mounts
  -C 0            \ # set current mount count
  -i 2m           \ # check filesystem every 2 months
  -e remount-ro   \ # on error remount filesystem read-only
  -m 3            \ # reserve 3% of space to root/defrag
  -o journal_data \ # all data committed into journal before writing to disk
  /dev/sdXY

Notes:

  • remove line comments as they are not syntactically correct
  • reserved space for defragmentation is useless for SSD: set 0% for data partitions and a number greater than 0 for system ones.
  • if you use ext4 then read the post why Delayed Allocation is Bad and mount your partition with -o nodelalloc to make it safe against a server crash.
  • on the raspberry pi avoid mounting a partition with journal_data option because in some circumstances it may lead to untolerable abysmal performance