Tag Info

New answers tagged

2

A symlink won't work. A hard link (when possible) won't work either because both files will have the same permissions. But I'd do the following: instead of a link, write a shell script /usr/bin/myscript.py that executes the script itself: #!/bin/sh exec python /path/to/wherever/I/have/put/myscript.py "$@" The "$@" passes any parameters through; if your ...


2

-rw--r--r-- 2 kamix users 5 Nov 17:10 hardfile.txt ^ That's the number of hard links the file has. A "hard link" is actually between two directory entries; they're really the same file. You can tell by looking at the output from stat: stat hardlink.file | grep inode Device: 805h/2053d Inode: 1835019 Links: 2 Notice again the ...


2

A hard linked file has more than one link (the 2 after the permission flags). You can use the stat command to easily extract this information: $ stat --printf '%h\n' hardfile.txt 2 See the manpage for stat (man 1 stat) for information about other values and how to print them.


0

Sorry to write this as an answer, I can't comment yet. I'll be interested to see what the fsck turns up. If you create another hard link to the file, does that hard link have the same problem? At least then you can rule out issues with the file reference...


0

I created an MBR disk with one partition, filled every single byte on that partition with data, created a SHA1 checksum of the whole partition, converted it to GPT as described in the question, created yet another checksum and compared it with the original. They were the same. So my conclusion is this: You can safely convert a disk to GPT without corrupting ...


1

Not really. It's not safe to do an instant power-down in the middle of a disk write. Journalling can help in that situation, but it's still not a good thing to inflict on your HD on a regular basis. Bear in mind that Linux does not write data to disk immediately - the Linux kernel caches filesystem reads and writes to improve performance, no matter which ...


0

None of the following are the real reason for disallowing hard links to directories; each problem is fairly easy to solve: cycles in the tree structure cause difficult traversal multiple parents, so which is the "real" one ? filesystem garbage collection The real reason (as hinted by @Thorbjørn Ravn Andersen) comes when you delete a directory which has ...


0

If you care much about battery life, you should not waste cpu time on compression. For example, just browsing the web would cause your system to spend energy on compressing cached data. If you're having storage space issues, consider using remote storage more often (see samba, sshfs, etc). You may still want to use btrfs for it's other features useful to ...


1

fuse-zip is an option and claims to be faster than the competition. # fuser-zip -r archivetest.zip /mnt archivemount is another: # archivemount -o readonly archivetest.zip /mnt Both will probably need to open the whole archive, therefore won't be particularly quick. Have you considered extracting the ZIP to a HDD or USB-stick beforehand and simply ...


1

You can use fuse-zip to mount zip as read only. 1 -- Install fuse-zip on your system. UBUNTU sudo apt-get install fuse-zip CENTOS/REDHAT/FEDORA yum install fuse-zip 2 -- Run below command to mount zip as read only. fuse-zip -o ro /path/abcd.zip /path/to/mount/directory 3 -- Use below command to unmount directory fusermount -u ...


0

Redhat cluster use a fencing method called fence scsi. The fencing node forbid the other from accessing lun in SAN. however, this still requires some sort of TCP/IP communication between node. I assume that by Because of security there is no any TCP/IP network between two linux server. you meant nodes can't access ILO/iDrac feature to power off ...


2

If you are looking for directories that are using up space, and are not on a different partition, then you want du -hx --max-depth=1 /. The -x tells it not to descend into directories that are on other filesystems ( partitions ). The --max-depth=1 asks to only print a line ( listing the total space for that directory and all subdirectories ) for each ...


1

If I am reading this question correctly, there is a program called tree. This would list all directories in a tree like structure. With it installed, you can do something like: tree -x Where -x Stay on the current file-system only. Ala find -xdev. UPDATE: I have tried tree -P /dev/xvda and it seemed to have shown directories under that filesystem. The -P ...


0

But, how will I know the list of directories under /sda2? There are no directories under /dev/sda2, /dev/sda2 is a partition on the disk (sda is the disk and 2 is the partitions number). But, is there any command or way through which I can also list down their filesystem too? Since you only have one filesystem mounted then they are all on the / ...


1

Sir I33tname gave you the answer. However you should be running separate cron job that checks for nearly full disks. This is an idea how to do that, NOT necessarily a perfect solution for your situation Use cronjob -e to add this (example change names of directories and files): 0,10,20,30,40,50 * * * * /path/to/my/script.sh 2>>/path/to/logfile script.sh ...


1

You should look at the output of dmesg and at the /var/log/syslog to see when this switch is happening and what messages preced it. I have seen this happen with drives that had intermittent access problems, particularly with USB drives that had bad connectors/cables.


0

I got farther in resolving my problem. I came across this: https://www.novell.com/coolsolutions/appnote/19386.html#DiskPermanentlyRemoved And so I plugged a new disk, did: pvcreate --uuid NOskcl-8nOA-PpZg-DCtW-KQgG-doKw-n3J9xd --restorefile VolGroup00_00001-16738001.vg /dev/sdc1 The VolGroup00_00001-16738001.vg being the lvm config before the disk died ...


0

In Fedora 20, the directory you're looking for is in one of the (possibly multiple) /var/tmp/systemd-private-${FOO} folders. I haven't been able to verify that on a RHEL 7 or CentOS 7 system yet, but I strongly suspect it will be in the same /var/tmp/systemd-private-${FOO} area.


44

The correct syntax in bash is the following: rm /tmp/!(lost+found) As @goldilocks wrote in the comments, the original command makes an expansion on the query (it deletes all the files in the /tmp folder, then goes on, and deletes all the files in the current working folder, in your case the home folder). You can try to check if you can recover some of ...


26

The !(lost+found) in your rm command was probably the fatal mistake: 1978 rm -rf /tmp/* !(lost+found) 1979 sudo rm -rf /tmp/* !(lost+found) I don't know exactly bash is doing with that, but this command prints everything in my /tmp and also everything my current directory, which is currently ~: echo /tmp/* !(lost+found)


1

cat /proc/mounts|sort|awk '{print $1 "\011" toupper(substr($4,0,2))}' Produces tab delimited output with mount name and mode.


3

You can optimize the directory using fsck.ext4 -D on an unmounted filesystem: -D Optimize directories in filesystem. This option causes e2fsck to try to optimize all directories, either by reindexing them if the filesystem supports directory indexing, or by sorting and compressing directories for smaller ...


0

When you mount another filesystem on /opt, the previous content of /opt is inaccessible through that path, but it doesn't go away. On Linux, you can make it available by mounting it elsewhere, thanks to mount --bind. mkdir /whole-root mount --bind / /whole-root mv /whole-root/opt/* /opt/ umount /whole-root There is of course an alternate method: mount the ...


0

You can compress data and based on nature of files, this can considerably reduce the disk usage so you can get more data with actual less reads. In your case, compressing binary files, would not reduce storage as much as in case of plain text files but still it help your data located consecutively in disk so reading those shared library files with less ...


0

You probably have NFS mounts, and the NFS server is not responding. Typically if df hangs, then the next unlisted filesystem in order of /proc/mounts (not /etc/mtab!) is the culprit. If this is a frequent occurance then it may be better to mount the NFS filesystem with the soft,intr options, so that you can stop the hanging process with ctrlc.


1

The symptoms are very consistent with a mostly saturated IO system, however having for the most part ruled out IO load from the OS/userspace side, another possibility is the drive running self-tests on itself, which may include reading from all the sectors. This should be queryable/tunable from smartctl (At least one place being smartctl -c for querying). ...


1

Setting a default owner "automatically" would require a directory setuid behaving like setgid. However, while this can be configured on FreeBSD, other UNIX & Linux systems just ignore u+s. In your case however, there might be another solution. What I want is to have a directory that can be shared by adding a group to a user. Anything created in this ...


1

There is a smarter way to do this. It uses a combination of set-gid and default acls. Obviously, you will need an acl enabled file system. Let's assume the directory you want shared is at /var/grpdir and that members of group sharing should be able to access it. chown root:sharing /var/grpdir chmod 2770 /var/grpdir #other can't read or traverse into the ...


0

I have not heard of any way to automatically change a files ownership such that the file owner is changed when the file is moved into a certain directory. The closest thing is the sticky bit, but it seems you have indicated that group ownership is not enough, the actual user ownership has to change. In that case, I think your best bet is the cron job with ...


2

I am not aware of any good way to do this. The technically cleanest way would be a FUSE file system which does that. Of course, a lot of work if nobody has done that yet. Alternatives: Use samba. samba has the force user parameter. You can export a directory locally and mount it locally. Doesn't make accesses faster but may be acceptable as only loop back ...


2

Your question suggests that Debian uses temp files for all writes, which isn't the case. This is simply the default for mp3gain. In version 1.4.3-2, the package maintainer (Stefan Fritsch) decided that as writing to a temp file is much quicker on ReiserFS, then this would be the default on Debian. This was sourced from the patch at ...


1

Changing a file in place is not always that easy. If you add date in the middle of a file, the size will grow and any data after the change has to be written to a new location. If you first write the data in the middle of the file, you have to store the old data in order to move it, and hope not to crash in the middle of that process. It is much easier to ...


2

You should never ever modify a file in place. The only safe ways to write a file are: if you are the first one to create the file (O_EXCL). by writing to a new temporary file and then performing an (atomic) rename(2). by opening the file in append-only mode (O_APPEND). Otherwise, you will lose data all the time, either when your program crashes (don't ...


0

As mentioned in the question: What does size of a directory mean in output of 'ls -l' command? The metadata of the folder is always stored in blocks, so it allocates 4kb even if there is not much data that needs to be stored. -Duplicate Question.


0

After the fact, I don't think there's any intrinsic way to find out about past mount and unmount operations. There may be indirect means, for example if the filesystem driver emits a log message. If you want to tell whether a particular directory is a mount point at a given time (I assume that your filesystem is always mounted at the same location), you can ...


0

There is at least one commercial file system that does a tremendous job making sure that the file-system very nearly cannot be corrupted due to power failures and that the only data you risk loosing is data that was being added as the power went out. The down-side is that it is very expensive, on the up-side they offer great support. Due to the expense, ...


0

Well, you can do it in a bash, if you want so. if ((mount | grep "/mount/point")>/dev/null) then echo "Is mounted"; fi;


1

Not sure what you mean by "what filesystem". If it means what instance of a filesystem, then using df $(pwd) may be your best bet, except when you know that the file you are inspecting actually is a mountpoint on its own, than using mountpoint $(pwd) may be a better idea. If it means what type of filesystem, then use the common Linux utility stat, it only ...


5

I think df . is your best bet. The filesystem usage check is not that expensive (it doesn't have to count any blocks on disk, that information is readily available and stored in memory once the filesystem is mounted). Alternatives like comparing the current path against mount points by using a script would be more expensive.



Top 50 recent answers are included