Xmobar DiskU not get the root partition information in Slackware 15 - haskell

I trying to show the root partition usage in the Xmobar (with XMonad), but not working!! Without any verbose or error message.
I don't know if the problem is the way as the Slackware loading the root partition or its way of the xmobar working.
Explaining the context:
The disk have three partitions: "swap", "/" and "/home"
/dev/sda1 is the /
/dev/sda2 is the swap
/dev/sda3 is the /home
in the Slackware, the system creates a virtual mount point to "/dev/sda1" calling it the "/dev/root" with mount point to "/"
In the Xmobar (.xmobarrc file), any of the options below not work:
- Run DiskU [ ( "/", "<size>" ) ] [] 20
- Run DiskU [ ( "root", "<size>" ) ] [] 20
- Run DiskU [ ( "/dev/root", "<size>" ) ] [] 20
- Run DiskU [ ( "sda1", "<size>" ) ] [] 20
- Run DiskU [ ( "/dev/sda1", "<size>" ) ] [] 20
and calling
- Run DiskU [ ( "/", "<size>" ), ("/home", "<size>") ] [] 20
where "/home" is the "/dev/sda3" partition, works fine to get the information about "/home"
Reading Xmobar sources, i see that the list of the available partition is read from "/etc/mtab". In my case, the "/etc/mtab" have de list of partitions below:
/dev/root / ext4 rw,relatime 0 0
...
/dev/sda3 /home ext4 rw,relatime 0 0
but i don't get the DiskU function works...
Any idea is welcome to solve this problem...
thanks in advance!

With a mount table containing
/dev/sda1 / ext4 rw,relatime 0 0
# ...
/dev/sda3 /home ext4 rw,relatime 0 0
an xmobar configuration along these lines should actually work:
Config
{ -- ...
, template = "... %disku% ..."
-- ...
, commands =
[ -- ...
, Run DiskU
[ ( "/", "Root: <usedp> (<used>/<size>)")
, ( "/home", "Home: <usedp> (<used>/<size>)")
]
[] 20
-- ...
]
-- ...
}

The solution:
Slackware set the mount point of /dev/sda1 to /dev/root automatically in /etc/mtab, but /dev/root is a virtual device and not exists in /dev folder.
Xmobar try to access the device /dev/root and not found it.
The most simple solution is creation of a symbolic link to /dev/root on system startup.
In this case, in Slackware, edit the file /etc/rc.d/rc.local and add:
ln -s /dev/sda1 /dev/root
Problem solved!

Related

Replace the option noexec to exec in /etc/fstab file through a shell script

Only the /tmp option of noexec to exec should change. The /var/tmp option of noexec to exec shouldn't change.
contents of /etc/fstab
UUID=f229a689-a31e-4f1a-a823-9a69ee6ec558 / xfs defaults 0 0
UUID=eeb1df48-c9b0-408f-a693-38e2f7f80895 /boot xfs defaults 1 2
UUID=b41e6ef9-c638-4084-8a7e-26ecd2964893 swap swap defaults 0 0
UUID=79aa80a1-fa97-4fe1-a92d-eadf79721204 /var xfs defaults 1 2
UUID=644be3d0-433c-4ed5-bf12-7f61d5b99860 /tmp xfs defaults,nodev,nosuid,noexec 1 2
UUID=decda446-34ac-45b6-826c-ae3f090ed717 /var/log xfs defaults 1 2
UUID=a74170bc-0309-4b3b-862e-722fb7a6882d /var/tmp xfs defaults,nodev,nosuid,noexec 1 2
Using awk:
$ cat 1.awk
$2=="/tmp" { n=split($4,a,",");
str=""
for (i=1; i <= n; i++ ) {
if (a[i] != "noexec") {
if (length(str))
str=str","
str=str""a[i]
}
}
$4=str; print }
$2 != "/tmp" { print }
$ awk -f 1.awk fstab
UUID=f229a689-a31e-4f1a-a823-9a69ee6ec558 / xfs defaults 0 0
UUID=eeb1df48-c9b0-408f-a693-38e2f7f80895 /boot xfs defaults 1 2
UUID=b41e6ef9-c638-4084-8a7e-26ecd2964893 swap swap defaults 0 0
UUID=79aa80a1-fa97-4fe1-a92d-eadf79721204 /var xfs defaults 1 2
UUID=644be3d0-433c-4ed5-bf12-7f61d5b99860 /tmp xfs defaults,nodev,nosuid 1 2
UUID=decda446-34ac-45b6-826c-ae3f090ed717 /var/log xfs defaults 1 2
UUID=a74170bc-0309-4b3b-862e-722fb7a6882d /var/tmp xfs defaults,nodev,nosuid,noexec 1 2
Note, alignment of fields in the modified line can easily be improved using printf. I cannot tell if you were using tabs or spaces between the various fields.

linux - df command says disk 100% used, but it actually it's not

I have an EC2 instance running jenkins service and almost everyday it stops working saying the disk is full.
So I enter the instance to check and it really says 100% used
$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 987M 60K 987M 1% /dev
tmpfs 997M 0 997M 0% /dev/shm
/dev/xvda1 32G 32G 0 100% /
So I use NCDU to check what is occuping the space and it says only 8gb is used.
ncdu 1.10 ~ Use the arrow keys to navigate, press ? for help
--- / -------------------------------------------------------
3.7GiB [##########] /var
1.7GiB [#### ] /home
1.6GiB [#### ] /usr
1.0GiB [## ] swapfile
323.6MiB [ ] /opt
133.8MiB [ ] /lib
47.3MiB [ ] /boot
43.8MiB [ ] /root
23.1MiB [ ] /public
19.8MiB [ ] /lib64
12.3MiB [ ] /sbin
10.7MiB [ ] /etc
7.0MiB [ ] /bin
3.7MiB [ ] /tmp
60.0KiB [ ] /dev
e 16.0KiB [ ] /lost+found
16.0KiB [ ] /.gnupg
12.0KiB [ ] /run
e 4.0KiB [ ] /srv
e 4.0KiB [ ] /selinux
e 4.0KiB [ ] /mnt
e 4.0KiB [ ] /media
e 4.0KiB [ ] /local
e 4.0KiB [ ] /cgroup
. 0.0 B [ ] /proc
0.0 B [ ] /sys
0.0 B [ ] .autorelabel
0.0 B [ ] .autofsck
Total disk usage: 8.6GiB Apparent size: 8.6GiB Items: 379695
Then I reboot the instance and the free space comes back to only 28% used
$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 987M 60K 987M 1% /dev
tmpfs 997M 0 997M 0% /dev/shm
/dev/xvda1 32G 8.7G 23G 28% /
What can be causing this problem?
Additional data:
PSTREE
init─┬─acpid
├─agetty
├─amazon-ssm-agen───6*[{amazon-ssm-agen}]
├─atd
├─auditd───{auditd}
├─crond
├─dbus-daemon
├─2*[dhclient]
├─java─┬─sh───sudo───gulp --prod───9*[{gulp --prod}]
│ └─67*[{java}]
├─lvmetad
├─lvmpolld
├─6*[mingetty]
├─rngd
├─rpc.statd
├─rpcbind
├─rsyslogd───3*[{rsyslogd}]
├─2*[sendmail]
├─sshd───sshd───sshd───bash───pstree
├─supervisord───2*[php]
└─udevd───2*[udevd]
CRONTAB
* * * * * cd /home/ec2-user/laravel-prod && php artisan schedule:run >> /dev/null 2>&1
0 1 * * * rm /var/log/jenkins/jenkins.log

Unable to mount volume created by terraform

I am using the following terraform template
resource "aws_instance" "ec2" {
ami = "${var.ami_id}"
instance_type = "${var.flavor}"
key_name = "${var.key_name}"
availability_zone = "${var.availability_zone}"
security_groups= ["${var.security_group}"]
tags = {Name = "${var.instance_name}"}
}
resource "aws_volume_attachment" "ebs_volume" {
device_name = "/dev/sdg"
volume_id = "vol-006d716dad719545c"
instance_id = "${aws_instance.ec2.id}"
}
to launch an instance in aws and attach volume to that instance.
When i execute this i see that the instance is created and volume is attached to the instance as well.
ubuntu#ip-172-31-10-43:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 91M 1 loop /snap/core/6350
loop1 7:1 0 18M 1 loop /snap/amazon-ssm-agent/930
loop2 7:2 0 88.4M 1 loop /snap/core/6964
loop3 7:3 0 18M 1 loop /snap/amazon-ssm-agent/1335
xvda 202:0 0 50G 0 disk
└─xvda1 202:1 0 50G 0 part /
xvdg 202:96 0 20G 0 disk
But when i try to mount the volume im getting this weird error
ubuntu#ip-172-31-10-43:~$ sudo mkdir -p /goutham
ubuntu#ip-172-31-10-43:~$ sudo mount /dev/xvdg /goutha,
mount: /goutha,: mount point does not exist.
ubuntu#ip-172-31-10-43:~$ sudo mount /dev/xvdg /goutham
mount: /goutham: wrong fs type, bad option, bad superblock on /dev/xvdg, missing codepage or helper program, or other error.
Can anyone please help me out as to what mistake i am doing in this exercise.
Thanks in advance.
You can make a file system on an attached disk using user data and terraform script.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html
https://www.terraform.io/docs/providers/aws/r/instance.html#user_data
Create a sh file, templates/mkfs.sh
#!/bin/bash
while ! ls /dev/xvdg > /dev/null
do
sleep 5
done
if [ `file -s /dev/xvdg | cut -d ' ' -f 2` = 'data' ]
then
mkfs.xfs /dev/xvdg
fi
terraform script,
data "template_file" "mkfs" {
template = "${file("${path.module}/templates/mkfs.sh")}"
}
resource "aws_instance" "ec2" {
...
user_data = "${data.template_file.mkfs}"
...
}
It will be run when an ec2 instance is created and wait until disk is mounted. after that it will create file system.
I figured it i think i missed creating the file system in the volume as the volume im trying to attach is an empty volume
so this helped me out
$ sudo mkfs -t xfs /dev/xvdg
and
sudo mkdir -p /goutham
sudo mount /dev/xvdg /goutham
Thanks

Run program on boot with initramfs

I'm running uClinux on a SmartFusion2 as part of a University team building a small cube satellite. However, I'm not super experienced in Linux kernel, and this issue has had me stumped for a few days. I'm trying to get the SmartFusion to run a program on bootup. Currently, the only .uImage that does this is the test 'hello' file. I'm trying to recreate the process for another program, but am running into some difficulties.
in my hello directory I have the following files: hello.busybox, hello.kernel.M2S, help.txt, hello.uImage, Makefile, hello.initramfs, hello (directory)
in the hello subdirectory (projects/hello/hello):
hello (executable), hello.c, hello.gdb, hello.h, hello.o, Makefile
to try and get the uImage to boot and run a different program, I made a copy of my projects/hello/hello directory and renamed it 'goodbye', with a few minor changes int the .h and .c files for testing purposes. Now I'm trying to get the executable 'hello' in projects/hello/goodbye to run on boot.
My initramfs file originally looked like this:
# This is a very simple, default initramfs
dir /dev 0755 0 0
nod /dev/console 0600 0 0 c 5 1
nod /dev/tty 0666 0 0 c 5 0
nod /dev/null 0600 0 0 c 1 3
nod /dev/mem 0600 0 0 c 1 1
nod /dev/kmem 0600 0 0 c 1 2
nod /dev/zero 0600 0 0 c 1 5
nod /dev/random 0600 0 0 c 1 8
nod /dev/urandom 0600 0 0 c 1 9
dir /dev/pts 0755 0 0
nod /dev/ptmx 0666 0 0 c 5 2
nod /dev/ttyS0 0666 0 0 c 4 64
nod /dev/ttyS1 0666 0 0 c 4 65
nod /dev/ttyS2 0666 0 0 c 4 66
nod /dev/ttyS3 0666 0 0 c 4 67
nod /dev/ttyS4 0666 0 0 c 4 68
nod /dev/ttyS5 0666 0 0 c 4 69
dir /bin 755 0 0
dir /proc 755 0 0
file /bin/hello ${INSTALL_ROOT}/projects/${SAMPLE}/hello/hello 755 0 0
slink /bin/init hello 777 0 0
I changed the last two lines of the initramfs to read as follows:
file /bin/hello ${INSTALL_ROOT}/projects/${SAMPLE}/hello/goodbye 755 0 0
slink /bin/init hello 777 0 0
But when I try and boot the SmartFusion2 after remaking the uImage, I get this, witht the error at the bottom:
Starting kernel ...
Linux version 2.6.33-arm1 (ecenstudent#EE10308) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #38 Thu May 25 09:09:08 MDT 2017
CPU: ARMv7-M Processor [412fc231] revision 1 (ARMv7M)
CPU: NO data cache, 8K instruction cache
Machine: Microsemi M2S
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: m2s_platform=m2s-fg484-som console=ttyS0,115200 panic=10 ip=10.2.118.102:10.2.118.101:192.168.0.1::m2s-fg484-som:eth0:off ethaddr=3C:FB:96:05:00:53
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 64408k/64408k available, 1128k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0x00000000 - 0x00001000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
vmalloc : 0x00000000 - 0xffffffff (4095 MB)
lowmem : 0xa0000000 - 0xa4000000 ( 64 MB)
modules : 0xa0000000 - 0x01000000 (1552 MB)
.init : 0xa0008000 - 0xa0012000 ( 40 kB)
.text : 0xa0074bc0 - 0xa0083000 ( 58 kB)
.data : 0xa0084000 - 0xa008cce0 ( 36 kB)
Hierarchical RCU implementation.
NR_IRQS:83
Calibrating delay loop... 132.30 BogoMIPS (lpj=661504)
Mount-cache hash table entries: 512
Switching to clocksource mss_timer2
Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0x40000000 (irq = 10) is a 16550A
console [ttyS0] enabled
serial8250.1: ttyS1 at MMIO 0x40010000 (irq = 11) is a 16550A
Freeing init memory: 40K
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
Backtrace: no frame pointer
Rebooting in 10 seconds..
Can somebody help explain why this is happening and what I need to do to my initramfs to make it run the proper program on boot? Thanks!!
As it turns out, I was confused about how those two lines worked. When I finally figured it out, they looked like this:
file /bin/hello ${INSTALL_ROOT}/projects/${SAMPLE}/goodbye/hello 755 0 0
slink /bin/init hello 777 0 0
then it worked as desired, and I was able to implement it into other uImages.

AWS ECS volumes do not share any files

I have an EBS volume I have mounted to an AWS ECS cluster instance. This EBS volume is mounted under /data:
$ cat /etc/fstab
...
UUID=xxx /data ext4 defaults,nofail 0 2
$ ls -la /data
total 28
drwxr-xr-x 4 1000 1000 4096 May 14 06:11 .
dr-xr-xr-x 26 root root 4096 May 15 21:18 ..
drwxr-xr-x 4 root root 4096 May 14 06:11 .ethereum
drwx------ 2 1000 1000 16384 May 14 05:29 lost+found
Edit: Output of /proc/mounts
[ec2-user#xxx ~]$ cat /proc/mounts
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
/dev/xvda1 / ext4 rw,noatime,data=ordered 0 0
devtmpfs /dev devtmpfs rw,relatime,size=4078988k,nr_inodes=1019747,mode=755 0 0
devpts /dev/pts devpts rw,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /dev/shm tmpfs rw,relatime 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
cgroup /cgroup/blkio cgroup rw,relatime,blkio 0 0
cgroup /cgroup/cpu cgroup rw,relatime,cpu 0 0
cgroup /cgroup/cpuacct cgroup rw,relatime,cpuacct 0 0
cgroup /cgroup/cpuset cgroup rw,relatime,cpuset 0 0
cgroup /cgroup/devices cgroup rw,relatime,devices 0 0
cgroup /cgroup/freezer cgroup rw,relatime,freezer 0 0
cgroup /cgroup/hugetlb cgroup rw,relatime,hugetlb 0 0
cgroup /cgroup/memory cgroup rw,relatime,memory 0 0
cgroup /cgroup/perf_event cgroup rw,relatime,perf_event 0 0
/dev/xvdf /data ext4 rw,relatime,data=ordered 0 0
Now, I would like to mount /data/.ethereum as a Docker volume to /geth/.ethereum in my ECS task definition:
{
...
"containerDefinitions": [
{
...
"volumesFrom": [],
"mountPoints": [
{
"containerPath": "/geth/.ethereum",
"sourceVolume": "ethereum_datadir",
"readOnly": null
}
],
...
}
],
...
"volumes": [
{
"host": {
"sourcePath": "/data/.ethereum"
},
"name": "ethereum_datadir"
}
],
...
}
It appears that the volume is correctly mounted after running the task:
$ docker inspect -f '{{ json .Mounts }}' f5c36d9ea0d6 | python -m json.tool
[
{
"Destination": "/geth/.ethereum",
"Mode": "",
"Propagation": "rprivate",
"RW": true,
"Source": "/data/.ethereum"
}
]
How ever, if I create file inside the container inside the mount point, it will not be there on the host machine.
[ec2-user#xxx .ethereum]$ docker exec -it f5c36d9ea0d6 bash
root#f5c36d9ea0d6:/geth# cat "Hello World!" > /geth/.ethereum/hello_world.txt
cat: Hello World!: No such file or directory
root#f5c36d9ea0d6:/geth# echo "Hello World!" > /geth/.ethereum/hello_world.txt
root#f5c36d9ea0d6:/geth# cat /geth/.ethereum/hello_world.txt
Hello World!
root#f5c36d9ea0d6:/geth# exit
exit
[ec2-user#xxx ~]$ cat /data/.ethereum/hello_world.txt
cat: /data/.ethereum/hello_world.txt: No such file or directory
Somehow the file systems are not being shared. Any ideas?
Found the issue.
It seems like with Docker, any mount point (e.g. for EBS volumes) on the host instance has to be created before the Docker daemon has started, otherwise Docker will write the files into the instance's root file system without you even noticing.
I stopped Docker, unmounted the EBS volume, cleaned everything up, mounted the EBS volume again and started Docker afterwards. Now Docker seems to recognize the mount point and writes everything into my EBS volume as it should.

Resources