date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,445,260,167,000
Introduction Until recently, I thought that on ext file system, inodes have reference counters which count the number of times the file is referenced by a directory entry or a file descriptor. Then, I learned that the reference counter only counts the number of directory entries referencing it. To falsify this, I read...
You are confusing two different counters: the file system link counter and the file descriptor reference counter. The file system link counter counts how many links to an inode are in the file system itself. The inode is the structure that contains the file metadata. In ext* file systems this counter is stored in the...
When is a file freed in an ext file system?
1,445,260,167,000
I have an old /home partition, that dates back to former linux systems, and it is still in ext3 format. Whereas the rest of my system, / and some other mounted point are devices formated in ext4. I have grasped some sites on the net that describes how to convert an ext3 partition to an ext4. In this UL.SE question Can...
Both ext3 and ext4 are journaling filesystems, in addition this list several differences, the most relevant are: Maximum individual file size can be from 16 GB to 16 TB Overall maximum ext4 file system size is 1 EB (exabyte). 1 EB = 1024 PB (petabyte). 1 PB = 1024 TB (terabyte). Directory can contain a maximum of 64,...
Convert old /home from ext3 to ext4
1,445,260,167,000
On my Debian Linux system during the install I decided to use disk encryption (the one offered during a regulard Debian install). When the system boots up I need to enter a password and then the "real" boot begins. Could someone explain how this encryption is performed? Does it happen before or after the filesystem'...
/boot is not encrypted (the BIOS would have no way to decrypt it...). It could be ext4, but there really isn't any need for it to be. It usually doesn't get written to. The BIOS reads GRUB from the MBR, then GRUB reads the rest of itself, the kernel, and the initramfs from /boot. The initramfs prompts you for the pass...
Encrypted disk filesystem compatibilities
1,445,260,167,000
I’m running a linux server at home which is mostly a file and e-mail server and a digital video recorder. All the data goes on an ext4 partition on a software raid-6. Every now and then (sometimes twice a day, sometimes twice a month) the whole server locks up. Sometimes I have a kernel report in the syslog which I ca...
kernel BUG at fs/ext4/inode.c:2118! invalid opcode: 0000 [#1] SMP Appears to be an issue with the ext4 driver in your kernel. Process mythbackend (pid: 27841, threadinfo ffff88004262a000, task ffff88007fb83330) mythbackend is triggering it. [<ffffffff811731df>] mpage_da_map_and_submit+0x2c6/0x2dc [<ffffffff8117390a>...
What does this Linux kernel trace mean?
1,445,260,167,000
If I dd my disk and compress the image with lzma or lzo the image is still big. The partition is 10GB used, 90GB available. But the image still around 20GB. I believe that is because I have copied many and deleted many files on that disk and the filesystem doesn't zero the unused blocks from those deletions. How can ...
The tool you think you're looking for is zerofree, as described in this duplicate question Clear unused space with zeros (ext3,ext4), and already available in most distributions. However, you seem to be asking how to take an image backup of a filesystem that excludes unused blocks. In this instance use fsarchiver, as ...
How can I zero the unused blocks on my filesystem in order to minimize the compressed disk image size? [duplicate]
1,445,260,167,000
I have a USB flash drive with ext4 file system and its files are owned by my user on my local machine, for example by myuser@myhost with 700 permissions. If I unplug my flash drive and plug it in other Linux machine, can users of that machine have access to files in the flash drive? What if there is also a user named ...
Filesystems designed for unix, such as ext4, track the user via a number, the user ID. The user name is not recorded. You can see your own user ID with the command id -u. You can see the user ID who owns a file with ls -ln /path/to/file. If you take an ext4 filesystem to a different machine, the files will still have ...
Permissions on an ext4 filesystem on a removable drive used in different machines
1,445,260,167,000
I tried looking at the difference, the main ones seem to be 4 supports more subdirectories in a file, supports larger files, has delayed write which I don't prefer as I don't want data loss. I also see timestamps are more accurate but it also mentions there is no support in glibc so no apps would use it. Also I just n...
These days ext4 is considered the stable standard, and you should use it. Also all filesystems use delayed writing, ext4 just delays allocating where the blocks go until they are actually written, which helps reduce fragmentation. It also uses extents to track the blocks, which makes it more efficient.
How do I choose between ext 3 and 4?
1,445,260,167,000
Suppose you have an ext3 partition which was unfortunately formated as ext4 partition (and where now are some but not a lot new files on it). Is there any way to recover (some) files from the old ext3 partition?
You can use a tool like PhotoRec to read the blocks and try to recover files. It actually recovers a lot of file types, not just images like the name may suggest. http://www.cgsecurity.org/wiki/PhotoRec
Recover formatted ext3 partition
1,445,260,167,000
I'm using ext4 encryption. https://wiki.archlinux.org/index.php/Ext4#Using_file-based_encryption Before I decrypt a directory, I can see lots of encrypted filenames in it. I would like to copy the encrypted files so that I can decrypt them on a different machine. I could do this with ecryptfs. How do I do this with ...
You can see encrypted & padded filenames, but you should be unable to read file contents. So trying to copy the files unencrypted will result in errors such as: cp: cannot open 'vault/YgI8PdDi8wY33ksRNQJSvB' for reading: Required key not available So you are pretty much not supposed to do this. The practical answer i...
Copying ext4 encrypted files
1,445,260,167,000
While I did Ubuntu netinst, the question came into my head. The question is: is reserved 5% kind of run-time? I mean, when doing something like sudo apt install - this 5% is beign used by root at this moment? Does system use this 5% at run-time? Do I have to increase it up to 10-15% e.g.? I have 300gb hard drive. Usua...
I mean, when doing something like sudo apt install - this 5% is being used by root at this moment? Yes. No. Maybe. It doesn't quite work that way. When you hear the term root reserve, you might think there is a specific area where only root may store files in. Like in a parking lot, you might find spots designated f...
Root reserved blocks
1,445,260,167,000
With NTFS you can enable or disable case sensitivity. Is there a way to do it with ext4 in Linux?
There are patches currently under development to implement case insensitivity for ext4. https://lwn.net/Articles/762826/ https://marc.info/?l=linux-ext4&m=154430575726827&w=2 They were included in the Linux 5.2 kernel, and also require e2fsprogs-1.45 to work. See How to enable new in kernel 5.2 case-insensitivity for...
Is it possible to disable ext4 case sensitivity?
1,445,260,167,000
I am using: debugfs -R 'stat <7473635>' /dev/sda7 to get the file creation time (crtime). Inode: 7473635 Type: regular Mode: 0664 Flags: 0x80000 Generation: 1874934325 Version: 0x00000000:00000001 User: 1000 Group: 1000 Size: 34 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 8 Fragment: Addr...
It does show the timestamp (with nanoseconds precision) but in hex; it's the field after crtime:, e.g. in your output 0x55b65ebc:970fe7cc. The part after the colon is the nanoseconds. This article gives more details and explains how to calculate the timestamp/nanoseconds. So, e.g. to convert the hex values to a timest...
Why debugfs doesn't show crtime in nanoseconds?
1,445,260,167,000
I was compiling a custom linux kernel for a newly installed machine, and after booting into the new kernel (3.12), the init process fails to find a root device, which I traced to the system getting an unknown partition table error on the device in question (/dev/sda). The generic kernel boots up and mounts the root pa...
There are a bunch of options mostly named CONFIG_.*_PARTITION, you probably didn't set the one you need. These may only show up if you answer yes to CONFIG_PARTITION_ADVANCED (Advanced partition selection). You're going to want (on a PC) at least: CONFIG_MSDOS_PARTITION=y # traditional MS-DOS partition table CON...
"unknown partition table" - misconfigured kernel
1,445,260,167,000
I'm trying to enable journaled usrquota on Debian 11 Kernel 5.10. All information I find uses external files which leads to the following deprecation warning: quotaon: Your kernel probably supports ext4 quota feature but you are using external quota files. Please switch your filesystem to use ext4 quota feature as ext...
To enable journaled quota tune2fs is used. No mount options in /etc/fstab are needed. I.E. assuming you want quotas for /home enabled which is on /dev/sda2 you do: umount /home tune2fs -O quota /dev/sda2 mount -a quotaon -va If you want to turn quota on for the root file system you need to boot from a live disk and u...
How to enable journaled quota on Debian 11
1,445,260,167,000
I have downloaded Debian GNU/Hurd disk image. However, while the virtual machine was running, my PC crash along with the virtual machine. I tried to start the virtual machine, but many things were not working because the filesystem was damaged. As far as I know, EXT4 is a journaling filesystem, so any damage to the fi...
As far as I’m aware, there’s no translator for Ext4, whether in Debian specifically or in the Hurd in general. The existing ext2fs translator doesn’t support Ext4, and the version packaged in Debian doesn’t either.
Does Debian GNU/Hurd support ext4 filesystem?
1,445,260,167,000
According to this page, filesystems like ext4 have journaling for both blocks and metadata, and it's used to prevent data corruption: A journaling file system is a file system that keeps track of changes not yet committed to the file system's main part by recording the intentions of such changes in a data structure k...
Btrfs uses copy on write (CoW) so the existing data are not overwritten when modified but copied to a new location and the copy is changed. So journal is not needed because in case of power failure or system crash you still have the original data. Btrfs also uses checksums to detect random data corruptions so it knows...
How does btrfs prevent data corruption without journaling?
1,445,260,167,000
Formatting a disk for purely large video files, I calculated what I thought was an appropriate bytes-per-inode value, in order to maximise usable disk space. I was greeted, however, with: mkfs.ext4: invalid inode ratio [RATIO] (min 1024/max 67108864) I assume the minimum is derived from what could even theoretically ...
Because of the way the filesystem is built. It's a bit messy, and by default, you can't even have the ratio as down as 1/64 MB. From the Ext4 Disk Layout document on kernel.org, we see that the file system internals are tied to the block size (4 kB by default), which controls both the size of a block group, and the am...
Why is 67108864 the maximum bytes-per-inode ratio? Why is there a max?
1,445,260,167,000
I recently got a "device full" warning for a 2 Tb external ext4 drive. I deleted a bunch of files, about 90-100 Gb of old system backups, and since I did not want to empty all trash, I deleted the trash folders from the drive. No disk space was freed however, and I am still showing only about 5 Gb free after deletin...
There seem to be two possibilities here: You're being confused by the (admittedly confusing) behavior of df and root-reserved space You deleted (unlinked) one hardlink to the files, there are more. Personally, I suspect you're seeing #1. Details below, along with some concluding remarks. Confusing df behavior If you...
ext4 disk space not reclaimed after deleting files
1,445,260,167,000
According to this Red Hat bug report (which I am trying to reproduce) it looks like the Netapp filer is able to store data directly in the inode, in case of very small files. Considering I had a FS with large inodes, would it be possible to store data in such a way on a Unix / Linux file system?
ext4 since kernel 3.8 supports this: it can store (very) small files within the inode, as described in the filesystem layout documentation. Other filesystems support this on Linux too, or variants of the idea; for example Btrfs stores small files in the parent extent.
Is it possible to store data directly inside an inode on a Unix / Linux filesystem?
1,445,260,167,000
I've been having a fairly serious issue on a high traffic web server. PHP pages are slowing down considerably, and it only seems to be an issue on pages where sessions are accessed, or a certain table within a database is being referenced. the '/var/log/messages' log file, I see hundreds of thousands of the following ...
The size of the directory (as seen with ls -ld /var/lib/php/sessions) can give an indication. If it's small, there aren't many files. If it's large, there may be many entries in there, or there may have been many in the past. Listing the content, as long as you don't stat individual files, shouldn't take a lot much lo...
How to determine how many files are within a directory without counting?
1,445,260,167,000
After reading a lot about why newer 4096 byte physical block hard drives should be partitioned taking care of alignment (Linux on 4KB-sector disks: Practical advice, What is partition alignment and why whould I need it?, Why do I have to “align” the partitions on my new Western Digital hard drive?, I was convinced to ...
What is happening is that the -b switch is nonsense and should not even be there. The sector numbers recorded in the MBR are always interpreted to be in units of the drive's logical sector size ( 512 bytes ). By using the -b switch, you are causing fdisk to divide all of the sectors it records by 8, so the kernel in...
Why my partitions don't show the right capacity on a 4096 byte physical block hard drive?
1,445,260,167,000
I was monitoring a directory containing downloads from Google Chrome with ls -la and got this in the output: -????????? ? ? ? ? ? 'Unconfirmed 784300.crdownload' I've never seen such question marks in the output. There were other files in the directory with normal metadata output. When I ra...
That's a (temporary?) file which had disappeared in the time between ls reading its directory entry and trying to get the metadata from its inode. You can reproduce that by stopping ls just before it calls lstat on a file, removing that file, and then letting it continue: $ mkdir dir; touch dir/file $ gdb -q ls Readin...
Question marks in ls metadata output?
1,445,260,167,000
I'm having a wired problem in my laptop. It works fine but almost every hour the screen freezes. When I force the shutdown and start it again, I see problems similar to this: The only solution I found is turning over the laptop for few seconds before starting it again. This help me see my Ubuntu work normally withou...
Backup Immediately Go buy an additional external HDD/SSD and make a full CloneZilla Live backup right now! The dead giveaway that your drive is in imminent danger of failing is the following parameter: 184 End-to-End_Error 0x0032 096 096 099 Old_age Always FAILING_NOW 4 Especially as you've been ...
Random EXT4 FS errors
1,445,260,167,000
I read somewhere that an operating system which knows nothing about ext3 and ext4 (i.e. antique Linux version) is able to read/write to ext4, and it detects any ext4 file system as ext2. I am not quite sure, whether the same is possible to Tux2 to tux3 or with FAT12. (FAT64 is exFAT) How exactly is that possible? How...
This depends heavily on how the ext4 filesystem was formatted. Some newer ext4 features (e.g. extents or 64bit) cannot be understood by older ext2 drivers, and the kernel would refuse to mount the filesystem (see, for example this post). In general, any filesystem formatted with a modern mke2fs with the default -t e...
How exactly is ext2 upwards-compatible?
1,445,260,167,000
I have a very basic idea: I would like to defragment files in size less than 100MB only in ext4 filesystem. Since there is no option for that in the defragmentation tool (e4defrag), any ideas how I could achieve that? I know only how to find those files: find / -type f -size -100M Reason for such action: I had a syst...
I was a hair away from a solution: sudo find / -xdev -type f -size -100M -exec e4defrag {} + Notes: the -xdev argument as man page says: Don't descend directories on other filesystems. This means it will not process any other filesystems like tmpfs (/tmp) etc., see mount -v for all you have mounted.
How to defragment files in size less than 100MB only in ext4 filesystem
1,445,260,167,000
I'm using debootstrap to create a rootfs for a device that I want to then write to an image file. To calculate the size needed from my rootfs, I do the following: local SIZE_NEEDED=$(du -sb $CHROOT_DIR|awk '{print $1}') SIZE_NEEDED=$(($SIZE_NEEDED / 1048576 + 50)) # in MB + 50 MB space dd if=/dev/zero of=$ROOTFS_IMAG...
Possibly the simplest solution is to heavily overprovision the space initially, copy all the files, then use resize2fs -M to reduce the size to the minimum this utility can manage. Here's an example: dir=/home/meuh/some/dir rm -f /tmp/image size=$(du -sb $dir/ | awk '{print $1*2}') truncate -s $size /tmp/image mkfs.ex...
How to calculate the correct size of a loopback device filesystem image for debootstrap?
1,445,260,167,000
In order to test an analysis tool, I need a file where the depth (eh.eh_depth) is greater than 1. I've tried a couple of things: A large file (1GiB) Creating hundreds of smaller files (1MiB), deleting every other one, and then filling the disk with one file (hoping for massive fragmentation). In both cases I only go...
If you want a file with a lot of extents, just do: $ perl -we 'for ($i=0;$i<100000;$i++) {seek STDOUT,$i*8192,0; print "."}' > a $ ll a -rw-r--r-- 1 stephane stephane 819191809 Dec 15 23:50 a $ filefrag a a: 100000 extents found That's a sparse file where every other block is sparse, so it forces the extents to be 4K...
Can I create a file on ext4 with a depth > 1 for testing purposes?
1,445,260,167,000
I was using ext4 filesystems for a long time, and it's the first time I see a weird behavior of ext4 filesystem. There is ext4 filesystem in /dev/dm-2 An I/O error happened in the underlying device, and the filesystem was remounted read-only. It is fine and expected by the configuration.But for some unknown reason, no...
Disclaimer: I can't and won't explain in this answer why a kernel partial failure was triggered. This looks like a kernel bug, possibly triggered by the I/O error conditions. TL;DR Having a filesystem still in use can happen when a new mount namespace inherits a mounted filesystem from the original mount namespace, bu...
Why a filesystem is unmounted but still in use?
1,445,260,167,000
I have an old ext4 disk partition that I have to investigate without disturbing it. So I copied the complete partition to an image file and mounted that image file while continuing my investigation. Now while I do not write to the mounted filesystem, I do have to mount it with read/write access, because one of the pro...
I agree with @UlrichSchwarz mount it read-only, then use overlayFS or unionFS to create a writeable file-system. You can make the writable layer (the bit where the modifications go, disposable, or persistent. Ether way the changes are not stored on the master file-system.
Can I mount ext4 without writing the last mountpoint to the filesystem?
1,445,260,167,000
In Linux or more particular EXT4 the initial size of directory file is 4kB. But if a large enough number of files are stored within the directory the size of the directory file will increase due to the increase of the internal "file list". However, how many files are needed for this to happen? I have been unable to fi...
The format of ext4 directory entries is documented in the kernel. There are two possibilities. For linear directories, each entry occupies eight bytes, plus the file name (zero-terminated), rounded up to four bytes. So n file entries occupy 8 × n bytes plus the lengths of all the file names individually rounded up to...
How many files in a directory before the size of the directory file increase
1,445,260,167,000
I've got 16 nodes of elasticsearch (RHEL 7) - 18TB each, every node has a ext4 filesystem. For better efficency I need to change to XFS filesystem. Is there any tool / way which help me change filesystem without losing data? Or have I to do full backup of each node, which will be difficult because of large size of dat...
The extensible filesystem family (ext) has provided one way in place upgrades (ext2 to ext3 and ext3 to ext4); but this is only possible because the filesystem was specifically designed to be able to do this. There may be other filesystem families that are designed with a similar feature. In the case of a within famil...
Change filesystem without losing data
1,445,260,167,000
I'm going to put 4 million files into an EXT4 partition. I have about 700 files in each dir, the average file size is 38kb, total size is 169 gigabyte. What are the best options in terms of block size, inode size and inode ratio I can choose? Is it better to create two or more partitions, thinking at the checking tim...
Handling 4M files in a single filesystem is no problem for ext4, so long as the filesystem is formatted with enough inodes. It is no problem to even have 4M files in a single directory, if the filenames are not excessively large. There are Lustre filesystems with 1.5-2B files, and 10-12M files in a single directory ...
Best options for 4 million files on ext4
1,445,260,167,000
I have 2TB disk that I use in notebook. This disk was formatted as ext4 and It works fine in notebook, but when I attach it to desktop (via sata-usb adapter), I am unable to mount it due to following error: From desktop: # mount /dev/sdd1 /mnt mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sdd1, missin...
This happens with faulty USB interface adapters. Possible reasons for faulty adapters: Adapter too old Cheap adapter Bad adapter firmware These errors became a lot more frequent with the advent of advanced format drives. Some adapters try to "translate" AF drive interactions so they emulate legacy format drives. Thi...
ext4-fs: bad geometry: block count exceeds size of device
1,445,260,167,000
I'm on Ubuntu 18.04 and if I issue: $ cat /proc/mounts I don't see barrier=1 next to my main filesystem (under LVM). Does this mean barriers are not enabled? I read that while there were issues with this some time ago, now barriers are compatible with LVM. If they are not enabled, how can I enable them? Maybe by addi...
They are enabled by default Since many years ago, barriers are enabled by default on ext4. If you want to turn barriers off (and you have same sort of battery backup) then you can add barrier=0 to the options field in /etc/fstab. See the ext 4 documentation on kernel.org. Generally speaking, don't add options to fstab...
Can I enable barriers for ext4 under LVM?
1,445,260,167,000
I was wondering if it is possible to convert my boot system from xfs to ext4. If it is possible, how do I do so?
You can do this using fstransform, which is a tool to convert a filesystem type into another: fstransform /dev/sda1 ext4 Currently it supports all main Linux filesystems i.e. ext2, ext3, ext4, jfs, ntfs, reiserfs, xfs.
Convert boot filesystem from xfs to ext4
1,445,260,167,000
From last 2 weeks I have problem with my SSD in GNU/Linux. I think it's not device problem but I'm not sure. From time to time (every 1-2 days last days) I loss physical access to the disk, as if it was disconnected or powered off. The error: EXT4-fs error (device: sda2): ext4_find_entry:1465: inode #1308161: comm Ne...
I think I've fixed this by removing SDD, blowing air into M.2 connector and reinserting it back. When I booted to rescue Debian from USB I've noticed more detailed kernel debug information. While searching I've noticed most solutions were to replace SATA cables. Laptop M.2 connection has no cables. I'm posting screen ...
random SSD turn off - ext4_find_entry , reading directory lblock0
1,439,543,725,000
I was trying to resize my LUKS crypt following this https://wiki.archlinux.org/index.php/Resizing_LVM-on-LUKS and I got to the partition resize with parted and seriously screwed things up. I typed 870 as the new size and forgot to put a G on the end. It shrunk my partition down to 870M I immediately resized it to 870G...
You can't fix LVM by growing size back to original size, unless you were very lucky and the LV had no fragmentation whatsoever due to previous resizes. Chances are the new LV will have the first 20G or so of your original filesystem but the remaining 780G (or whatever) are scrambled eggs (wrong data, wrong offset, wro...
LVM Filesystem recovery
1,439,543,725,000
Would there be any problems in copying files on my Linux system with ext4 filesystem to an external drive that is formatted in NTFS? I'm reinstalling my OS and intend to copy these files back to my Linux system once the new Linux OS is up and running.
No, with ntfs-3g you've got read- and write-support for NTFS formated partitions. Just additionally avoid the following characters: \ : * ? " < > | You will maybe loose the permissions... If this is important for you (which I doubt), you have to create a tar-file first and then transfer it to the NTFS-drive. If you ar...
Backup Files on ext4 to external NTFS drive
1,439,543,725,000
[root@xx]# cat -n create_extents.sh 1 #!/bin/bash 2 3 if [ $# -ne 2 ] 4 then 5 echo "$0 [filename] [size in kb]" 6 exit 1 7 fi 8 9 filename=$1 10 size=$2 11 i=0 12 13 while [ $i -lt $size ] 14 do 15 i=`expr $i + 7...
The “Blockcount” value is the i_blocks field of the struct ext2_inode. This is the value that is returned to the stat syscall in the st_blocks field. For historical reasons, the unit of that field is 512-byte blocks — this was the filesystem block size on early Unix filesystems, but now it's just an arbitrary unit. Yo...
ext4, why 70k file takes 88 blocks
1,439,543,725,000
I have a Debian box with additional ( it is not a system disk ) 1.5Tb sata hdd (wd caviar green). There is only one partition on the whole disk. Disk is used for backups from remote system (with rsnapshot, backup update runs every 4 hours) and rtorrent for some files. So disk is permanently in use. Everything was perf...
additionally I discovered some messages in dmesg like: [2429573.624923] ata6.00: status: { DRDY ERR } [2429573.624945] ata6.00: error: { UNC } [2429573.632900] ata6.00: configured for UDMA/133 [2429573.632942] ata6: EH complete [2429576.564846] ata6.00: exception Emask 0x0 SAct 0x1 SErr 0x0 action 0x0 [2429576.564885]...
A lot of errors on ext4, however smart doesn't show any errors
1,439,543,725,000
How do I accomplish setting up project quota for my live root folder being ext4 on Ubuntu 18.04? Documentation specific to project quota on the ext4 filesystem is basically non-existent and I tried this: Installed Quota with apt install quota -y Put prjquota into /etc/fstab for the root / and rebooted, filesystem got...
I was told running tune2fs -O project -Q prjquota /dev/sdaX is absolutely essential to enable Project Quota on a device. So I searched for a solution that does not require switching off or using a live-cd as this requires too much time and does not always work well in my experience with my VPS provider. And I also hop...
Project Quota on a live root EXT4 filesystem without live-cd
1,439,543,725,000
I have an ext4 img file containing an Android system partition files. I mount it by using sudo mount -t ext4 -o loop,rw system.img system When I'm done editing the files and umount the file, I notice that the resulting image is significantly larger than the content it has. I checked with GParted, and it is indeed tru...
You can use resize2fs -M system.img to shrink your filesystem to the minimum size. Note that this does not shrink the image file directly. You would need to use truncate to shrink the image file to the new filesystem size (carefully, so you don't chop data off the end).
Automatically shrink an ext4 IMG file
1,439,543,725,000
Ubuntu 17.04; ext4 filesystem on 4TB WD green SATA [WDC WD40EZRX-22SPEB0] Mount (on startup, from fstab) failed with bad superblock. fsck reported / inode damaged, but repaired it. 99% of files restored (the few that are lost are available in backup). Repaired volume mounts and operates normally. Looking at the SMAR...
According to the SMART readings, the disk seems fine at the moment. The exciting ones for disk sectors are these 5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0 197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 0 198 Offline_Uncorrectable 0x003...
ext4 : bad block fixed, but is this disk dying?
1,439,543,725,000
I had some bad sectors on my ext4 partition and using hdparm --write-sector I managed to reallocate them. However, I ended up in state where in one folder I have folder that has no inode assigned. ``` ls -li /path/ ? d?????????? ? ? ? ? ? folder ``` I am unable to delete this folder now. I tr...
I'd suggest forcing a fsck: sudo touch /forcefsck and then reboot. But before you do that, make sure you have backups — especially now since you can still access the contents of your filesystem. debugfs does support LVM-backed filesystems, it simply uses whatever block device you give it (or even a file). Presumably o...
Delete file with missing inode number
1,439,543,725,000
I have a pretty basic system running Ubuntu 16.04 (this question is not specific to Ubuntu, but rather ext4 partitions), 1 HDD, running a few partitions: sda1 - EXT4 - 100G - / sda2 - EXT4 - 723.5G - /home sda3 - NTFS - 100G - (windows) sda5 - SWAP - 8G Whenever I try to access one of 3-4 files in a specific dir...
Finally found the answer from somebody else on another site, just zeroed the inodes and rechecked the system, that was all! debugfs -w /dev/sda2 :clri &lt1415> :clri &lt1416> :clri &lt1417> :q fsck -y /dev/sda2 To anybody else with this issue, I found my bad inodes using find on the bad mount, then checked dmesg for...
Partition Errors and Remounts Read-Only when Accessing Specific File
1,439,543,725,000
I always thought "clean" is a synonym of does not need journal recovery. However that does not seem to be the case $ sudo file -s /dev/sdc4 /dev/sdc4: Linux rev 1.0 ext4 filesystem data, UUID=117ce600-a129-446b-8859-1e20ad8fe823, volume name "platform" (needs journal recovery) (extents) (large files) (huge files) $ su...
The filesystem was unmounted incorrectly. The "clean" at the end of the output of "fsck -n" is misleading. It does not mean recovery is not needed. It just means that if you would have reached that point, without -n, the filesystem would have been clean. How to reproduce: sh-4.3# dd if=/dev/zero of=/tmp/test.fs bs=1M...
ext4: Can a clean filesystem need journal recovery?
1,439,543,725,000
I'm trying to create a graph of the distribution of file sizes on my ext4 system. I'm trying to write a script to scrape this information from my computer somehow. I don't care where the files are stored in the directory structure, only how much space each takes up. I know file sizes are stored in the inode metadata, ...
If you want a C API, you're going to end up with GNU nftw, the GNU file tree walk. DON'T fool yourself into using plain old ftw, you will get inaccurate data. You'll need to write a "per file" function that uses the struct stat that nftw passes into the "per file" function. You can have the "per file" function put f...
Fastest way to get list of all file sizes
1,439,543,725,000
For benchmark and testing purposes I need to be able to allocate a file at a specific offset from the start of the partition. When I create a new file normally, its blocks are placed wherever the file system decides, but I want to control that. In other words, I want to manually pick which blocks are assigned to a fil...
I have managed to find a way to do this. It uses a python script which first uses debugfs to find the necesssary number of blocks (including indirect blocks) that the file will need. It then manually writes the indirect blocks to the disk, and invokes debugfs again to mark the blocks as used and to update the file's i...
Allocate file at a specific offset in ext3/4
1,439,543,725,000
I just read about the "inline data" feature in EXT4, and more specifically about that answer on how to enable it. What are the reasons why this feature isn't enabled by default in EXT4 ? I guess it's to keep the FS compatible with older kernels, that didn't support this feature yet. Are there other reasons ? If I know...
Answering my own question, basically just developing Stéphane Chazelas' comment : As Theodore Ts'o (maintainer of ext4) explained in an e-mail dating back to 2019: There are some known issues with with the inline_data feature (...). (...) But yeah, there is a good reason why it's not a default-enabled feature. It al...
Are there downsides to enabling the "inline data" feature of EXT4?
1,439,543,725,000
I just read this discussion between Linus Torvalds and (among others) Milan Broz, one of dm-crypt's maintainers. I am intrigued by the the following part of the discussion : Linus Torvalds: I thought the people who used hidden ("deniable") things didn't actually ever use the outer filesystem at all, exactly so that t...
There are probably a few ways to do this with reasonable safety, with potentially different approaches if starting with a new outer volume or an existing one. Probably the best way to do this would be with the debugfs setb command on the unmounted outer filesystem device to mark range(s) of blocks that belong to the i...
How to refresh decoy data on a plausible deniability dm-crypt scheme?
1,439,543,725,000
Is it possible to completely disable sparse file support in an ext4 file system? The purpose is to avoid disk fragmentation. Bonus "no-points" if the solution allows the file system to allocate the files quickly, without filling the file with zeroes (or whatever). What I want is to be able to tell applications to crea...
There’s no option to disable sparse file support in ext4, but ext4 (and the Linux kernel in general) support features which would allow you to implement a workaround without writing a new file system driver (or adapting the ext4 driver). I think what could work is to implement a shared library shim, which you would lo...
Disable sparse file support on ext4
1,439,543,725,000
I have a 128 GB Micro SD Card that I formatted as ext4 and used in a Chromebook for an Ubuntu Chroot Environment. I used it for quite some time that way. At some point, I either deleted everything off of it or formatted it using the Chromebook's simple formatting system. After this, I stuck it in a GoPro Hero Session,...
Running testdisk on the ddrescue image as per the instructions in this guide, I was able to recover all files. The initial quickscan did not detect anything useful, but after the quickscan, a deepscan option is available. Deepscan detected three partition file systems- ext4, exFAT, exFAT ext4 was labeled Linux. I di...
SD Card Recovery without data loss or corruption
1,439,543,725,000
Sometimes I have an error ext4 and my disk becomes read-only. I can fix it with a reboot and fcsk /dev/sda2 but it keeps coming back... Here are some dmesg : [ 3160.692730] perf: interrupt took too long (2509 > 2500), lowering kernel.perf_event_max_sample_rate to 79500 ...
Can you check your disk for bad sectors or bad blocks? you can use badblocks or smartctl command to check in linux, I think bad disk is only reason for your issue.
Ext4 Error and disk remounted read-only
1,439,543,725,000
The problem that I am having is the extremely long time that fsck is taking. I have thoroughly made searches on Google, but I could not find anything that would resolve the problem. The command that I am running is sudo fsck.ext4 -vc /dev/sdb1. I have a 200GB SATA hard drive which has some bad sectors. It is SMART-com...
SMART doesn't remap sectors, it just detects and logs errors. Bad sectors are remapped automatically when written to. You can do this with dd or hdparm --write-sector. If your drive cannot remap the sector because it has run out of reserve sectors then you should be one step before panic. Remapping them in the file sy...
Extremely long time for an ext4 fsck
1,439,543,725,000
I've several partitions with ext4. Now, I would want if it makes sense to use tune2fs with flags -c0 (max-mount-counts) and -i0 (interval-between-checks) in the partitions with a journal file-system since it needs less checks?
Generally speaking... yes, it does make sense. Though you might want to run tune2fs -l /dev/sdXY | egrep "Maxim|Check" to see how those flags are set as it all depends on the version of e2fsprogs used to create the filesystems and/or distribution specific patches applied to e2fsprogs. You might already have MAX_MNT_C...
To use -c0 -i0 in file-systems with journal
1,439,543,725,000
I am trying to understand what I did wrong with the following mount command. Take the following file from here: http://elinux.org/CI20_Distros#Debian_8_2016-02-02_Beta Simply download the img file from here. Then I verified the md5sum is correct per the upstream page: $ md5sum nand_2016_06_02.img 3ad5e53c7ee89322ff8...
Once you have extracted the filesystem you are interested in (using dd), simply adapt the file size (967424*4096=3962568704): $ truncate -s 3962568704 trunc.img And then simply: $ sudo mount -o loop trunc.img /tmp/img/ $ sudo find /tmp/img/ /tmp/img/ /tmp/img/u-boot-spl.bin /tmp/img/u-boot.img /tmp/img/root.ubifs.9 /...
bad geometry: block count 967424 exceeds size of device (415232 blocks)
1,431,331,661,000
I have a single hard drive. I want to use a filesystem that will give me less storage space, but as a tradeoff, give me checksums or any other method to help preserve data integrity. It is my understanding that something like ext4 or xfs will not do this, and thus you can suffer from silent data corruption, aka bitrot...
You could use either ZFS or btrfs. Both of them are copy-on-write filesystems with error detection (and correction too, if there's sufficient redundancy to repair the original data - e.g. mirror drives or RAID-Z), transparent compression, snapshots, etc. ZFS allows you to set the copies attribute on a dataset to keep ...
Filesystem with checksums?
1,431,331,661,000
a@b:~$ sudo growpart -v /dev/xvda 1 update-partition set to true resizing 1 on /dev/xvda using resize_sfdisk_dos 6291456000 sectors of 512. total size=3221225472000 bytes WARN: disk is larger than 2TB. additional space will go unused. ## sfdisk --unit=S --dump /dev/xvda label: dos label-id: 0x965243d6 device: /dev/xvd...
Your drive is formatted as MBR. For drives larger than 2TB, they need to be partitioned as GPT as MBR is limited to 2TB regardless of the OS.
Cannot extend partition beyond 2TB on AWS Ubuntu
1,431,331,661,000
I have heard if you don't make partitions in linux, it is so hard to recover the data. And if you make few partitions it would be easy to recover the data. for example if you make /par1 /part2 /part3 it is better for recovery. But now some of my friends tell me that /home/user/{all data here} has no difference with ma...
To illustrate the question in a simple and efficient manner, consider two scenarios: You install your favourite linux distribution on entire disk i.e. without any partitions: Suppose your system is crashed because operating system is unable to access some sectors and unable to boot. You lost some chunk of data due to...
Why creating partitions in linux is a good solution for easy recovery?
1,431,331,661,000
The drive is currently in NTFS. After running chkdsk for hours, I have found the locations of bad sectors (below). I want to reformat the disk in EXT4. I have heard that EXT4 has some sort of metadata to mark bad sectors, and there is a utility for that, but I do not want to run the test for hours again. Can I just di...
You can use the "badblocks" command together with e2fsck to specify a list of bad disk blocks to the filesystem. As others have commented, that is not great, because that means your disk is on the verge of increasing failure. Also, because this is normally handled at the drive level today, this badblocks code is rarel...
Manually telling EXT4 about bad sectors?
1,431,331,661,000
using dumpe2fs on some ext4 partition, I get in the initial data, that the first inode is #11. However, if I ls -i on this disk root partition, I get that it's inode number is #2 (as expected). So... What is this “first partition” reported by dumpe2fs ?
#11 is the first "non-special" inode, that can be used for the first regularly created file or directory (usually used for lost+found). The number of that inode is saved in the filesystem superblock (s_first_ino), so technically it doesn't need to be #11, but mke2fs always sets it that way. Most of the inodes from #0 ...
what is this “first inode” reported by dumpe2fs?
1,431,331,661,000
I'd like to format a 12 TB HDD (not SSD) with EXT4, in order to store large video files (each file being at least 1 GiB in size). I am working with an x86-64 (a.k.a. x64 or amd64) processor. There's of course the -T largefile4 option of mkfs.ext4, but are there other optimizations that can be done ? In particular, I w...
The very document you linked says (emphasis mine): At the moment, the default size of a block is 4KiB, which is a commonly supported page size on most MMU-capable hardware. This is fortunate, as ext4 code is not prepared to handle the case where the block size exceeds the page size. Out of well-known processor archi...
EXT4 for very large (>1GB) files : increase block size, use block clusters, or both?
1,431,331,661,000
I created an ext4 partition on Ubuntu 18.04.4 LTS in order to transfer a large amount of data to a production server. The server is running CentOS 6.10 with kernel 2.6.32. The Ext4 Howto states that "Ext4 was released as a functionally complete and stable filesystem in Linux 2.6.28" so I assumed I was going to be able...
First try running sudo e2fsck -f -v -C 0 -t /dev/sdd1 An e2fsck run may be required to complete the removal of the feature. If it still doesn't help, try removing and recreating the journal: sudo /home/user/bin/tune2fs -O '^has_journal,^64bit' /dev/sdd1 sudo /home/user/bin/resize2fs -s /dev/sdd1 sudo /home/user/bin/tu...
How do I mount an ext4 partition created on a recent system, on a ten-year-old 2010 CentOS system?
1,431,331,661,000
I wonder if there are ways to copy or restore crtime (creation time) for inodes/files/directories in Linux in 2020. I've accidentally deleted a folder while I still have a full disk backup, but neither cp -a, nor rsync can restore/copy files/directories crtimes. I have found a way to achieve it using debugfs but it's ...
I've actually solved it on my own. You never know what you can do till you try :-) It must be safe to run even when all the filesystems are mounted read-write. #! /bin/bash dsk_src=/dev/sdc4 # source disk with original timestamps mnt_src=/mnt/sdc4 # source disk mounted at this path dsk_dst=/dev/sda4 # destination dis...
Copying or restoring crtime for files/directories on ext4fs filesystem
1,431,331,661,000
I have added user_xattr in ext4 but when I remount it doesn't show xattr & I installed attr & attr_dev # <file system> <mount point> <type> <options> <dump> <pass> /dev/mapper/Anonymous--vg-root / ext4\040remount,user_xattr errors=remount-ro 0 1`
User extended attributes are supported by default on Ext4, you don’t need to do anything to enable them. To verify this, run cd touch xattr-test setfattr -n user.test -v "hello" xattr-test getfattr xattr-test This should show that the extended attribute was successfully stored.
how to enable xattr support in Debian 9 (Stretch)
1,431,331,661,000
I'm going to move journal to another partition, but I don't know how to correctly caculate the size needed for journal? I'm running ext4 file system with 15GB capacity.
$ man mkfs.ext4 The size of the journal must be at least 1024 filesystem blocks (i.e., 1MB if using 1k blocks, 4MB if using 4k blocks, etc.) and may be no more than 102,400 filesystem blocks. I think the default size is 128MB but not sure, that might be dated. Anyways I don't think moving journal to another partiti...
Keep ext4 journal on another system, how much space would be necessary?
1,431,331,661,000
TLDR; In EXT4 terminology, are "block groups" and "extents" the same thing ? [EDIT] The suggested What do "extents" feature do in ext4 filesystem in linux? discussion doesn't answer that question. While it explains clearly what "extents" are, it doesn't talk about "block groups", and whether it's the same thing or not...
The ext4 block groups are how ext4 is managing block allocation. There is a bitmap to manage the allocated/freed blocks for every group. In archaic terminology this is a "cylinder group", but it has been a very long time since this related to a cylinder on a physical disk. In XFS this is an Allocation Group (AG). An e...
In EXT4, are "extent" and "block group" the same thing?
1,431,331,661,000
I am a Unix wanderer. I just noticed that symlinks don't have data blocks allocated to them, I think the inode of the symlink file stores the filename which the symlink refers to, is this actually the case? $ stat sdb File: sdb -> /dev/sdb Size: 8 Blocks: 0 IO Block: 4096 symbolic link De...
ext4 stores the target of a symbolic link inside the inode, if the target is less than 60 bytes long. Longer targets will be stored in a data block.
Why symbolic links have no data blocks allocated to them in ext4fs?
1,431,331,661,000
I'm trying to use setfattr, but always get Operation not supported In my home directory, I'm doing the following: touch delete.me setfattr -n naomi -v washere delete.me This returns setfattr: delete.me: Operation not supported. My home directory is ext4 and delete.me definitely exists. I'm on Fedora 25. Any idea why ...
You can't just use any name. You need to select a namespace. For arbitrary attribute name, you'd need to use the user namespace: setfattr -n user.naomi -v washere delete.me (see man 5 attr for details). For ext4, the ext_attr feature must be enabled (on by default). Check with: sudo debugfs -R stats /dev/block/device...
Cannot set file attribute
1,431,331,661,000
I want to mount my Windows NTFS share C:\ to Linux ext4 file system, so I can see the file system tree as part of my Linux file system and transfer my files. PS. I am using rhel6.
As @Hauke Laging says, it will not become ext4, but you could mount it to /mnt/winshare or some other place, using Samba. A tutorial for RHE is here. Both ways (linux to windows, and vice versa) are described. BTW: this seems to be a similar question.
How to mount remote file system
1,431,331,661,000
The filesystem is ext4, the machine hasn't been rebooted in years and we don't want to do that now either. We used to have a folder with millions of small (2-3kb of size) files. This almost broke the system so we fixed the code that was generating so many files and wrote a crontask that erased all the files within th...
This is a known problem with file systems in the Ext family; see Why directory with large amounts of entries does not shrink in size after entries are removed? for details. The only way to fix this is to re-create the directory. First, rename the existing directory (this will avoid problems with processes attempting t...
Listing directory takes forever on a folder that used to have millions of files [duplicate]
1,431,331,661,000
In the Linux kernel source, the block numbers in an on-disk inode struct are 32-bit. Why? Surely Linux can support more than 2^32 blocks...
The interpretation of the array inode.i_block is different in Ext4 compared to previous on-disk filesystem formats. In Ext4, when the inode has the EXT4_EXTENT_FL set in i_flags this array stores the root of the extent tree and up to four extent descriptors (struct ext4_extent or struct ext4_extent_idx). You will noti...
32-bit block addresses in ext4 inode struct
1,431,331,661,000
There is a troublemaking empty file (md5sums of kernel 4.19.1) left on my ubuntu system, with has strange owner/group/date/attributes How to fix or workaround this defect file? $ uname -a Linux olly-ryzen-pc1 4.20.10-042010-generic #201902150516 SMP Fri Feb 15 10:19:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux stat $...
As fsck does not find anything wrong, you may need to use debugfs to clear the inode. Note that I last used debugfs years ago, so take care! Read the manpage first to see what's possible with this tool. Boot from a rescue medium, and run debugfs /dev/sda2 You can try to use debugfs's rm command to remove the file: rm...
Error when move or delete file on ext4 in dpkg info directory
1,431,331,661,000
I am trying to find the association between block groups and superblocks in an ext4 filesystem I was unable to find much of documentation online, except this link that hints that Because of the importance of the superblock and because damage to it (for example, from physical damage to the magnetic recording medium on...
Here's what the official documentation has to say about that: If the sparse_super feature flag is set, redundant copies of the superblock and group descriptors are kept only in the groups whose group number is either 0 or a power of 3, 5, or 7. If the flag is not set, redundant copies are kept in all groups. T...
Superblock replicas in ext4
1,431,331,661,000
I am using GParted (0.28.1, Fedora 25) to format a external drive and noticed that the command displayed is: mkfs.ext4 -F -O ^64bit -L "INSTALL" /dev/sdd1 When making disks in the past from command line I have just used mkfs.ext4 DEVICE which seemed to work well for various architectures. However the above includes ...
The default options for mke2fs including those for ext4 can be found in /etc/mke2fs.conf. They could be different depending on the distro you're using. I'd take a look at that file on any distro you're curious about to see if the -O ^64bit param would be necessary. According to the man page the '^' is indeed the prefi...
What does this mkfs.ext4 operand mean?
1,431,331,661,000
The ext4 file system usually uses 4 KiB blocks. In this way when you write a small file, and it's size is less that 4 KiB, you will see the difference in any file manager. There are usually two values: size of the file and size on disk. The fist one has the right value, and the other is multiplication of the 4 KiB. In...
The list of blocks that make up the file has to be stored somewhere. Typically there's a little space in the inode, but if there are too many blocks to fit in the inode, the filesystem allocates indirect blocks to store the address of the blocks, in addition to the blocks that contain file data. At least for ext2/ext3...
Why is the difference in file size and it's size on disk bigger than 4 KiB?
1,431,331,661,000
My task is to store a list of JSONs on disk (without using any database) and I have these options: Store them in a single, large file. Store them in separate files, keyed by their IDs. Personally I prefer the second option since it allows direct addressing any JSON by their ID without ever having to touch any other ...
Having 1 million files in a single directory would slow things down, but so would parsing an aggregate JSON with 1 million entries. Your best bet is indeed to use hashed directories, but you probably want to go two levels deep rather than just one. Namely, put 0123456789.json in root/0/01/0123456789.json, and 987654...
What are the consequences of having many files in a directory in an ext4 filesystem?
1,431,331,661,000
In order to store attachments, a /path/to/atts/ directory will have numerous child-directories (product IDs) created (from 1 to ~10,000 or maybe more in the future), and in each of this subdir, 1 to ~10 attachment files will be created. In /path/to/atts/ 1 ├── file1.1 ├── file1.2 └── file1.3 2 └── file2.1...
You can read about the hash tree index used for directories here. A linear array of directory entries isn't great for performance, so a new feature was added to ext3 to provide a faster (but peculiar) balanced tree keyed off a hash of the directory entry name.
'cd' complexity on ext4
1,431,331,661,000
I have a directory called Pages of 2.2 million HTML files (about 80 GB) on an Ubuntu server. I compressed it with 7-Zip using this command: 7z a -mx=9 Pages.7z Pages It took around 5-6 hours to compress (seems excessive). Compressed size is about 2.3 GB. I then downloaded it to my main computer (Ubuntu, Intel® Xeon® ...
I finally figured out the actual answer when I read the wikipedia entry for XZ (https://en.wikipedia.org/wiki/Xz): One can think of xz as a stripped-down version of the 7-Zip program. xz has its own file format rather than the .7z format used by 7-Zip (which lacks support for Unix-like file system metadata[2]). ...
7-Zip slows down over time on Ubuntu but not Windows
1,431,331,661,000
I have a few TB of media files that never changes and that I need to store safely. Since it's a personal business it's overkill to set up a disk server et cetera, so I use the simple solution of storing the files on harddrives at two different locations. Then, at intervals of a few years, I rewrite the drives to refre...
Short answer: Ext4 is the standard file system on most Linux distribution. It works, it is safe, and as @Marco said: If ext4 works for you, just keep using it Choosing a file system It depends on what are your objectives. For a total compatibility across systems, you may choose FAT32 (do not blame me - I think it'...
What should I consider when choosing a filesystem for a personal disk archive / cold storage?
1,431,331,661,000
I've reinstall windows 7 on it's asignated partition and, as usually, it override the MBR with it's own stuff and, thus, it was not possible to boot to my ubuntu 12.04 partition. I followed the step int this tutorial and everything went good. When booting on my ubuntu 12.04 system after that, I got an error message te...
You don't seem to have a separate home partition. /dev/sda3 is an extended partition (hence the "Étendue" in fdisk -l), you will not be able to mount it and it will not contain your /home. Unless you have a 2nd hard disk, it appears you deleted your /home partition while installing Windows. The only partitions in sda...
Unable to mount /home/ partition after reinstalling grub after reinstalling windows 7
1,431,331,661,000
To be able to test out of disk situations I tried to set up a file-based size-limited file system like this: $ dd if=/dev/zero of=file.fs bs=1MiB count=1 $ mkfs.ext4 file.fs $ udisksctl loop-setup -f file.fs Mapped file file.fs as /dev/loop1. $ udisksctl mount --options rw -b /dev/loop1 Mounted /dev/loop1 at /medi...
Yeah, that's kind of mean :) But you can work around: mkfs.ext4 takes a -d directory/ option with which you can specify a directory containing an initial content for the file system; if you already know which directories you'll later want to populate, that would be a good place to start. mkfs.xfs supports -p protofile...
Create writable file system using udisksctl
1,431,331,661,000
Reading the man page of chattr, I came across the I flag for Indexed Directory. Upon investigation it turned out that this refers to HTree indexed directories, as described by this paper. It says that hashed tree provided a similar performance to BTrees, but are way simpler to implement. After running lsattr in the h...
In any modern ext3/ext4 filesystem, all directories larger than a single filesystem block (typically 4KB) will be indexed. This happens automatically when the directory grows beyond the first block. There isn't any particular way to "create" an htree directory, beyond adding more entries than can fit into one block (d...
HTree Indexed Directory
1,431,331,661,000
I want to backup my home directory to an external SSD drive using rsync. I'm on Arch Linux. My home is ext4 (251G), the SSD is NTFS-3G mounted as fuseblk (512G). The exact rsync invocation is: rsync -aSh --info=progress2 --delete --exclude=/me/.cache /home/me /run/media/me/Samsung_T5/ Eventually, it fails with this b...
You might look at duplicity and its gui deja-dup. It does incremental backups using tar files, optionally encrypted, optionally to a remote server. It uses librsync and its rolling-checksum algorithm so that each incremental archive holds only the changed parts of files. The home page says it handles Unix permissions,...
rsync doubles the size when copied from ext4 to NTFS-3G
1,431,331,661,000
I have an ext4 volume that is 3.6T. According to df, the USED is less than SIZE with about 100GB free. However AVAIL shows 0. If I run gparted it shows the real amount of free space (100GB). If I try to write any files, I get the error message: No space left on device The only thing I can think of is that I use rs...
What you're looking at is the reserved space and the file system overhead for ext4. Reserved space is standard 5% on any ext4 FS and is reserved for the root user only! FS overhead consists of: the inode table at format time the journal ( usually 128 MB ) resize inodes. So basically: the OS is still running, use...
Showing 0 (zero) disk space available even though there is free space
1,431,331,661,000
I have 2 physically identical disks. Each with 1 partition: | Disk | FS | Size | Comment | |----------+------+----------+----------------------------------| | /dev/sdb | NTFS | 468.8 GB | Partition created long | | | | | ago with Partition magic, Win ...
Cylinder/head/sector addressing is horrendously obsolete, but some old disk tools still use it by default, and Linux fdisk supports it in emulation. The CHS values it's giving do not refer to any physical reality of the disk, but are guesses based on (I'd guess) the current partition table. They can probably be safel...
Comparing 2 partitions on identical disks
1,431,331,661,000
I'm curious, what is the smallest size a file can really be on Linux? (Assuming Ext3 fs, so why not ext4 fs as well). Sure you can write a file that only contains one byte, or maybe even less; but surely that'll allocates a minimum, and reasonable amount of data for convenience. So what is the minimum allocation / blo...
The smallest possible allocation size for a file in ext3/ext4 is 0 (none at all) because of inline data: files with sizes smaller than 60 bytes can be stores completely inside the inode itself. Of course, every file, whether it's a regular file, symlink, directory (which can contain data), or character device or block...
Smallest file block size (ext 3, 4)
1,431,331,661,000
After a breaker trip a Raspberry Pi of mine started to halt boot with kernel panic (same message as here). This is a Raspberry Pi running Raspbian, so it runs from a SD card, from a main ext4 partition, which I've tried repairing on my PC with: sudo e2fsck -f -y -v /dev/sdx2 However, this eventually fails with some w...
I had a quick glance through the e2fsck source, and it seems to me there are places where the "Memory allocation failed" error can occur for reasons that might not really be memory allocation errors. The error string is defined in [src]/lib/ext2fs/ext2_err.et.in in relation to the constant EXT2_ET_NO_MEMORY. This can...
After crash, e2fsck fails with weirdly high block numbers/sizes
1,348,735,162,000
I just read this article about the virtually non-existent disk fragmentation on *nix filesystems. It was mentioned that due to the way ext handles writing data to the disks, fragmentation may only begin manifesting on hard drives that are at least 80%, where the free space between the files starts to run out. On how t...
What you have read is true. File systems become fragmented over time - as you write more of your epic screenplay, or add to your music collection, or upload more photos, etc, so free space runs low and the system has to split files up to fit on the disk. In the process described in the excerpt you posted, the final st...
How to fix a fragmented ext disk - myth or truth?
1,348,735,162,000
I tried to install Arch Linux to an USB key. Things are kind of wobbly (it assumes the system has exactly one drive inside, for example) but everything installed just fine. Until I rebooted. Booting 'Arch Linux' root (hd1,1) Filesystem type unknown, partition type 0x7 kernel /boot/vmlinuz26 root=/dev/dsb2 ro Erro...
The first thing to check in this situation is if the disk you're trying to boot from is the right one. The ordering of disks can depend on many factors: In Grub1, you only get access to two hard disks. This is a limitation of the BIOS interface. Which two hard disks you actually get depends on your BIOS settings (loo...
Arch Linux fails to boot from a USB key (cannot mount selected partition)
1,348,735,162,000
I'm trying to understand e4crypt and fscrypt, and also how they differ. But it is hard to find documentation on e4crypt other than the command line tool man page and some old tutorials. Is there any documentation on how the kernel side of things work? I'm mainly interested in the higher level stuff: what is stored whe...
Native filesystem encryption is supported since Linux-4.1 The kernel level is nowadays implemented in the fs/crypto directory of the kernel source tree and commonly referred as fscrypt. e4crypt, part of the e2fsprogs package, is the initial userspace tool that relies on the native ext4 filesystem encryption. It was (s...
Is there any e4crypt kernel side documentation?
1,348,735,162,000
I used the following alias to back up my root directory on Ubuntu 22.04 LTS to an external flash drive alias backup='sudo rsync -aAXHS --info=progress2 --delete --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*", "/USBDrive", "/lost+found"} / /USBDrive && notify-send -t 10000 "Backup complete...
The backup command was missing --numeric-ids but since you're only copying locally it probably doesn't matter. To restore the backup you swap the source and destination arguments. Remember the --dry-run option while testing. You can choose to restore just your home directory. Ensure once the copy is complete that the ...
Restore Rsync Backup Of System On Any Linux Distribution
1,348,735,162,000
I've got an Ubuntu 20 virtual machine running in qemu that uses a qcow2 disk file with another qcow2 disk file as backing store. The VM was built from a recent Canonical-distributed cloud image with cloud-init. As soon as I start it up, its disk file starts getting bigger and bigger at a rate of about a gigabyte ever...
This is the ext4 lazy_itable_init thread that is zeroing out the inode tables after mount, instead of doing it as part of mke2fs. In e2fsprogs commit v1.46.4-25-gbd2e72c5c552 a patch was landed (mke2fs: Add extended option for prezeroed storage devices) to add the -E assume_storage_prezeroed option so that you can te...
How can I stop my Linux virtual machine from writing data to empty disk blocks?
1,348,735,162,000
I have a folder /stuff that is owned by root:stuff with setgid set so all new folders' have group set to stuff. I want it so: New files have rw-rw----: User: read and write Group: read and write Other: none New folders have rwxrwx---: User: read, write, and execute Group: read, write, and execute Other: none I...
There is no way to differentiate between files and directories using setfacl only. Instead you can workaround the issue with using inotify-tools to detect new created files/dirs, then apply the correct ACLs for each one recursively: 1- You have to install inotify-tools package first. 2- Recover the default /stuff dire...
How do I set different default permissions for files vs folders using setfacl?
1,348,735,162,000
I was experimenting with encryption on an ext4 filesystem and I encrypted a file (using fscrypt) which was set to be immutable (via chattr +i). I have now lost the encryption key and uninstalled fscrypt. I would like to delete the file, but when I try to delete it, I get the following error: # rm foo rm: cannot remove...
With the filesystem unmounted, you should be able to use debugfs -w -R "rm path_to_file" /dev/sda1 to delete the file.
How do I delete an immutable encrypted file?
1,348,735,162,000
Today I have bought a new Toshiba 1TB Canvio Ready USB 3.0 Portable External Hard Drive (Black). The specifications page of the portable hard drive says, it has been formated to NTFS file system and can be re-formatted to HFS+ file system for full Mac compatibility. File system NTFS (MS Windows) * The drive can...
Sure. The only reason that only NTFS and HFS+ were mentioned was because that's what the vast majority of people purchasing their product are going to use. This isn't OS-specific, but I would strongly recommend that you always make sure to properly unmount the drive before you disconnect the USB cable. USB drives aren...
Is it okay to format my Toshiba Canvio Ready Portable Hard Drive to "ext4"?
1,348,735,162,000
We have Beaglbone black based custom board with 256MB RAM and 4GB eMMC. We have script to flash software on the board. Script erases gpt partition table using following commands #Delete primary gpt (first 17KiB) dd if=/dev/zero of=/dev/mmcblk0 bs=1024 count=17 #Delete secondary gpt (last 17KiB) dd if=/dev/zero of=/dev...
Thanks to @frostschutz, his suggestion worked for. Just for completeness I am adding that as an answer, Using following commands did the trick for me. wipefs -a /dev/mmcblk0p[0-9]* wipefs -a /dev/mmcblk0 First command deleted filesystem information from each partitions. second command deleted partition table.
How to erase gpt partition table and how to make old partition forget mount information
1,348,735,162,000
Fragmentation seems to create a lot of unnecessary seeks when traversing a directory tree on a HDD: # stat -c %F 00 01 02 directory directory directory # filefrag -v 00 01 02 Filesystem type is: ef53 File size of 00 is 12288 (3 blocks of 4096 bytes) ext: logical_offset: physical_offset: length: expected...
Since there does not seem to be any online defragmentation tool for directory indices and even the offline defragmenters don't seem to help I had to resort to rebuilding the directory tree recursively. I've written a small tool (defrag-dirs) for that purpose. Alas, that approach requires the application using the dire...
How to atomically defragment ext4 directories
1,348,735,162,000
I would like to convert my raid6 mdadm into encrypted LUKS. Right now raid6 consists of "/dev/sdX1" which are raid partitions. /dev/md0 doesn't have a partition - it is pure ext4 FS. Is it safe to reencrypt (cryptsetup-reencrypt /dev/md0)? Will LUKS add some specific header which could cause data loss/FS corrupt? Or i...
A volume is called a "LUKS volume" because it has a LUKS header. Thus if you convert a non-LUKS volume into a LUKS volume then you do get an additional header and do lose data space. The LUKS header can be on a differenct device (--header) but I do not know whether cryptsetup-reencrypt supports that. But most probably...
Is it safe to reencrypt unencrypted mdadm array with LUKS?
1,348,735,162,000
I have a script that mounts /dev/sdc1 to /home. I do not know the state of /dev/sdc1 in advance, it could possibly be "dirty". Do I need to run fsck.ext4 before mounting the filesystem, or has mount some checks that will prevent a "dirty" filesystem to be mounted an possibly corrupting data? Or even better, is there ...
There used to be an option to check ext2 filesystems at mount time, but that is no longer supported. Nowadays boot scripts check filesystems before mounting them, and your scripts should do so too. Mounting a filesystem does still check things to make sure it's safe to mount the filesystem; but it won't fix anything (...
do I need fsck.ext4 before mounting a filesystem?