Hot answers tagged

80

The answer is "Probably yes, but it depends on the filesystem type, and timing." None of those three examples will overwrite the physical data blocks of old_file or existing_file, except by chance. mv new_file old_file. This will unlink old_file. If there are additional hard links to old_file, the blocks will remain unchanged in those remaining links. ...


80

Presumably, you'll be seeing some flavor of "No space left on device" error: # truncate -s 100M foobar.img # mkfs.ext4 foobar.img Creating filesystem with 102400 1k blocks and 25688 inodes ---> number of inodes determined at mkfs time ^^^^^ # mount -o loop foobar.img loop/ # touch loop/{1..25688} touch: cannot touch 'loop/25678': No space left on device ...


80

I can think of two things offhand: you didn't use -H, so hardlinks are lost. you didn't use -S, so sparse files may have been expanded


62

A directory that used to be huge may still have a lot of blocks allocated for directory entries (= names and inode numbers of files and sub-directories in that directory), although almost all of them are now marked as deleted. When a new directory is created, only a minimum number of spaces are allocated for directory entries. As more and more files are ...


52

Once the limit is reached, subsequent attempts to create files will fail with ENOSPC, indicating that the target file system has no room for new files. In the scenario you describe, this will typically result in the transfer aborting once the limit is reached.


44

Out of curiosity, let's try to reproduce this: $ mkdir test $ cd test $ time ls # Check initial speed of ls real 0m0,002s $ stat . # Check initial size of directory File: . Size: 4096 Blocks: 8 IO Block: 4096 directory ... $ seq 1 1000000 | xargs touch # Create lot of files $ echo 3 | sudo tee /proc/sys/vm/drop_caches # ...


42

I combined this into a simple shell function: get_crtime() { for target in "${@}"; do inode=$(stat -c %i "${target}") fs=$(df --output=source "${target}" | tail -1) crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null | grep -oP 'crtime.*--\s*\K.*') printf "%s\t%s\n" "${target}" "${crtime}" done } You ...


38

That is strongly indicative of file-system corruption. You should unmount, make a sector-level backup of your disk, and then run e2fsck to see what is up. If there is major corruption, you may later be happy that you did a sector-level backup before letting e2fsck tamper with the data.


37

The exact quote from the ext4 Wikipedia entry is However, Red Hat recommends using XFS instead of ext4 for volumes larger than 100 TB. The ext4 howto mentions that The code to create file systems bigger than 16 TiB is, at the time of writing this article, not in any stable release of e2fsprogs. It will be in future releases. which would be one reason ...


36

Yes, data=journal is the safest way of writing data to disk. Since all data and metadata are written to the journal before being written to disk, you can always replay interrupted I/O jobs in the case of a crash. It also disables the delayed allocation feature, which may lead to data loss. The 3 modes are presented in order of safeness in the manual: data=...


36

Like any unix-style filesystem, ext4 includes standard Unix file ownership and permission conventions. That is, the user is identified by an UID number, and each user will belong to one or more groups, each group identified by its GID number. Each file has an owner UID and one group owner GID. The three classic Unix file permission sets are: one set of ...


33

Try this: mkfs.ext4 -N 104 -m0 -O ^has_journal,^resize_inode /dev/purgatory/test1 I thinks this does let you understand "what is going on". -N 104 (set the number of iNodes you filesystem should have) every iNode "costs" usable space (128 Byte) -m 0 (no reserved blocks) -O ^has_journal,^resize_inode (deactivate the features has_journal and resize_inode ...


33

If you want a fix and are not just trying out debugfs, you can have fsck do the work for you. Mark the filesystem as dirty and run fsck -y to get the filename changed: $ debugfs -w -R "dirty" /tmp/ext4fs $ fsck -y /tmp/ext4fs ... /tmp/ext4fs was not cleanly unmounted, check forced. Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory ...


32

Disadvantages of btrfs compared to ext4: btrfs doesn't support badblocks This means that if you've run out of spare non-addressable sectors that the HDD firmware keeps to cover for a limited number of failures, there is no way to mark blocks bad and avoid them at the filesystem level. Swap files are only supported via a loopback device, which complicates ...


29

The xstat function never got merged into mainline. However, a new statx call was proposed later on, and was merged in Linux 4.11. The new statx(2) system call does include a creation time in its return struct. A wrapper for statx(2) was added to glibc only in 2.28 (release August 2018). And support for using this wrapper was added in GNU coreutils 8.31 (...


29

Take a look at the bindfs package. bindfs is a FUSE filesystem that allows for various manipulations of file permissions, file ownership etc. on top of existing file systems. You are looking specifically for the --map option of bindfs: --map=user1/user2:@group1/@group2:..., -o map=... Given a mapping user1/user2, all files owned by user1 are shown as ...


26

Bug in the implementation of ext4 feature dir_index which you are using on your destination filesystem. Solution : recreate filesytem without dir_index. Or disable feature using tune2fs (some caution required, see related link Novell SuSE 10/11: Disable H-Tree Indexing on an ext3 Filesystem which although relates to ext3 may need similar caution. (get a ...


25

This is safe to do, but naturally you may not have finished the copy. When the cp command is run, it makes syscalls that instruct the kernel to make copies of the file. A syscall, or system call, is a function that an application can use to requests a service from the kernel, such as reading or writing data to the disk. The userspace process simply waits for ...


25

AFAIK, not with the kernel API. If such an interface existed, it would have to be limited to the super-user as otherwise that would let anyone access files in directories they don't have search access to. But you could use debugfs on the file system (once it's unmounted) to do it (assuming you have write access to the block device). debugfs -w /dev/block/...


23

I just ran into this same problem. After debugging the issue with the e2fsck maintainer, we realised that the SD card was broken. It was accepting writes without error, but it wasn't actually writing the data to the card. The SD card was effectively read only. It seems the card had gone into some sort of failsafe mode, where the data could still be read, ...


23

Since cp is a userspace command, this does not affect filesystem integrity. You of course need to be prepared that at least one file will not have been copied completely if you kill a runnning cp program.


22

The ext4 filesystem has no built-in snapshot feature. The generic way to make snapshots under Linux is at the level of the storage volume. Your filesystem must be on an LVM logical volume, which is Linux's own partition system, as opposed to directly on a platform-native disk partition. To create a snapshot of a logical volume, run lvcreate --snapshot. You ...


21

That's the problem with multi-user systems, especially if you have more than one of them. ;) There's no really nice way to do what you want. Approaches coming to mind would be having the same UID for your account on every machine you're using your external drive (actually not feasible, since most probably not all of the machines are under your control) ...


20

Most modern file systems are journaling file systems, which means that they keep track of changes that have not yet been written to disk in an internal data structure called a journal. In the event of a crash, this journal will be replayed, to make sure that all writes performed successfully, preventing file corruption. When actually writing out the data ...


20

Lower inode number doesn't prove older. A simple case that would change that sequence is deleting a file which would free the inode. That inode therefore becomes available for future use.


19

The short answer: Not all space on the block device becomes available space for your data: some of the raw space is needed for file-system internals, the behind the scenes bookkeeping. That bookkeeping includes the super block, block group descriptors, block and inode bitmaps, and the inode table. In addition copies of the super block for backup/recovery ...


18

Do you have /sbin in your path? Most likely you are trying to run mkfs.ext4 as a normal user. Unless you've added it yourself (e.g. in ~/.bashrc or /etc/profile etc), root has /sbin and /usr/sbin in $PATH, but normal users don't by default. Try running it from a root shell (e.g. after sudo -i) or as: sudo mkfs.ext4 -L hdd_misha /dev/sdb1 BTW, normal ...


18

ext4 filesystem check during boot Tested on OS: Linux Mint 18.x in a Virtual Machine Basic information /etc/fstab has the fsck order as the last (6th) column, for instance: <file system> <mount point> <type> <options> <dump> <fsck> UUID=2fbcf5e7-1234-abcd-88e8-a72d15580c99 / ext4 errors=remount-ro 0 1 ...


18

You didn't provide additional details, so this explanation is for the moment centered on the EXT file systems common in Linux. If you look at the "size" of a symlink as provided by e.g. ls -l, you will notice that the size is just as large as the name of the target it is pointing to is long. So, you can infer that the "actual" file ...


17

The man page for chattr contains all the info you need to understand the lsattr output. excerpt The letters `acdeijstuACDST' select the new attributes for the files: append only (a), compressed (c), no dump (d), extent format (e), immutable (i), data journalling (j), secure deletion (s), no tail-merging (t), undeletable (u), no ...


Only top voted, non community-wiki answers of a minimum length are eligible