Note
fsck
. For more information, see
Chapter 5, The Ext3 File System.
fsync()
call afterwards.
fsync()
. This behavior hid bugs in programs that did not use
fsync()
to ensure that written data was on-disk. The ext4 file system, on the other hand, often waits several seconds to write out changes to disk, allowing it to combine and reorder writes for better disk performance than ext3.
Warning
fsync()
to ensure that data is written to permanent storage.
xattr
) — This allows the system to associate several additional name and value pairs per file.
Note
data=ordered
(default).
mkfs.ext4
command. In general, the default options are optimal for most usage scenarios:
# mkfs.ext4 /dev/device
Example 6.1. mkfs.ext4
command output
~]# mkfs.ext4 /dev/sdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 245280 inodes, 979456 blocks 48972 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1006632960 30 block groups 32768 blocks per group, 32768 fragments per group 8176 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 20 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
mkfs.ext4
chooses an optimal geometry. This may also be true on some hardware RAIDs which export geometry information to the operating system.
-E
option of
mkfs.ext4
(that is, extended file system options) with the following sub-options:
value
must be specified in file system block units. For example, to create a file system with a 64k stride (that is, 16 x 4096) on a 4k-block file system, use the following command:
# mkfs.ext4 -E stride=16,stripe-width=64 /dev/device
man mkfs.ext4
.
Important
tune2fs
to enable some ext4 features on ext3 file systems, and to use the ext4 driver to mount an ext3 file system. These actions, however, are
not supported in Red Hat Enterprise Linux 6, as they have not been fully tested. Because of this, Red Hat cannot guarantee consistent performance and predictable behavior for ext3 file systems converted or mounted in this way.
# mount /dev/device /mount/point
acl
parameter enables access control lists, while the
user_xattr
parameter enables user extended attributes. To enable both options, use their respective parameters with
-o
, as in:
# mount -o acl,user_xattr /dev/device /mount/point
tune2fs
utility also allows administrators to set default mount options in the file system superblock. For more information on this, refer to
man tune2fs
.
nobarrier
option, as in:
# mount -o nobarrier /dev/device /mount/point
resize2fs
command:
# resize2fs /mount/device node
resize2fs
command can also decrease the size of an
unmounted ext4 file system:
# resize2fs /dev/device size
resize2fs
utility reads the size in units of file system block size, unless a suffix indicating a specific unit is used. The following suffixes indicate specific units:
s
— 512 byte sectors
K
— kilobytes
M
— megabytes
G
— gigabytes
Note
resize2fs
automatically expands to fill all available space of the container, usually a logical volume or partition.
man resize2fs
.
Procedure 6.1. Backup ext2/3/4 File Systems Example
/etc/fstab
and the output of
fdisk -l
. Running an sosreport/sysreport will capture this information and is strongly recommended.
# cat /etc/fstab LABEL=/ / ext3 defaults 1 1 LABEL=/boot1 /boot ext3 defaults 1 2 LABEL=/data /data ext3 defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 LABEL=SWAP-sda5 swap swap defaults 0 0 /dev/sda6 /backup-files ext3 defaults 0 0 # fdisk -l Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1925 15358140 83 Linux /dev/sda3 1926 3200 10241437+ 83 Linux /dev/sda4 3201 4864 13366080 5 Extended /dev/sda5 3201 3391 1534176 82 Linux swap / Solaris /dev/sda6 3392 4864 11831841 83 Linux
/dev/sda6
partition to save backup files, and we assume that
/dev/sda6
is mounted on
/backup-files
.
dump
to backup the contents of the partitions:
Note
e2fsck
on the partitions before backup.
dump
should not be used on heavily loaded and mounted filesystem as it could backup corrupted version of files. This problem has been mentioned on
dump.sourceforge.net.
Important
# dump -0uf /backup-files/sda1.dump /dev/sda1 # dump -0uf /backup-files/sda2.dump /dev/sda2 # dump -0uf /backup-files/sda3.dump /dev/sda3
Note
# dump -0u -f - /dev/sda1 | ssh root@remoteserver.example.com dd of=/tmp/sda1.dump
Procedure 6.2. Restore an ext2/3/4 File System Example
fdisk
command.
Note
mkfs
command, as shown below.
Important
/dev/sda6
in the above example because it saves backup files.
# mkfs.ext3 /dev/sda1 # mkfs.ext3 /dev/sda2 # mkfs.ext3 /dev/sda3
fstab
file. This step is not required if the partitions are not being recreated.
# e2label /dev/sda1 /boot1 # e2label /dev/sda2 / # e2label /dev/sda3 /data # mkswap -L SWAP-sda5 /dev/sda5
# mkdir /mnt/sda1 # mount -t ext3 /dev/sda1 /mnt/sda1 # mkdir /mnt/sda2 # mount -t ext3 /dev/sda2 /mnt/sda2 # mkdir /mnt/sda3 # mount -t ext3 /dev/sda3 /mnt/sda3 # mkdir /backup-files # mount -t ext3 /dev/sda6 /backup-files
# cd /mnt/sda1 # restore -rf /backup-files/sda1.dump # cd /mnt/sda2 # restore -rf /backup-files/sda2.dump # cd /mnt/sda3 # restore -rf /backup-files/sda3.dump
# ssh 10.0.0.87 "cd /mnt/sda1 && cat /backup-files/sda1.dump | restore -rf -"
# ssh 10.0.0.87 "cd /mnt/sda1 && RSH=/usr/bin/ssh restore -r -f 10.66.0.124:/tmp/sda1.dump"
quota
, refer to
man quota
and
Section 16.1, “Configuring Disk Quotas”.
tune2fs
utility can also adjust configurable file system parameters for ext2, ext3, and ext4 file systems. In addition, the following tools are also useful in debugging and analyzing ext4 file systems:
man
pages.