Tag Info

Hot answers tagged

42

When trying to gain insight into what sort of magic is happening behind the scenes your best friend is strace. Learning to operate this tool is one of the best things you can do to get a better appreciation for what crazy magic is happening behind the scenes. $ strace -s 200 -m strace.log cat /proc/cpuinfo ... read(3, "processor\t: 0\nvendor_id\t: ...


38

Whenever you read a file under /proc, this invokes some code in the kernel which computes the text to read as the file content. The fact that the content is generated on the fly explains why almost all files have their time reported as now and their size reported as 0 — here you should read 0 as “don't know”. Unlike usual filesystems, the filesystem which is ...


15

You can use the command archivemount to mount archives such as .tar.gz. $ ls files.tgz mnt/ $ archivemount files.tgz mnt $ ls mnt file1 file2 [... Perform desired read/write operations on the archive via mnt/ ...] $ umount mnt [... Any changes are saved to the archive ...] See the man page for archivemount for more info. It's often times not ...


15

If you need Linux, you need a filesystem. (I mean Linux the operating system here, rather than Linux the OS kernel. I'll get to that narrower interpretation below.) Your observation about device drivers loading at boot before the filesystem exists is a red herring. You can load a driver without having a filesystem. What you can't do is fd = ...


12

There is no direct, clean (reliable) way to do that. But under appropriate circumstances this can be possible (or at least probable). The problem is that there are two hard links but just one file. Change, modification and (maybe) creation time are stored for files (inodes) only but not for directory entries (the hard links). Thus the information you want ...


10

If you rely on the last modification time of the directories and you don't have knowledge of how and when those directories are changed, relying on mtime is going to lead you to be wrong some percentage of the time. The issue here is that the file is represented in the filesystem by an inode, not by a directory entry. The directory entry (filename) points ...


8

The answer given by @slm is very comprehensive, but I think a simpler explanation might come from a change in perspective. In day-to-day usage we can think of files as physical things, ie. chunks of data stored on some device. This makes files like /proc/cpuinfo very mysterious and confusing. However, it all makes perfect sense if we think of files as an ...


8

I think this question is (quite reasonably) misguided as to what a hard link really is. I think however the most correct direct answer is 'They both are'. Unix file systems normally store actual file contents and data in i-nodes, these do not have a path whatsoever, paths then have a many to one relationship to these i-nodes. Take as an analogy a person who ...


8

Well, in short: a warm cache is useful whereas a cold cache is not. In fact, a cold cache can be dangerous to use. You see, the whole point of a cache is to keep oft-accessed data accessible. For instance a DNS cache will store locally the results of the name-resolutions that you've requested recently, and, when those same resolutions are requested again ...


7

I wrote an answer to to a related question that details how the concept of a file is core to the way Unix works, and since you can't have a file without some kind of filesystem, it means that you definitely need one. However it is possible to survive without a filesystem that exists on any persistent storage media. Your initramfs image can be compiled into ...


6

You're either talking about a FUSE filesystem (filesystem in userspace - Linus calls them toys) or a custom compiled kernel OR squashfs. Squash is not exactly as you describe - you cannot simply mount a tarball for instance - not with the kernel supported VFS, anyway - but you can certainly mksquash any number of files or directories and mount the resulting ...


6

Full disk encryption is usually done using the dm-crypt Device Mapper target, with a nested LVM (Logical Volume Manager) inside. So to reset your password you'll have to Unlock/open the crypto container; this is done using cryptsetup Activate the logical volumes; vgchange is used for this. Usually you won't need to care about this but could let the ...


5

As of GNU coreutils 8.21 (changelog), df has a --output option. Using sed to trim the header: df -h --output=size,used,avail,pcent | sed 1d


5

Actually, technically speaking you don't need a file system. The default behaviour is to have a file system from which to boot. (e.g. /sbin/init is launched from there). However, if you like you can look at what happens in do_basic_setup() in linux-source/init/main.c. By the time that routine gets called, the kernel and CPU0 are ready for real work. You can ...


4

In general, a cold cache is one that is not well populated (yet). So if your cache is cold, information must be retrieved using the, presumably, slower method. This is typically the case shortly after an application starts up or the types of queries change significantly. Conversely a warm cache is well populated with information that you have recently or ...


4

As others have pointed out, this is because hexdump -x treats the files as containing 2-byte words. On little endian systems (almost all desktops are), this means the bytes will be swapped before they are displayed. This means that the byte values are printed in pairs and that the order of these bytes are swapped. Since you have an odd number of bytes, ...


3

There are a number of things that could be done here. Note that none of the actually use hard links since they can only point to a full file. Using the btrfs filesystem opens up some vary useful possibilities here. Note that btrfs is currently (most recent version is v3.13) still experimental. However, its COW (copy-on-write) ability is perfect for this kind ...


3

There is no difference betweem tmpfs and shm. tmpfs is the new name for shm. shm stands for SHaredMemory. See: Linux tmpfs. The main reason tmpfs is even used today is this comment in my /etc/fstab on my gentoo box. BTW Chromium won't build with the line missing: # glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for # POSIX shared memory ...


3

Whether you may encounter permission problems with external media depends on whether all your machines share the same password and group database (the username-UID and group-GID mappings). Ownership on an ext4 filesystem is stored as UID and GID numbers. A more appropriate but somewhat experimental filesystem you could try is UDF. It has the benefit of ...


3

According to the ext4 manual this is the total number of bytes written to the filesystem since it was created. You can also query this value in kB by examing this file in the sysfs: /sys/fs/ext4/<DEVICE>/lifetime_write_kbytes


3

Assuming that entries returned by readdir are not sorted by inode number reading files in inode order reduces the number of seek operations the content of most files are in the initial 8k allocation (an ext4 optimization) which also should yield less seek operations you can try to speed up copying via copying files in inode order. That means using ...


2

If you are having trouble understanding endianess, here's another illustration. #include <stdio.h> #include <inttypes.h> #include <unistd.h> int main (void) { uint16_t x = 1; write(1, &x, 2); x = 2; write(1, &x, 2); return 0; } This is C code which will write out 2 16-bit values, 1 and 2. When we think ...


2

According to the guidelines of the Linux Filesystem Hierarchy: /var/cache Is intended for cached data from applications. Such data is locally generated as a result of time-consuming I/O or calculation. This data can generally be regenerated or be restored. Unlike /var/spool, files here can be deleted without data loss. This data remains ...


2

Is there some way, either general or specific, that I can verify that none of the files on my filesystem were damaged? Without copies of the files to refer to, I think this is impossible. Have you looked in /lost+found? If anything was corrupted into pieces, those pieces will be left there by fsck. I have seen this happen before too, and as far as I ...


2

findmnt -Do SIZE,USED,AVAIL,USE% Here's my output: SIZE USED AVAIL USE% 11.8G 0 11.8G 0% 11.8G 63.1M 11.7G 1% 11.8G 920K 11.8G 0% 11.8G 0 11.8G 0% 12G 8.9G 2.7G 74% 11.8G 410.6M 11.4G 3% 3G 584.4M 2.4G 19% 3G 584.4M 2.4G 19% 2.4G 4K 2.4G 0% 0 0 0 - So if you're not already using findmnt ...


2

Assuming filesystems and mount points don't contain blank characters, try: df -hP | awk 'NR>1 { $1=$6="" ; print }' | column -t df -hP lists the filesystem statistics without linebreaks for long filesystem names. awk 'NR>1 { ... }' restricts the given action to 2nd and following lines to skip df's header line... The awk-action { $1=$6="" ; print } ...


2

The crux of the answer given by several others above is that the every file name is a hard link to a file. There is no real original, just possibly a first one. Think of a directory as a table that lists file names and inode-numbers. Every hard link, including the first one, is an entry in a directory which assigns a "file name" to the inode number, so ...


2

Let's have a brief look onto the function: int blkid_superblocks_get_name(size_t idx, const char **name, int *usage) { if (idx < ARRAY_SIZE(idinfos)) { if (name) *name = idinfos[idx]->name; if (usage) *usage = idinfos[idx]->usage; return 0; } return -1; } name is a pointer to a char * ...


2

No it will not move the entire extended partition nor make the space contigious. Although in theory the extended partition could just be recreated with the same logical partitions, that would mean that the entries stay in place (with some zero size first, logical partition), or you would have to rearange the Extended partition information. Both that would ...


2

rootfs mounted on / is an in-memory filesystem which typically only contains the tools needed to mount the “real” root filesystem and is emptied after this is done. The initial content of the rootfs are loaded from an initramfs image stored inside or next to the kernel binary and loaded by the bootloader. The root filesystem on flash is ubi0:root. This is a ...



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