Tag Info

Hot answers tagged

16

Here's an article on How To Geek about how ext2/ext3 allocates files on the disk. And they also have an article asking "Do you really need to defrag?" On why FAT becomes fragmented: "When you save a file to a FAT file system, [the file is saved] as close to the start of the disk as possible. When you save a second file, [the file is saved] right after ...


10

Fragmentation is always a concern no matter what the filesystem. Ext3/Ext2, though, have minimized the problem to the point where most admins just operate as if it's not a concern. This is minimized by use of competent the I/O scheduler and by the filesystem leaving trailing space after each file to accommodate growing. On top of that, additional fragments ...


7

It's because you're in the directory that you're mounting into. So you're still referencing the original directory's contents through the original directory. You can see this exact same effect when you are cd into a directory that is then deleted. $ pwd /home/saml/dirtodel $ rmdir ../dirtodel $ pwd /home/saml/dirtodel How can that be? I'm still inside ...


6

TL;DR: Put supporting files in /usr/local/lib/my_app_name and main script in /usr/local/bin. Of course you will get many suggestions for different places to put things, as there is not much standardization for this kind of thing. I prefer to put files of this type in /usr/local/my_app_name/ or /opt/local/my_app_name, depending on where you install ...


5

I dont think lsblk and file -s is that ugly, but there is an alternate way. You can use blkid instead. By default, blkid without any arguments will list the known block devices, and a little bit of information about them, including the filesystem type. The format is also in key=value pair format (by default), which makes it easy to dump into a script. This ...


4

Answering your questions, one by one: Why don't you have to defrag a Linux system? Because it's using the ext2/ext3 file system or because it's Linux? Because ext2/3/4 have a different approach about the files and folders, so they barely get fragmented. Others have already answered about it, and you can read more details here That's relevant, ...


4

As mentioned in Why does a software package run just fine even when it is being upgraded?, the lock is placed on inode not on filename. When you load and execute a binary, the the file is marked as busy - which is why you get ETXTBSY (file busy) error when you try to write to it. Now, for shared libraries it is slightly different: the libraries get memory ...


4

No. Directory entries pointing to inodes are one-way links. The inodes do not point back to the directory entries. In order to find a complete list of directory entries that point to an inode, you need to traverse the filesystem until you have found enough directory entries to account for the inode's link count.


4

Writing to the device (/dev/sdX) instead of to a file system (/mount/point) deletes the file system on the device anyway so there's no need for mkfs before. There is also no need to erase data in the non-written area. It is not visible anyway. Linux file systems can without problems be smaller than the block device they live on.


3

Given the vast array of file systems out there, I'm certain that exceptions exist, but traditionally, the inode had an array of disk block numbers in it. For example, in /usr/include/linux/ext3_fs.h, I see a definition of struct ext3_inode. Inside struct ext3_inode, I see a member i_block[EXT3_N_BLOCKS];/* Pointers to blocks */ Different file systems have ...


3

blkid -d /dev/VOLUME /dev/VOLUME: UUID="97da23eb-542e-4f5f-9cc8-5108ee6a1f2e" TYPE="ext3" But with external disks: Mind the difference between disks and partitions: /dev/sdx vs. /dev/sdx1. It may be useful to check with fdisk -l /dev/sdx or cat /proc/partitions first.


3

What I do is to store tarballs on the USB drive (formatted as VFAT). I'm wary of reformatting USB drives, they are build/optimized for VFAT so to level wear, and I'm afraid it will die much sooner with other filesystems. Besides, formatting another way will make it useless for ThatOtherSystem...


3

When you want to modify a file, you have two options, each with its benefits and drawbacks. You can overwrite the file in place. This does not use any extra space, and conserves the hard links, permissions and any other attribute beyond the content of the existing file. The major drawback of doing this is that if anything happens while the file is being ...


3

What can go wrong, is that you can lose files. It depends on the filesystem and how you access it, but in the worst case, you could lose access to all the data on your linux partition, although it would still be possible to recover - albeit difficult and very time consuming - with the proper tools. More likely is that you might just corrupt the file you ...


2

In the end, it's down to the file system drivers within the OS. ext2 and FAT file systems are both methods to record which blocks on disk belong to which file. When not all block of a file are contiguous, the file is called fragmented. But as should be obvious, fragmentation is caused by the block allocation strategy when writing a file, not by how you ...


2

I prefer incron, as its easier to manage. Essentially its a service that leverages inotify and you can setup configurations to take action based on file change operations. Ex: <directory> <file change mask> <command or action> options /var/www/html IN_CREATE /root/scripts/backup.sh You can see a full example here: ...


2

"It's not a bug, it's feature..." It would be quite evil if every unprivileged user could write to every Linux file system just because he feels entitled to. You must explicitely allow him to. After creating a file system only root is allowed to. # You (as root) can either give write write access to everyone: chmod 777 /mount/point # or you give the whole ...


2

At least some distros offer shrinking NTFS partitions during the Linux installation. Of course, this is possible with free space in that partition only. And you should run Windows' check disk tool immediately before. There is always a risk when playing with file system structures and partition tables (you should "try" not to have a power outage then...) but ...


2

You can use cmp for checking if everything was copied fine: $ cmp -n `stat -c '%s' debian-X-netinst.iso` debian-X-netinst.iso /dev/sdX This solution does not explicitly compute the checksum of your /dev/sdX - but you don't need to to that because you have already done this for the source of the comparison (i.e. debian-X-netinst.iso). Doing just a dd ...


2

A rpm upgrade does the same - with running binaries and libraries while nothing crashes. So what is the difference: unlink file write new file with the same name This will NOT replace the file inplace: The inode referring to the in-use-binary is still "busy" until the last object holding it open finishes. The new file will be created with a new ...


1

Just use tar to dump the data and getfacl/setfacl for storing/restoring the ACLs. Even if NTFS supported UNIX permissions you'd have to ensure mapping od user/group IDs and names, which tar does for you automatically (be aware that some - usually rather ancient or non-mainstream - versions of the utility don't store user/group names, only the numerical IDs). ...


1

In general, you're right - if you delete all references to the files (which could be > 0 if the files are hardlinked), the inodes should be freeed up when you delete the files. However, if some process has the file open (like whatever process is writing to the log files), the inodes won't be freed up until that process(es) closes the files. Just as disk ...


1

You can determine the breakdown of your inodes on a given file system using the tune2fs command. You typically call tune2fs with the -l switch and the device you'd like to query, typically /dev/sda1 or /dev/sdb1. For my example I have a RAID device, /dev/md0. Example $ tune2fs -l /dev/md0 | grep -i inode Filesystem features: has_journal ext_attr ...


1

On Unix, a file name can contain any character except '\0' (NUL) and '/' (directory separator). All current Linux/Unix native filessytems have to handle this. Foreign filesystems might have their own restrictions (for example, MS-DOS FAT can have only filenames in the 8+3 format, with exactly one '.', probably ':' and '\' are forbidden too; VFAT presumabably ...


1

If you look in the kernel sources (or a kernel doc package, or on the web), look in Documentation/filesystems, it varies by filesystem. For example, with ext2 an inode number can be translated using info stored in the superblock to a certain offset in the partition—one of the reasons ext2 allocates a fixed number of inodes at mkfs time—which is then read. ...


1

In general rsnapshot is just making use of rsync so it should work fine with backing up a variety of files from file systems such as ext3, ext4, FAT, and NTFS. The comment that you're referring to: Backing up to external usb HDD's works perfectly, but one needs to use a ext3 or similar formatted drive that supports hard links. So no FAT32 or NTFS ...



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