In Linux I think there is a mechanism to kill the application.
I want to know what is in the condition that will cause an application to be killed?
For example, I think that there are insufficient memory, a certain number of application launches, and so on.
Control group (cgroups) which supported by Linux kernel permitting to limit resource used for an application.
(memory, bandwidth, disk, …). Once a particular app exceeds the permitted resource, it will be automatically killed.
How to enable it?
Make following modification to do_configure_append() in linux-kernel.bb.
# cgroups
kernel_configure_variable CGROUPS y
kernel_configure_variable CGROUP_FREEZER y
kernel_configure_variable CGROUP_PIDS y
kernel_configure_variable CGROUP_DEVICE y
kernel_configure_variable CPUSETS y
kernel_configure_variable PROC_PID_CPUSET y
kernel_configure_variable CGROUP_CPUACCT y
kernel_configure_variable PAGE_COUNTER y
kernel_configure_variable MEMCG y
kernel_configure_variable CGROUP_SCHED y
kernel_configure_variable NAMESPACES y
# overlay fs
kernel_configure_variable OVERLAY_FS y
References:
https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide
Related
I know we can use NFS, but I just don't want to use it.
(don't want to keep network connection to NFS server all the time).
I know we can use tftp in u-boot to load kernel and device-tree!
But can we use tftp in u-boot to download root-filesystem, put it in the right partition of SD card, and boot?
If yes, how to do it? (I googled, but found no answers)
Thanks,
Jerry
I use TFTP in uboot to flash my rootfs (for debug purposes) on my internal eMMC. It's nearly the same case as you.
First download in you RAM the filesystem:
tftpboot ${rootfs_addr} ${tftppath}/${rootfs_file}
rootfs_addr will be the RAM address, I use 0x10800000.
tftppath is the TFTP path (depends on your configuration)
rootfs_file is the ext4 or ext3 file
Then update the mmc device (you can run mmc listto show SD u-boot number)
mmc dev 2
Here I set the device to the number 2, you need to set it corresponding to the mmc list command.
Then write the content of the RAM to the SD:
setexpr rootfsblksz ${filesize} / 200
setexpr rootfsblksz ${rootfsblksz} + 1
mmc write ${rootfs_addr} 6000 ${rootfsblksz}
Description:
I create a rootfsblksz variable, it converts the number of bytes downloaded to a number of blocks. filesizeis set automatically when we use TFTP, it represents the size of the last downloaded file (in Bytes).
Here my block is 512Bytes (0x200)
I add +1 to the blocksize (to be shure to have all the data)
I write it on the eMMC (or SD) at the address 0x6000 (in blocks) -> 24 576 blocks -> 12 582 912 (in Bytes) -> 12MB because my ext partition is at 12MB offset
Hope it helps!
On Debian 8 installed XRDP + xfce4. There is no possibility to add a new layout to system - the "Add" button is disabled: after logging in go to the "Application Menu - Settings - Keyboard" select "Layout" and see the following picture: see screenshot.
In the directory /etc/xrdp/ there are files:
km-0407.ini
km-0409.ini
km-040c.ini
km-0410.ini
km-0419.ini
km-041d.ini
rsakeys.ini
sesman.ini
startwm.sh
xrdp.ini
km-0419.ini - layout, which I need.
How to add a keyboard layout?
I tried to run inside a terminal session (under root) commands:
setxkbmap
and
xrdp-genkeymap /etc/xrdp/km-0419.ini
In response to the first command I get:
XKB extention not present on: 10.0
second silently executed, nothing happens.
The same commands is a terminal session (on a host-machine) reported:
Can not open display «default display»
and
unable to open display ""
I had a trouble with Debian 9 + xfce + xrdp.
The trouble was the additional layouts disappeared when I reconnected by RDP.
I'm not sure this is exactly you are looking for, I apologize if it is not.
Maybe my experience will help you to figure out how to resolve your trouble.
Also I do not know if it works for your version of xrdp.
For example here is solution for Russian keyboard.
It returns all keyboard layouts settings to default when you start new RDP session.
So there are two ways to resolve it.
Run the command to change your settings to preferable after any RDP login.
setxkbmap -layout us,ru -variant ',winkeys' -option 'grp:alt_shift_toggle,grp_led:scroll'
Or change xrdp config to make it use the settings you want.
What helped me is correcting file /etc/xrdp/xrdp_keyboard.ini
(pay attention for sections [rdp_keyboard_ru] and [layouts_map_ru])
You can use it for another's languages by analogy.
Here is an example of /etc/xrdp/xrdp_keyboard.ini file of mine.
You can see at the end of the file I use my custom sets:
;
; RDP Keyboard <-> X11 Keyboard layout map
;
; How this file works:
; 1. load the file and scan each section to find matching "keyboard_type"
; and "keyboard_subtype" based on the values received from the client.
; If not found, then jump to default section.
; 2. in the selected section, look for "rdp_layouts" and "layouts_map".
; Based on the "keylayout" value from the client, find the right x11
; layout value.
; 3. model/variant are inferred based on the "keyboard_type" and
; "keyboard_subtype", but they can be overridden.
;
;
; RDP Keyboard Type (http://msdn.microsoft.com/en-us/library/cc240563.aspx)
;
; 0 is not a valid value
;
; 1 - IBM PC/XT or compatible (83-key) keyboard
; 2 - Olivetti "ICO" (102-key) keyboard
; 3 - IBM PC/AT (84-key) or similar keyboard
; 4 - IBM enhanced (101- or 102-key) keyboard
; 5 - Nokia 1050 and similar keyboards
; 6 - Nokia 9140 and similar keyboards
; 7 - Japanese keyboard
;
; RDP Keyboard Subtype is vendor dependent. XRDP defines as follows:
;
; 0 is not a valid value
;
; 1 - Standard
; 2 - FreeRDP JP keyboard
; 3 - Macintosh
; ... - < any vendor dependent subtype >
;
; The list can be augmented.
;
; default
[default]
; keyboard_type and keyboard_subtype is not read for default section. It
; is only a placeholder to keep consistency. Default model/variant are
; platform dependent, and could be overridden if needed.
keyboard_type=0
keyboard_subtype=0
; user could override variant and model, but generally they should be inferred
; automatically based on keyboard type and subtype
;variant=
;model=
; A list of supported RDP keyboard layouts
rdp_layouts=default_rdp_layouts
; The map from RDP keyboard layout to X11 keyboard layout
layouts_map=default_layouts_map
[default_rdp_layouts]
rdp_layout_us=0x00000409
rdp_layout_de=0x00000407
rdp_layout_fr=0x0000040C
rdp_layout_it=0x00000410
rdp_layout_jp=0x00000411
rdp_layout_jp=0xe0010411
rdp_layout_jp=0xe0200411
rdp_layout_jp=0xe0210411
rdp_layout_kr=0x00000412
rdp_layout_ru=0x00000419
rdp_layout_se=0x0000041D
rdp_layout_ch=0x00000807
rdp_layout_pt=0x00000816
rdp_layout_br=0x00000416
rdp_layout_pl=0x00000415
; <rdp layout name> = <X11 keyboard layout value>
[default_layouts_map]
rdp_layout_us=us
rdp_layout_de=de
rdp_layout_fr=fr
rdp_layout_it=it
rdp_layout_jp=jp
rdp_layout_kr=kr
rdp_layout_ru=ru
rdp_layout_se=se
rdp_layout_ch=ch
rdp_layout_pt=pt
rdp_layout_br=br(abnt2)
rdp_layout_pl=pl
; if two sections have the same keyboard_type and keyboard_subtype, then
; the latter could override the former.
[rdp_keyboard_mac]
keyboard_type=4
keyboard_subtype=3
rdp_layouts=default_rdp_layouts
layouts_map=rdp_layouts_map_mac
[rdp_keyboard_jp]
keyboard_type=7
keyboard_subtype=2
model=pc105
rdp_layouts=default_rdp_layouts
layouts_map=default_layouts_map
[rdp_layouts_map_mac]
rdp_layout_us=us
rdp_layout_de=de
rdp_layout_fr=fr
rdp_layout_jp=jp
rdp_layout_kr=kr
rdp_layout_it=it
rdp_layout_ru=ru
rdp_layout_se=se
rdp_layout_ch=ch
rdp_layout_pt=pt
rdp_layout_br=br(abnt2)
rdp_layout_pl=pl
[rdp_keyboard_ru]
keyboard_type=4
keyboard_type=7
keyboard_subtype=1
model=pc105
options=grp:lctrl_lshift_toggle,compose:ralt
variant=,
rdp_layouts=default_rdp_layouts
layouts_map=layouts_map_ru
[layouts_map_ru]
rdp_layout_us=us,ru
rdp_layout_ru=us,ru
look at $HOME/.config/xfce4/xfconf/xfce-perchannel-xml/keyboard-layout.xml
setxkbmap -layout us,ru -variant ',' -option 'grp:win_space_toggle'
Nginx occupies all the available disk space. How to set limit for log files on Mac OS?
Rotate the log files. On OS X, newsyslog is the preferred utility to do that. Set up a file like this in /etc/newsyslog.d/nginx.conf:
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/nginx.log deceze:wheel 644 2 1024 * J
Read https://www.newsyslog.org/manual.html for more information.
Building on #deceze's answer, here's an adapted version of Apple's Apache configuration for a Homebrew-installed nginx:
#logfilename [owner:group] mode count size when [flags] [/pid_file] [sig_num]
/opt/homebrew/var/log/nginx/access.log _nginx:_nginx 644 10 20480 * Z /opt/homebrew/var/run/nginx.pid 30
This is assuming you're running as user:group _nginx:_nginx. It sends the correct SIGUSR1 signal (30 on macOS) to nginx. Also changed to using gzip instead of bzip2.
In the past, I have created an instance with attached EBS storage through the AWS web console. At the "Step4. Add storage" step I would add EBS storage as device="/dev/sdf", Standard as Volume type and no Snapshot. Once the instance got launched, I would issue the following set of commands to mount the extra drive as a separate directory and make it accessible to everybody:
sudo mkfs.ext4 /dev/xvdf
sudo mkdir /home/foo/extra_storage_directory
sudo mount -t ext4 /dev/xvdf /home/foo/extra_storage_directory
cd /home/foo
sudo chmod a+w extra_storage_directory
aI was given a piece of python code that creates instances without any extra storage programmatically. It calls boto.ec2.connection.run_instances. I need to modify this code to be able to create instances with extra storage. I need to essentially emulate the manual steps I used doing it via console, to make sure that the above sudo commands work after I launch the new instance.
Which boto function(s) do I need to use and how to add the storage?
UPDATE: I did some digging and wrote some code that I thought was supposed to do what I wanted. However, the behavior is a bit strange. Here's what I have:
res = state.connection.run_instances(state.ami,key_name=state.key,instance_type=instance_type,security_groups=sg)
inst = res.instances[0]
pmt = inst.placement
time.sleep(60)
try:
vol = state.connection.create_volume(GB, pmt)
tsleep = 60
time.sleep(tsleep)
while True:
vstate = vol.status
if not vstate == 'available':
print "volume state is %s, trying again after %d secs" % (vstate,tsleep)
time.sleep(tsleep)
else:
break
print "Attaching vol %s to inst %s" % (str(vol.id),str(inst.id))
state.connection.attach_volume(vol.id, inst.id, "/dev/sdf")
print "attach_volume OK"
except Exception as e:
print "Exception: %s" % str(e)
The call to run_instances came from the original code that I need to modify. After the volume get created, when I looked at its status in the AWS console, I see available. However, I get an endless sequence of
volume state is creating, trying again after 60 secs
Why the difference?
As garnaat pointed out, I did have to use vol.update() to update the volume status. So the code below does what I need:
res = state.connection.run_instances(state.ami,key_name=state.key,instance_type=instance_type,security_groups=sg)
inst = res.instances[0]
pmt = inst.placement
time.sleep(60)
try:
vol = state.connection.create_volume(GB, pmt)
tsleep = 60
time.sleep(tsleep)
while True:
vol.update()
vstate = vol.status
if not vstate == 'available':
print "volume state is %s, trying again after %d secs" % (vstate,tsleep)
time.sleep(tsleep)
else:
break
print "Attaching vol %s to inst %s" % (str(vol.id),str(inst.id))
state.connection.attach_volume(vol.id, inst.id, "/dev/sdf")
print "attach_volume OK"
except Exception as e:
print "Exception: %s" % str(e)
I tripped on the same problem and the answer at How to launch EC2 instance with Boto, specifying size of EBS? had the solution.
Here are the relevant links:
Python Boto documentation - block_device_map
API reference - BlockDeviceMapping.N
Command line reference - -b, --block-device-mapping mapping
CLI reference - --block-device-mappings (list)
Important note: While in the Web Console the "Delete on Termination" check box is checked, in the Boto API, it's the opposite, delete_on_termination=False by default!
fdisk is used to create mmcblk0p3 on the 64G SD card.
Disk /dev/mmcblk0: 63.8 GB, 63864569856 bytes
255 heads, 63 sectors/track, 7764 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2 6 40162+ c Win95 FAT32 (LBA)
/dev/mmcblk0p2 7 130 996030 83 Linux
/dev/mmcblk0p3 131 7764 61320105 83 Linux
The fs is then formatted like this:
$ mke2fs -L media /dev/mmcblk0p3
Filesystem label=media
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3833856 inodes, 15330026 blocks
766501 blocks (5%) reserved for the super user
First data block=0
Maximum filesystem blocks=16777216
468 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, ...
Mount point /media definitely exists and $ mount /dev/mmcblk0p3 /media works fine when mmcblk0p3 is a FAT32 FS on a Win95 FAT32 partition. I need to change from FAT32 to ext2 since the FAT32 partition 3 is too easily hosed in this embedded Linux target (power cycle, USB mass storage disconnects, etc.). An Ubuntu 10.04 desktop system has been used to verify that the partition type is ext2 and is able to mount the SD card partition but this needs to work on the embedded Linux target. The kernel version is 2.6.32-17-ridgerun with BusyBox v1.18.2.
Why does $ mount /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: Invalid argument?
Why does mount -t ext2 /dev/mmcblk0p3 /media cause mount: mounting /dev/mmcblk0p3 on /media failed: No such device?
Why does $ mount /dev/mmcblk0p3 /media cause mount: mounting
/dev/mmcblk0p3 on /media failed: Invalid argument?
The kernel can probably mount the filesystem, but it wrongly guess its type.
Why does mount -t ext2 /dev/mmcblk0p3 /media cause mount: mounting
/dev/mmcblk0p3 on /media failed: No such device?
If, after you specified -t, you get a problem like that, it is very likely that the kernel cannot mount the requested filesystem for you. Check if there is a module for that filesystem and it is loaded.
lsmod # show modules
modprobe ext2 # load module
Sources : http://www.silas.net.br/doc.notes/unix/linux/busybox-troubleshooting.html
As far as I know ext2 modules are already loaded by default. But it won't hurt to check.
The problem here I think is the ambiguity due to mke2fs. mke2fs can be used to create ext2/ext3/ext4 filesystems. You have to specify the file system via -t option. Try doing this :
#mkfs -t ext2 /dev/hda1
#mkfs.ext2 /dev/hda1
You missed out -t option in your command making mke2fs format it with filesystem in default conf.