When i do the "df" command in my machine I can see the following:
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 491520 127240 364280 26% /
I want to create another tmpfs. How should i do it?
I am using flash which contains my bootloader, kernel and rootfs. At which stage of booting should I make the changes so that another tmpfs is created.
You could add a line to /etc/fstab:
none /mnt/mytmp tmpfs defaults 0 0
Related
root#mongo_node_1:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 42G 0 42G 0% /dev
tmpfs 8.3G 1.3M 8.3G 1% /run
/dev/sda2 2.9T 2.9T 0 100% /
tmpfs 42G 0 42G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 42G 0 42G 0% /sys/fs/cgroup
/dev/loop0 87M 87M 0 100% /snap/core/4917
/dev/loop1 90M 90M 0 100% /snap/core/8268
tmpfs 8.3G 0 8.3G 0% /run/user/0
root#mongo_node_1:~# e
I have deleted the 20G mongod log file, but the disk is still insufficient, so I can only delete some databases or tables to free the disk.
However, mongod cannot be started now. Can I delete the database or table without starting mongod?
By the way, there are three database nodes. Only the shard1 server disk is full.
If your shard has more then one replicaSet member you can delete the entire data folder content and the member will init sync its content from other members , if it is only one member and running under the default wiredTiger storage engine it is best to not delete files from the data folder since you could easily corrupt the content. It is best if you shutdwon the member , extend the partition offline and start the member again ...
I accidentally removed a wrong folder using rm -rf, every tool I've tried tell me either I have no hard disk or that the filesystem is not found.
When I type df I get :
Filesystem Size Used Avail Use% Mounted on
/dev/simfs 25G 7.6G 18G 31% /
none 256M 12K 256M 1% /dev
But if I type debugfs -w /dev/simfs I get the error :
/dev/simfs: No such file or directory while opening filesystem
I'm using a VPS hosted by OVH, what's wrong with that filesystem ?
I have the same scenario/issue. To take the conversation a step further, I've also tried
tune2fs -l /dev/simfs
which outputs
tune2fs 1.42.9 (4-Feb-2014)
tune2fs: No such file or directory while trying to open /dev/simfs
Couldn't find valid filesystem superblock.
You'll get the same invalid superblock error if you try to scan an entire disk eg /dev/sda
What is the limit of EXT4, what i found is only EXT3, and other links only suppositions and not a real number?
Can you please provide me: max number per directory, max size?
Follow-up on #Curt's answer. The creation parameters can determine the number of inodes, and that's what can limit you in the end. df's -i switch gives you inode info.
(env)somesone#somewhere:/$ df -iT
Filesystem Type Inodes IUsed IFree IUse% Mounted on
/dev/root ext4 25149440 612277 24537163 3% /
devtmpfs devtmpfs 3085602 1418 3084184 1% /dev
none tmpfs 3086068 2 3086066 1% /sys/fs/cgroup
none tmpfs 3086068 858 3085210 1% /run
none tmpfs 3086068 1 3086067 1% /run/lock
none tmpfs 3086068 1 3086067 1% /run/shm
none tmpfs 3086068 4 3086064 1% /run/user
This is a Linode box BTW, so it's virtualized environment. The number I look at is 24537163, that's how many free inodes the root fs has. Note, that more than 10K files in a directory can cause difficulties for many tools. 100K can be really hard on utilities.
See also: https://serverfault.com/questions/104986/what-is-the-maximum-number-of-files-a-file-system-can-contain
It depends upon the MKFS parameters used during the filesystem creation. Different Linux flavors have different defaults, so it's really impossible to answer your question definitively.
I have partition structure like :
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda6 51606140 16939248 34142692 34% /
/dev/sda5 495844 72969 397275 16% /boot
/dev/sda7 113022648 57515608 49765728 50% /home
/dev/sda8 113022648 57515608 49765728 4% /mnt
while parsing directories content using readdir() - how to find out which file resides on what device?
readdir() invoked from root directory and parses the file name and prints its size.
like from device : /dev/sda6 and list the filenames under that partition.
When it reads contents from /home - it should display reading content from /dev/sda7 and list filenames
Please let me know,if you need more details/info
you can just do
df <file_name>
that will give you the device and partition for the particuar file
There is a st_dev member in struct stat, it should uniquely identify one partition.
Example in bash:
stat ~/.vimrc
File: `/home2//leonard/.vimrc' -> `local-priv/vimrc'
Size: 16 Blocks: 0 IO Block: 4096 symbolic link
Device: 802h/2050d Inode: 6818899 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1024/ leonard) Gid: ( 1024/ leonard)
Access: 2012-06-22 16:36:45.341371003 +0300
Modify: 2012-06-22 16:36:45.341371003 +0300
Change: 2012-06-22 16:36:45.341371003 +0300
The stat utility does no additional magic. Here is strace -vvv output:
lstat64("/home2//leonard/.vimrc", {st_dev=makedev(8, 2), st_ino=6818899, st_mode=S_IFLNK|0777, st_nlink=1, st_uid=1024, st_gid=1024, st_blksize=4096, st_blocks=0, st_size=16, st_atime=2012/06/22-16:36:45, st_mtime=2012/06/22-16:36:45, st_ctime=2012/06/22-16:36:45}) = 0
0x0802 is major 8(sd) partition 2, so /dev/sda2
In order to map this to actual partitions you can iterate /proc/mounts and stat all the devices (first column). The contents of /proc/mounts is just like the output of mount(1) except it comes directly from the kernel. Some distros symlink /etc/mtab to /proc/mounts.
Or you can parse /proc/partitions:
$ cat /proc/partitions
major minor #blocks name
8 0 976762584 sda
8 1 3998720 sda1
8 2 972762112 sda2
Of course /dev/sda might not actually exist, the device could be using a long udev name like /dev/disk/by-uuid/c4181217-a753-4cf3-b61d-190ee3981a3f. Major/Minor numbers should be a reliable unique identifier of a partition.
For example, a sample df command output is
Filesystem MB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 512.00 322.96 37% 4842 7% /
/dev/hd2 4096.00 717.96 83% 68173 29% /usr
/dev/hd9var 1024.00 670.96 35% 6385 4% /var
/dev/hd3 5120.00 0.39 100% 158 10% /tmp
Now if I specify something like /tmp/dummy.txt I should be able to get /dev/hd3 or just hd3.
EDIT : Thanks torek for the answer. But probing the /proc would become very tedious. Can anyone suggest me some system calls which can do the same internally?
df `pwd`
...Super simple, works, and also tells you how much space is there...
[stackuser#rhel62 ~]$ pwd
/home/stackuser
[stackuser#rhel62 ~]$ df `pwd`
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda7 250056240 196130640 41223408 83% /
[stackuser#rhel62 ~]$ cd isos
[stackuser#rhel62 isos]$ pwd
/home/stackuser/isos
[stackuser#rhel62 isos]$ df `pwd`
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda5 103216920 90417960 11750704 89% /mnt/sda5
[stackuser#rhel62 isos]$ df $(pwd)
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda5 103216920 90417960 11750704 89% /mnt/sda5
...which is the likely cause of the mount point query in the first place.
Note those are backticks, and the alternate (modern) method, providing further control over slashes and expansion is df $(pwd). Tested and traverses symlinks correctly on bash, dash, busybox, zsh. Note that tcsh won't like the $(...), so stick to the older backtick style in csh-variants.
There are also extra switches in pwd and df for further enjoyment.
On Linux, use /proc/<pid>/mounts to access a list of mount points for a given pid, or /proc/self/mounts (with the literal word self) to refer to yourself. (cat the /proc/self/mount* files to see what they look like.)
Then, for each file system, you can do a statfs() call and compare f_fsid the f_fsid field to the result from an earlier statfs() on the path in question. Once the fsid's match, you have found the appropriate mounted file system and can use the other data from /proc/self/mounts. (However, see statfs(2) for restrictions on doing anything useful with f_fsid.)