Hot answers tagged

114

Check with lsof to see if there are files held open. Space will not be freed until they are closed. sudo /usr/sbin/lsof | grep deleted will tell you which deleted files are still held open.


112

How do I tell what sort of data (what data format) is in a file? → Use the file utility. Here, you want to know the format of data in a device file, so you need to pass the -s flag to tell file not just to say that it's a device file but look at the content. Sometimes you'll need the -L flag as well, if the device file name is a symbolic link. You'll see ...


84

The field gets populated (see below) only coreutils stat does not display it. Apparently they're waiting1 for the xstat() interface. coreutils patches - aug. 2012 - TODO stat(1) and ls(1) support for birth time. Dependent on xstat() being provided by the kernel You can get the creation time via debugfs: debugfs -R 'stat <inode_number>' DEVICE ...


76

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 ...


65

Another option is to use blkid: $ blkid /dev/sda1 /dev/sda1: UUID="625fa1fa-2785-4abc-a15a-bfcc498139d1" TYPE="ext2" This recognizes most filesystem types and stuff like encrypted partitions. You can also search for partitions with a given type: # blkid -t TYPE=ext2 /dev/sda1: UUID="625fa1fa-2785-4abc-a15a-bfcc498139d1" TYPE="ext2" /dev/sdb1: UUID="...


58

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. ...


50

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.


41

You can use sudo parted -l [shredder12]$ sudo parted -l Model: ATA WDC WD1600BEVT-7 (scsi) Disk /dev/sda: 160GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 8587MB 8587MB primary ext3 boot 4 8587MB 40.0GB 31.4GB primary ext4 2 ...


37

Use lsof to find the deleted, but open, file still consuming space: lsof | grep deleted | grep etilqs_1IlrBRwsveCCxId chrome 3446 user 128u REG 253,2 16400 2364626 /var/tmp/etilqs_1IlrBRwsveCCxId (deleted) Find the entry in /proc/<pid>/fd/ that cooresponds to the filehandle: ls -l /proc/3446/fd/...


37

You should not use df because it shows the size as reported by the filesystem (in this case, ext4). Use the dumpe2fs -h /dev/mapper/ExistingExt4 command to find out the real size of the partition. The -h option makes dumpe2fs show super block info without a lot other unnecessary details. From the output, you need the block count and block size. ... Block ...


36

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 ...


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

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 ...


29

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 ...


29

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 ...


28

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=...


25

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 ...


24

The -T largefile flag adjusts the amount of inodes that are allocated at the creation of the file system. Once allocated, their number cannot be adjusted (at least for ext2/3, not fully sure about ext4). The default is one inode for every 16K of disk space. -T largefile makes it one inode for every megabyte. Each file requires one inode. If you don't have ...


24

No. It won't give consistent results on the read-only client, because of caching. It's definitely not designed for it. You could expect to see IO errors returned to applications. There's probably still some number of oversights in the code, that could cause a kernel crash or corrupt memory used by any process. But most importantly, ext4 replays the ...


21

Let's see. The device size is 1,465,138,583½ kB = 1,500,301,909,504 B. The filesystem consists of 366,284,288 blocks of 4096 B each, which is 1,500,300,443,648 B. I don't know what the remaining 1,465,856 B (1.4 MB) are used for (additional copies of the superblock? I know there are a few kB of space at the beginning for the bootloader.). The filesystem ...


21

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.


21

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.


21

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 is a function that an application can call that requests a service from the kernel, such as reading or writing data to the disk. The userspace process simply waits for the syscall ...


20

Theres no missing space. 5% reserved is rounded down to the nearest significant figure. 1k Blocks: 1922860848 Reserved 1k Blocks: (24418931 * 4) = 97675724 Total blocks used: 927384456 + 897800668 + 97675724 = 1922860848 Edit: Regarding your comment on the difference between df blocks and 'Block Count' blocks. So the 4k block difference is (1953514496 - ...


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 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 (...


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 ...


19

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 ...


18

The answer to your question lies in the e2fsck/problems.c file of the e2fsprogs source code. Looking for the PR_PREEN_OK flag should get you started. As the complete error handling is a bit more involved, due to the multitude of different error conditions that may occur, you are advised to have a closer look at the code if you are concerned about a specific ...


18

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) ...


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