grub error 15: file not found - linux

I have a vm(on vmware fully running). But i want to do some modification and put all file system to single partition /.
In my current VM i have /, /var, /tmp, /boot partition.
Action performed:
Attached new hard disk, formatted and created two partition (one for / and another for swap)
made / as active partition for root.
copied all the files from original hard disk to new harddisk.
made changes in /etc/fstab and run grub-install.
detached new harddisk and created new VM using this harddisk.
Now when I am starting VM, I got
"Error 15: File not found"

Just got answer while hitting and trying . This error is due to /etc/grub/grub.conf file. When we have /boot partition we don't need to give whole path for kernel for example :
Kernel /< kernel version>
but when we have single root partition only, means no /boot partition we need to provide complete path, example:
Kernel /boot/< kernel version>
And same for initrd line.
It worked for me.

Related

No space left on device- Ubuntu Issues

I am getting this error "OSError: [Errno 28] No space left on device" when I am writing files in a directory. I am downloading images programmatically from different sources and creating directories according to day wise. Its working well on windows though.
While checking inodes I got this
I tried different solution like deleting the deleting the junk file and tmp folder but still no success.
What could be the issue?
inodes don't directly correlate with disk usage. Better use df -h to actually see, if your drive is full.
But as you get the error: Yep, it's full. Up to the brim.
You probably have some data some where that uses all that precious storage. Check your home directory with du -hs * | sort -h. This can take a moment, but it will show you the size of all files and directories in the current workdir (and sort it too).
Also directories to check would be /opt, /var and /tmp. Don't randomly delete stuff in /var though, if you don't know what you are doing.
I've listed /tmp here too, because you don't have listed it as a mount of the type tmpfs. You should fix that probably.

Mount a partition (linux) in a already existent folder

How can mount a partition in an already existent folder of my linux tree? What happens with the already created file and can I move these to the new disk in the process?
I am using a Ubuntu 16.04 with an SSD and HD disk, I would like to mount the ~/Documents or $HOME in the HD moving the files already created and free the SSD to the main files of the operation system (in this moment all the files are in the SSD and the HD is only formatted as Ext4).
The moment you mount the new parition on top off ~/Documents you cant access the Files anymore, but there are some Options:
Mount the HD somewhere else first and move the files. (code is just an example, it is not supposed to be executable as is)
mount /dev/disks/by-lable/foo /media/temporary
mv /home/hildogjr/Documents/* /media/temporary
umount /media/temporary
mount /dev/disks/by-lable/foo /home/hildogjr/Documents
Use a bindmount, to still be able to access the files after mounting:
mount --bind /home/hildogjr/Documents /media/Documents_on_ssd
mount /dev/disks/by-lable/foo /home/hildogjr/Documents
mv /media/Douments_on_ssd/* /home/hildogjr/Documents
umount /media/Documents_on_ssd
Use a unionfs, and move the files over Time. man unionfs:
It first tries to access the file on the top branch and if the file
does not exist there, it continues on lower level branches. If the
user tries to modify a file on a lower level read-only branch the file
is copied to to a higher level read-write branch if the copy-on-write
(cow) mode was enabled.

du linux command size greater than df

I am using Digi embedded linux module which is having 8MB flash and 16MB RAM.
My partition table is as below:
SO, I got 4.4MB for rootfs. And 2MB for UserFS.
When I run ‘df -ah’, I get following output.
However, when I run ‘du -sh’ on root, I have 4M in /lib and 3M in /usr. Both are under root. However, the root is only 4.4M.
I have checked for symbolic link and can confirm that the files are physically present on /lib and /usr.
I deleted some of the library files(netsnmp) under /lib, which was close to 2M, but the available size on /dev/root only increased by ~390K(from 408K to 792K).
This suggests that the /lib/libnetsnmp* were stored somewhere else. I am not sure where those files were saved. Any ideas?
Also, please note that the rootfs image size is 4M. And this is shown correctly in df -ah command on /dev/root filesystem.
JFFS2 has transparent compression built in if I recall correctly. Executables compress pretty well.
if the file is in use. you can't delete it really.
you can use lsof | grep deleted to find them.
Probably it is due to the existence of hard-links in the root filesystem. Each hard-link will be shown as a normal file, but all hard-links will point to the same inode, so physically there is only one copy of the file in the hard-disk. You can see a good definition of soft-link and hard-link in this link.
EDIT: You can search for hard-links using this command (taken from this answer):
find . -samefile /path/to/file

linux /tmp folder + how to know if files will deleted after reboot or after some time

I have Linux red-hat machine
And I not sure what the concept about the directory /tmp
How to know if the files under /tmp will deleted after reboot or maybe will deleted after some time
Which file/configuration in my Linux machine responsible for that ?
And if it possible to change the rules there?
remark my crontab is empty - no deleted Job there
This is specified in the File Hierarchy Standard and Linux Standard Base
/tmp/ is often tmpfs mounted, and on systems where it is not the case, the boot init scripts should (and usually do) clean it.
So files under /tmp/ do not survive a reboot. Put them elsewhere (perhaps /var/tmp/) if you want them to survive a reboot.
In the FHS §2.3:
The /tmp directory must be made available for programs that require temporary files.
Programs must not assume that any files or directories in /tmp are preserved between invocations of the program.
Tip Rationale
IEEE standard P1003.2 (POSIX, part 2) makes requirements that are similar to the above section.
Although data stored in /tmp may be deleted in a site-specific manner, it is recommended that files and directories located in /tmp be deleted whenever the system is booted.
So unless your systems are very badly misconfigured, you should presume that /tmp/ is cleaned at least at reboot time. BTW, some sysadmins are setting a crontab entry to clean old files (e.g. weekly clean older than 2 weeks file). See also tmpfiles.d(5), TMPDIR, mkstemp(3), crontab(5), POSIX tmpfile & tmpnam
Just check the output of
mount
If you find that /tmp is of tmpfs type, then it will be deleted. tmpfs is an in-memory filesystem.
But never count on /tmp to persist.
The default setting that tells your system to clear /tmp at reboot is held in the /etc/default/rcS file.
The value we’ll look at is TMPTIME.The current value of TMPTIME=0 says delete files at reboot despite the age of the file.Changing this value to a different (positive) number will change the number of days a file can survive in /tmp.
Code:
TMPTIME=7
This setting would allow files to stay in /tmp until they are a week old, and then delete them on the next reboot.
A negative number (
TMPTIME=-1
) tells the system to never delete anything in /tmp.
systemctl cat systemd-tmpfiles-clean.timer
# /lib/systemd/system/systemd-tmpfiles-clean.timer
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Daily Cleanup of Temporary Directories
Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
ConditionPathExists=!/etc/initrd-release
[Timer]
OnBootSec=15min
OnUnitActiveSec=1d
The [Timer] section specifies what service to trigger (systemd-tmpfiles-clean.timer) and when to trigger it. In this case, the option OnBootSec specifies a monotonic timer that triggers the service 5 minutes after the system boot, while the option OnUnitActiveSec triggers the service 24 hours after the service has been activated (that is, the timer will trigger the service once a day).

Is there a way to wait until root filesystem is mounted?

I have a statically linked code(not a module) in kernel that should launch kernel thread after root file system is mounted. The problem is I don't know how to do this without modifying prepare_namespace() kernel function. I thought it's possible to do via initcalls but
they're executed before kernel takes care about rootfs.
Does anyone know the best way to do this?
UPDATE [1]: #BenVoigit suggested the following solution in comments:
Seems like you should open /proc/mounts and poll_wait on it. See the source for `mounts_poll'
UPDATE [2]: I looked at RSBAC patches, RSBAC modifies prepare_namespace() function to make some actions after filesystem is mounted. It seems to be the easiest way.
Well, current Linux images are too big to fit the PC boot sector. Modern bootloaders like grub will mount an small filesystem in RAM before the real one.
To understand what is happening under the hood, you can open the disk image located under /boot. For example, in Ubuntu:
mkdir test
cd test
zcat /boot/initrd.img-2.6.35-24-generic > image.cpio
cpio -i < image.cpio
vim init
In the end, it's just a bunch of shell scripts - the simplicity is almost poetic.

Resources