access /proc from disk [closed] - linux

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 months ago.
Improve this question
On linux, I know procfs is a pseudo FS and only exist in memory. is there a simple way to access procfs (/proc) from disk by dumping that memory content to disk either through configuration or actively run command?

For the most part there is no "memory content" . The /proc pseudo file system not only does not exist on disk, the majority of it also isn't explicitly instantiated as files in memory. Much of the content is instantiated on-demand from information stored elsewhere in kernel data structures. From the manual:
The proc file system acts as an interface to internal data structures in the kernel. It can be used to obtain information about the system and to change certain kernel parameters at runtime (sysctl).
This is even reflected in the fact the /proc file system reports no actual usage (in contrast to /dev/shm, which is a real file system):
$ df -h /proc /dev/shm
Filesystem Size Used Avail Use% Mounted on
proc 0 0 0 - /proc
tmpfs 20G 336K 20G 1% /dev/shm
So for example, the contents of /proc/$$/status and /proc/$$/stack are constantly changing as a process runs, and the contents of those pseudofiles are only generated on-demand when you open the file.
If you want the contents of these files dumped to disk you can use a cp operation to capture some of it (with sufficient user permission), but dumping it ALL to disk is probably a bad idea and might not even terminate.

Related

Swap memory using [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 8 days ago.
Improve this question
Our system is consuming swap memory even system has avaiable memory. Is that behaviour normal ?
Our system is redhat 8.6.
memory usage figure
Solution for memory usage problem.
The Linux 2.6 kernel introduced a new kernel parameter called swappiness, which allows administrators to customize how Linux swaps.
Swappiness is a property for the Linux kernel that changes the balance between swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100, inclusive. A low value means the kernel will try to avoid swapping as much as possible where a higher value instead will make the kernel aggressively try to use swap space.
Since the linux kernel 5.8 has a swappiness value range of 0 to 200 and a default value of 60. You can change it temporarily (until your next reboot) with the following command
echo 42 > /proc/sys/vm/swappiness
If you want to change it permanently, edit the vm.swappiness parameter in the /etc/sysctl.conf file.
It should be noted that the swappiness number does not imply that 60% of memory will be moved into swap. There is a swap algorithm that determines when and how much data is put into swap.
The following formula is provided by Redhat to determine swap tendency:
swap_tendency = mapped_ratio/2 + distress + vm_swappiness;
You can read more here

Swap data of /dev/sda2 and /dev/sda3 [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 1 year ago.
Improve this question
To begin with ,I would build up the exact context to begin with. The link(cuz am low on reputations) is a screenshot of partitions in my laptop's hard disk.Hard disk filesystem partitions /dev/sda
As it must have been evident from the screenshot itself../dev/sda2 was a pre-existing partitions which has now been formatted into a clean btrfs format; And /dev/sda3 has ParrotOS in it.
Now I wish to make whole of hard disk memory from /dev/sda2 and /dev/sda3 to ParrotOS without losing any iota of any existing data in /dev/sda3...as per the software used here(Gparted) partitions can be extended only if they have empty unallocated space after them, so there is no apparent option here for to directly unallocate /dev/sda2 and put /dev/sda3 in front of it..Or is it?
Can some generous guys help me to atleast aid me to swap everything from /dev/sda3 so that I can unallocate it and can merge them together into a single large chunk of partition.
If sda2 and sda3 are the same size (low-level size, that is... not FS size... you can see that with say fdisk), then you can copy binary content of sda3 into sda2 with something as simple as:
sudo dd if=/dev/sda3 of=/dev/sda2
After that is done, sda2 would be an exact image of sda3. Just make sure to not have the partition of sda3 (or sda2, of course) mounted so that there are no operations going on against it. When that is copied over, you should be able to mount sda2 and see what you have in sda3.... when that is done, you can then remove sda3 so that sda2 can be extended.... this is not risk free, by the way... and some adjustments will need to be made, for example, adjusting /etc/fstab (among other things).

Inode Number Full Ubuntu [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
I have a ubuntu machine with 8Gb of RAM and 250B of Harddisk. I am using this machine as my Jenkins Server for CI , Iam facing inode number full problem from the past few days
I fire command :
df -i
Output:
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda5 18989056 15327782 3661274 81% /
none 989841 11 989830 1% /sys/fs/cgroup
udev 978914 465 978449 1% /dev
tmpfs 989841 480 989361 1% /run
none 989841 3 989838 1% /run/lock
none 989841 8 989833 1% /run/shm
none 989841 39 989802 1% /run/user
Suggest how to resolve this.
The program mkfs.ext4 allows an open -N which sets the number of inodes when making a new file system.
In this case you'd need to backup the entire / file system, boot from a live CD/USB and recreate the filesystem on /dev/sda5. WARNING: This will kill every single file on that drive. You'll probably need to reinstall the operating system onto that partition first because merely restoring a backup of a boot drive will likely not get all the fiddly bits necessary to boot.
If you are running out of inodes, it is likely you are doing something sub-optimal like using the filesystem as a poor-man's database. It is worth looking into why you are exhausting i-nodes, but that's another question.

Does Linux have a page file? [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
I found at several places that Linux uses pages and a paging mechanism but I didn't find anywhere where this file is or how to configure it.
All the information I found is about the Linux swap file / partition. There is a difference between paging and swapping:
Paging moves pages (a small frame which contains a piece of data - usually 4 KB but can vary between different OS's) from main memory to a backbend storage, happens always as a normal function of the operating system.
Swapping moves an entire process to storage and happens when the system is memory stressed or on windows 8 when a new application is hibernating.
Does Linux uses it's swap file / partition for both cases?
If so, how could I see how many page are currently paged out? This information is not there in vmstat, free or swapon commands (or that I fail to see it).
Or is there another file used for paging?
If so, how can I configure it (and watch it's usage)?
Or perhaps Linux does not use paging at all and I was mislead?
I would appreciate if the answers will be specific to red hat enterprise Linux both versions 6 and 7 but also a general answer about all Linux's will be good.
Thanks in advance.
On Linux, the swap partition(s) are used for paging.
Linux does not respond to memory pressure by swapping out whole processes. The virtual memory system does demand paging, page by page. Under extreme memory pressure, one or more processes will be killed by the OOM killer. (There are some useful links to documentation in the first NOTE in man malloc)
There is a line in the top header which shows swap partition usage, but if that is all the information you want, use
swapon -s
man swapon for more information.
The swap partition usage is not the same as the number of unmapped pages. A page might be memory-mapped to a file using the mmap call; since that page has backing store in the file, there is no need to also write it to a swap partition, and the system won't use swap space for that. But swap partition usage is a pretty good indicator.
Also note that Linux (unlike Windows) does not allocate swap space for pages when they are allocated. Instead, it adds the new page to the virtual memory map without any backing store. and allocates the swap space when the page needs to be swapped out. The consequence (as described in the malloc manpage referenced earlier) is that a malloc call may succeed in allocating virtual memory, but a subsequent attempt to use that virtual memory may fail.
Although Linux retains the term 'swap partition' as a historical relic, it actually performs paging. So your expectation is borne out; you were just thrown by the archaic terminology.

List all harddrives in a linux system [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'm having problems to detect which one of my block devices is the hard drive. My system has a cd-rom drive, USB drives, and a single hard drive of unknown vendor/type.
How can I identify the hard drive with a linux command, script, or C application?
sudo lshw -class disk
will show you the available disks in the system
As shuttle87 pointed out, there are several other posts that answer this question. The solution that I prefer is:
root# lsblk -io NAME,TYPE,SIZE,MOUNTPOINT,FSTYPE,MODEL
NAME TYPE SIZE MOUNTPOINT FSTYPE MODEL
sdb disk 2.7T WDC WD30EZRX-00D
`-sdb1 part 2.7T linux_raid_member
`-md0 raid1 2.7T /home xfs
sda disk 1.8T ST2000DL003-9VT1
|-sda1 part 196.1M /boot ext3
|-sda2 part 980.5M [SWAP] swap
|-sda3 part 8.8G / ext3
|-sda4 part 1K
`-sda5 part 1.8T /samba xfs
sdc disk 2.7T WDC WD30EZRX-00D
`-sdc1 part 2.7T linux_raid_member
`-md0 raid1 2.7T /home xfs
sr0 rom 1024M CDRWDVD DH-48C2S
References:
https://unix.stackexchange.com/q/4561
https://askubuntu.com/q/182446
https://serverfault.com/a/5081/109417
If you have a list of the plausible block devices, then the file
/sys/block/[blockdevname]/removable
will contain "1" if the device is removable, "0" if not removable.

Resources