The /run directory: how to create it at first boot to store runtime data [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I read an article about the /run directory on Linux systems.
http://article.gmane.org/gmane.linux.redhat.fedora.devel/146976
This article states that many Linux distributions have agreed that the /run directory is the only clean solution for early-runtime-dir problem. Previously, they put early runtime data in /dev/.XXX or /var/run. But they are now adopting the /run directory for storing early runtime data.
My question: How do they make this change? To be specific, do they change the code in kernel or boot or initscripts?
Take this article (http://article.gmane.org/gmane.linux.redhat.fedora.devel/146976) for example, what are the possible changes that needed to implement this?

The run directory has no special meaning for the kernel itself be it /run or /var/run. From the kernel's point of view it is just a regular directory. For performance reasons since some time ago it is usually mounted as tmpfs file system. The Fedora distribution creates a symbolic link /var/run pointing to /run for backward compatibility:
mount:
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
ls /var:
lrwxrwxrwx. 1 root root 6 Jun 8 15:33 run -> ../run
So actually all 'old' programs and scripts will work. But as the convention changed the packages are also undergoing the update to reflect this. So, with time the need in the /var/run link will dissappear.
To implement this move of /run the init scripts are changed.

/run is created and mounted (usually as a tmpfs filesystem) by the init system of your Linux distribution. For example systemd or OpenRC. The init system runs before any other program.
The kernel doesn't have anything to do with it.

Related

PLEASE HELP! I mounted the new HDD to existing folder (where another HDD has been mounted), and all files (in other HDD) have disappeared [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 days ago.
Improve this question
I have recently bought a new 8TB HDD (barracuda) and tried to connect and mount the HDD to ubuntu system.
However, I made some mistakes and accidentally mounted the HDD to existing folder, where another HDD has been mounted.
Specifically,
(Before buying new HDD) I had 1 SSD & 1 HDD (will denote as HDD1 from now on), where
SSD: /dev/sda ==> Mounted on /home/{username}/SSD via
mount /dev/sda /home/{username}/SSD
HDD1: /dev/sdc1 ==> Mounted on /home/{username}/HDD1 via
mount /dev/sdc1 /home/{username}/HDD1
After buying new HDD, I have connected the HDD and
tried to do:
HDD2: /dev/sdb1 ==> Mount on /home/{username}/HDD2
what I have actually done
mount /dev/sdb1 /home/{username}
--> Mounted /dev/sdb1 to /home/{username}
After running this comman, all the files in HDD1 and SSD has been removed, and has been overwritten by HDD2's files.
I have read the post where the files are shadowed if mounted over it, but I am keep getting trouble restoring these files, and can't even find the files via
du -sh *
or
df -h
at root.
Are there any chances of this procedure overwriting the files in HDD1 and SSD? Are there any ways to restore back the files? PLEASE HELP!!!!!
WHAT I HAVE TRIED
1.
sudo -i
sudo umount /home/{username}
but
error: target is busy
came up.
So I have killed all the processes running on /home/{username} via
fuser -ck /home/{username}
Now I am completely locked in a state where I can't open /home/{username}/HDD and only terminal is available.
2.
I have tried df -h after doing (at root user, via sudo -i)
and following messages come up.
df: /home/{username}/SSD: Input/output error
df: /home/{username}/HDD1: Input/output error
Filesystem Size Used Avail Use% Mounted on
udev 63G 0 13G 0% /dev
...
/dev/loop14 56M 56M 0 100% /snap/core18/2697
/dev/sdb1 7.3T 3.5T 3.5T 51% /home/{username}

ubuntu 14.04 disk full [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
when i run df -h on my ubuntu 14.04 laptop i see the following:
pdp2907#pdp2907-Satellite-C655:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 933M 4.0K 933M 1% /dev
tmpfs 189M 1.1M 188M 1% /run
dev/mapper/ubuntu--vg-root 228G 215G 1.1G 100% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 943M 11M 933M 2% /run/shm
none 100M 36K 100M 1% /run/user
/dev/sda1 236M 44M 180M 20% /boot
the /dev/mapper/ubuntu--vg-root is full.
how do i correct the problem please.?
thanx for all your support
You need to know what data is on it. So far I assume you have a whole OS in / only. What you can do is, for example, move some content to anoter volume (disk) and either mount it or make a symbolic link. I personally place /usr to a separate volume, and my /opt is a link. Then the root partition does not need to be so huge. But in your case the root has over 200 Gb what seems a bit more than the OS only :). Explore the files over there, perhaps you also find some movies if the user's home directories are also there...
find / -size +100M
The command above might be helpful to search for files over 100 Mb size (normally should not appear in root filesystem)
In order to free up disk space in dev/mapper/ubuntu--vg-root you can remove cached files with the following command:
sudo apt-get clean
You still can free up more space by uninstalling packages that are not required anymore:
sudo apt-get autoremove

File last access time. How to mount root filesystem with atime,norelatime [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I've installed a simple LAMP system based on Debian 7.2.0 (32 bits). On my server I want to know when each of PHP files was used (accessed) by web server. When I check last access times of php files (with command ls -alu), they are wrong.
I've found that it is because of relatime option used for mounting of the root filesystem. I've tried to edit my /etc/fstab and to put norelatime,atime options there but it does not work. My current /etc/fstab is:
UUID=d4bb10f1-1428-4ee4-916c-55e800263c3f / ext4 atime,norelatime,errors=remount-ro 0 1
UUID=6db7a3c7-6ff9-43ac-b959-5175039bb84b none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
After a reboot, when I type mount, I get:
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=127786,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=103240k,mode=755)
/dev/disk/by-uuid/d4bb10f1-1428-4ee4-916c-55e800263c3f on / type ext4 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=352700k)
All the partitions have relatime option. Any help?
http://www.linux-archive.org/fedora-development/120241-why-relatime-immune-remount.html and https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/582799 indicate that this does not work on Fedora or Ubuntu, and presumably the same is true for Debian. To quote from the first linked article:
You have to:
echo 0 > /proc/sys/fs/default_relatime
and then mount/remount with 'atime' and it should work.

Why can't I save a VI file after entering data? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I am new to linux, when I typed "vi FILE1" I was able to open VI editor. I added some data and I want to save the file and I tried :w but it threw me an error.
"file1" E212: Can't open file for writing
Press ENTER or type command to continue
why I am not able to save it?
The directory in which I am creating file has following permissions:
drwxr-xr-x 4 pentaho pentaho 4096 Mar 12 2013 master
I am logging using root user and password.
Output of mount command :
/dev/sda1 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sdb1 on /etl type ext4 (rw)
/dev/sdc1 on /oracle type ext4 (rw)
/dev/sdd1 on /export type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
You can also get this error if the directory you are trying to save to does not exist. Even the root user will get this error.
When you log in linux with your common user, you are logged with the user you created, but you are not superuser (you do not have all permissions). To execute a program with root priviliges (and therefore have all permissions), you have to add the command sudo. So you should run: $> sudo vi FILE1. This will ask you for the password and then you use vi normally
If you are facing issue in vi, try to create directory manually and edit the file. May be you don't have access to create directory/file.

Use of tmpfs on embedded Linux systems

I am going to bring up a new embedded Linux system soon, kernel version 3.2. The main root filesystem needs to be writable as we do software image updates, and we do want to keep the logs under /var/log persisted for analysis after reboots.
One technique I've seen used is to mount /tmp as tmpfs which makes sense, as we don't need anything in /tmp to be maintained across reboots. What other directories in a Linux system will undergo a lot of writes, but do not need to be maintained across reboots? I've seen so far:
/tmp
/var/run
can anyone suggest any other candidates for tmpfs?
Yes,
/tmp
/var/run
And
/var/tmp
too. Yes, /var/tmp is suppose to preserve temporary files between system reboots, but practically, my /var/tmp/ is always empty. It won't hurt to put that in tmpfs -- I've been doing that for more than 10 years and so far so good.
Also, I always put /run/lock in tmpfs and so far so good as well. If you have udev then it will put /dev on devtmpfs. Also my system, automatically put /run and /run/shm in tmpfs. Depending on your system, you may consider doing that as well.
HTH

Resources