Does setting the read ahead parameter using the blockdev command affects open files and running process?
Example: The default value for read ahead is 256.
Suppose I run the following:
sudo blockdev --setra 8 /dev/sdX
Will this instantly enter in effect and will affect all running processes which have files open in a partition mounted from /dev/sdxn?
If not, what is the minimal for this to enter in effect? Is restarting the processes so that they can open the files again enough or do I need to remount the partition?
Related
My Mac had a kernel security level of 0. Then, I changed the kernel security level to 1.
Here's how I changed it to 1: sysctl kern.securelevel=1
I'd like to change it back to 0 because my hosts file has a system immutable flag on it.
This is the code for that- sudo chflags schg /etc/hosts
I'd like to take away the system immutable flag, and that starts with changing the security level back to 0.
I've tried to boot into single-user mode. I shut down my computer and then held down cmd+S when I rebooted. It shows a black screen and white code scrolling across the screen and then went into the regular user selection field. Then, I put in my password to log in and it showed more white code scrolling across the screen and then it logged me in and everything appears normal.
This is related to this
https://apple.stackexchange.com/questions/282339/protect-hosts-file
It sounds like you are having trouble getting into single user mode. Typically holding command-S after power on should work, but as a work around you can specify single user mode as a boot parameter.
sudo nvram boot-args="-s"
Once you are done, unset the arg(s):
sudo nvram -d boot-args
If you are using file vault, you still need to enter your username and password to unlock the volume, so don't take needing a username as an indication that something is neccesarily wrong.
The setting of the sysctl doesn't affect your /etc/hosts immutability. What does is one of two:
A) Pre MacOS 10.15, "System Integrity Protection" (SIP) adds a "restricted" flag to files in /etc, with /etc/hosts being one of them
B) In early MacOS 10.15 /etc is part of the root filesystem, which is mounted read-only, so /etc/hosts can't be modified. Also, above mentioned SIP prevents you from remounting (mount -o remount,rw /). This has later changed and /etc is redirected to /System/Volumes/Data, but you didn't indicate which version of MacOS you're on.
What to do:
Try 'df /etc/hosts' to see where /etc is mounted.
Try 'ls -lO /etc/hosts'. This will show you an extra column of flags. If you do have schg, it will be there (but it's never on by default, so likely it won't if you didn't have it on).
If you see "restricted", then you need to boot into recovery. That's CMD-R, and then go to Utilties menu, open a terminal, and then either edit whatever needs editing, or (and do this only if you're absolutely fine with repercussions):
i) Either disable SIP for filesystem checks (NOT recommended)
ii) selectively enable /etc/hosts in /System/Library/Sandbox/rootless.conf (which labels all files and causes the setting of the "restricted" flag).
I use UBIFS for rootfs on NAND.
When I edited a file like /etc/rc.local with nano command and saveed it,
"cat /etc/rc.local" shows the editted content, of course.
However after removing power supply (without reboot or poweroff command) and supply power again, the content of /etc/rc.local becomes empty.
I found that written data is not written to NAND straight away in UBIFS and written to cache. (refer: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_empty_file)
I want to sync to NAND straightly after editting.
Only solution I found is fsync, but this should be called in C program and it requires file descripter. Nano command and so on does not give us file descripter. So I can not solve this sync problem.
How can I solve this not syncing to NAND problem?
Are there any command to sync?
Do I have to edit files with C program and use fsync if I want to edit and save a file in UBIFS?
You can use the 'sync' command. the system will flush all the cache to the disk.
When I run the command:
rsync -aviuP /src /trgt
The command seems to be missing some files that are not correct at the target destination. Like a 25gb file on src, being 4gb at the target and corrupt. I run the command 3 times to be safe.
When I start the sync, I have to stop the sync with ctrl+C every now and then as I need the drives to work faster for some other task but I thought the P flag was meant to make that cosher.
Am I missing something here? The problem is happening relatively frequently and I can't seem to find any answers on the web.
Thanks in advance.
Avoid interrupting the sync process. Instead limit the maximum bandwidth used by rsync using the bwlimit option
rsync --bwlimit=1000 -aviuP /src /trgt
In this example the maximum bandwidth used would be limited to roughly 1MB/s (1000KB/s).
Here is what I am trying to do: I need to know whenever a file is read or used by a tool (e.g. compiler). I use ls to get the last accessed time using the following command
ls -l --time=access -u --sort=time --time-style=+%H:%M:%S
or
stat "filename"
But my files access times are not getting updated, I figured its because of caching! please correct me if I am wrong. So my next step was how can I clear the cache, researching it I came across some variations of the following command:
sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
The thing is even after I execute this command my file access time is not updated! My way of testing access time is by opening the file in gEdit or call gcc on my source file.
My setting: Ubunto 12.0.4 running on VMware, which is running on Win 7
Question: what am I missing or doing wrong that my access time is not being updated??
What you're observing is the change in the default mount option starting 2.6.30 in order to bring about filesystem performance improvement.
Quoting from man mount:
relatime
Update inode access times relative to modify or change time.
Access time is only updated if the previous access time was ear‐
lier than the current modify or change time. (Similar to noat‐
ime, but doesn't break mutt or other applications that need to
know if a file has been read since the last time it was modi‐
fied.)
Since Linux 2.6.30, the kernel defaults to the behavior provided
by this option (unless noatime was specified), and the stricta‐
time option is required to obtain traditional semantics. In
addition, since Linux 2.6.30, the file's last access time is
always updated if it is more than 1 day old.
(Also refer to this and this.) You might be looking for the following mount option:
strictatime
Allows to explicitly requesting full atime updates. This makes
it possible for kernel to defaults to relatime or noatime but
still allow userspace to override it. For more details about the
default system mount options see /proc/mounts.
I set the HOME variable in /etc/launchd.conf using the following line: setenv HOME /Users/student
Now the machine wont boot at startup. I tried holding shift at startup but safe mode doesn't seem to be working. I tried holding cmd+s on startup and got into single user mode. I was able to bring up the /etc/launchd.conf file but I can not save/overwrite the existing file due to permission issues.
Is there some way to reset this file from single user mode or other to fix this? I'm open to other approaches as well. I am not a unix/linux power user by any means, fyi :)
Thank you in advance.
I'll give you two options, but first a warning: both of these involve using the command line to undo the damage, and if you do it wrong there's a possibility you'll make it even worse. A backup would've been a good idea, but it's a little late for that (well, actually, there are still ways to do it, but they also involve a risk of getting it wrong...). So whatever your do, be careful.
Option 1: use single-user mode (Command-S at startup). This will leave you running as root, which means you are not subject to normal file permissions; after remounting the startup disk for write access (mount -uw /) you should not get permissions errors. You said this didn't work; the most likely thing is that you mistyped the command (I see this happen a lot -- people either leave out the "/", or the space between "-uw" and "/"). Hint: if the mount command prints anything (other than the prompt for the next command) you typed it wrong. If that still doesn't do it, check the file's flags and metadata with ls -leO# /etc/launchd.conf and report the results.
Option 2: use recovery mode (Command-R at startup). This boots from a small hidden partition with a minimal copy of OS X. In recovery mode, pull down the Utilities menu and choose Terminal. This is actually a fair bit like single-user mode, except that the normal startup disk won't be /, it'll be /Volumes/Macintosh HD (or whatever it's named), and it'll already be mounted for write access. Since there's (probably) a space in the volume name, you'll have to quote or escape it:
$ cd "/Volumes/Macintosh HD"
$ mv launchd.conf launchd.conf-disabled