Swap partitions - activation and situation
2 participantes
Página 1 de 1.
Swap partitions - activation and situation
Hola all dudes,
what the hell is swap partition? It is a sort of virtual memory. If your system have a limited amount of physical memory (in MS4x0H it is 250MB) and some application want's to allocate some more resources, the system will signal the application insufficient amount of free memory to be allocated and application will stops. You can avoid this by adding the physical memory (not possible in MS4x0H situation) or add the virtual memory - it is a space allocated on disk to be used as memory (it can be a full partition or file in filesystem). The partition (or file in filesystem) is called as swap and is added to system with lowest priority and is used as last option to allocate memory.
In Harmony from first version, there is automatic swap partition activation.
I try to describe the swap situation:
The main HDD (internal, for 400H in external bay) is repartitioned as following schema:
1. partition - main partition for all the movies/photos/music and recordings - rest of HDD if you subtract next 3 partitions
2. partition - swap partition - 160MB
3. partition - Linux EXT3 partition for time-shift - size depend of your choice in settings while HDD formating
4. partition - service partition - 160MB
I have following situation while using 1.5TB disk
The activated swaps can be see in /proc/swaps
Why is this...
The "/mnt/rd/swap.img" is from the original firmware specification. The size is 40kb. This swap MUST BE activated and must be activated as first swap. If you don't do this, the system will not start and constantly reboots.
The second swap is activated from Harmony start. I detect the creation of swap partition but in start scripts there were no activation of this swap. So it is added to startup script of Harmony.
There are some confusing behavior of system:
- if you boot with no USB connected, the HDD is detected as /dev/sda - so all the partitions are seen as /dev/hda1-4
- if you plug any of the USB disk and then turns the PVR on, this USB is detected before the HDD so it takes the /dev/hda and the HDD takes /dev/hdb (I didn't try to connect more than 1 USB disk so there is a possibility if you connect 2 USB disks, the one USB disk takes /dev/hda, he second takes /dev/hdb and HDD takes /dev/hdc) - this is for MS400H with one HDD in bay. If someone can test it for MS450H with installed internal HDD w/wo external HDD, I can supply it.
Best accessing the concrete disk is point to the physical connection - as you can see in list of swaps - "/dev/scsi/host1/bus0/target0/lun0/part2". This is the notation of absolute partition. If we boot without any USB disk the targets are as follows:
If you connect the the USB disk, the /dev/sd* devices are changed but /dev/scsi/host1/... devices are still same across all the time.
Why I write this... if you use original firmware, there is only added the 50kB file /mnt/rd/swap.img and the next swap partition on HDD not. So I tell there is no reason to activate this partition for us. It is done by "starthddscript.sh" which is started in boot sequence and after the disk is detected. It will add additional 160MB of virtual memory. So we can see following output of free memory:
So in Harmony we have 400MB of memory.
what the hell is swap partition? It is a sort of virtual memory. If your system have a limited amount of physical memory (in MS4x0H it is 250MB) and some application want's to allocate some more resources, the system will signal the application insufficient amount of free memory to be allocated and application will stops. You can avoid this by adding the physical memory (not possible in MS4x0H situation) or add the virtual memory - it is a space allocated on disk to be used as memory (it can be a full partition or file in filesystem). The partition (or file in filesystem) is called as swap and is added to system with lowest priority and is used as last option to allocate memory.
In Harmony from first version, there is automatic swap partition activation.
I try to describe the swap situation:
The main HDD (internal, for 400H in external bay) is repartitioned as following schema:
1. partition - main partition for all the movies/photos/music and recordings - rest of HDD if you subtract next 3 partitions
2. partition - swap partition - 160MB
3. partition - Linux EXT3 partition for time-shift - size depend of your choice in settings while HDD formating
4. partition - service partition - 160MB
I have following situation while using 1.5TB disk
- Código:
root@Venus:~# fdisk -l /dev/sda
Disk /dev/sda: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 2 180249 1447842060 7 HPFS/NTFS
/dev/sda2 180250 180269 160650 82 Linux swap
/dev/sda3 180270 182361 16803990 83 Linux
/dev/sda4 182362 182381 160650 83 Linux
The activated swaps can be see in /proc/swaps
- Código:
root@Venus:~# cat /proc/swaps
Filename Type Size Used Priority
/mnt/rd/swap.img file 32 0 -1
/dev/scsi/host1/bus0/target0/lun0/part2 partition 160640 0 -2
Why is this...
The "/mnt/rd/swap.img" is from the original firmware specification. The size is 40kb. This swap MUST BE activated and must be activated as first swap. If you don't do this, the system will not start and constantly reboots.
The second swap is activated from Harmony start. I detect the creation of swap partition but in start scripts there were no activation of this swap. So it is added to startup script of Harmony.
There are some confusing behavior of system:
- if you boot with no USB connected, the HDD is detected as /dev/sda - so all the partitions are seen as /dev/hda1-4
- if you plug any of the USB disk and then turns the PVR on, this USB is detected before the HDD so it takes the /dev/hda and the HDD takes /dev/hdb (I didn't try to connect more than 1 USB disk so there is a possibility if you connect 2 USB disks, the one USB disk takes /dev/hda, he second takes /dev/hdb and HDD takes /dev/hdc) - this is for MS400H with one HDD in bay. If someone can test it for MS450H with installed internal HDD w/wo external HDD, I can supply it.
Best accessing the concrete disk is point to the physical connection - as you can see in list of swaps - "/dev/scsi/host1/bus0/target0/lun0/part2". This is the notation of absolute partition. If we boot without any USB disk the targets are as follows:
- Código:
/dev/sda1 = /dev/scsi/host1/bus0/target0/lun0/part1
/dev/sda2 = /dev/scsi/host1/bus0/target0/lun0/part2
/dev/sda3 = /dev/scsi/host1/bus0/target0/lun0/part3
/dev/sda4 = /dev/scsi/host1/bus0/target0/lun0/part4
If you connect the the USB disk, the /dev/sd* devices are changed but /dev/scsi/host1/... devices are still same across all the time.
Why I write this... if you use original firmware, there is only added the 50kB file /mnt/rd/swap.img and the next swap partition on HDD not. So I tell there is no reason to activate this partition for us. It is done by "starthddscript.sh" which is started in boot sequence and after the disk is detected. It will add additional 160MB of virtual memory. So we can see following output of free memory:
- Código:
root@Venus:~# free
total used free shared buffers
Mem: 250728 246972 3756 0 29888
-/+ buffers: 217084 33644
Swap: 160672 0 160672
So in Harmony we have 400MB of memory.
Re: Swap partitions - activation and situation
Hi Keltek,
I disagree with your point:
Nevertheless, I must say that using official firmware I have never ever seen (I keep a log of the output of free every 5 minutes) more than a few Kbyts (<<32) of used swap.
Best,
I disagree with your point:
I am now running the official firmware MS400_101027_0128.img and this is what I see:Keltek escribió:[...]if you use original firmware, there is only added the 50kB file /mnt/rd/swap.img and the next swap partition on HDD not.[...]
- Código:
lg#> cat /proc/swaps
Filename Type Size Used Priority
/mnt/rd/swap.img file 32 0 -1
/dev/scsi/host0/bus0/target0/lun0/part2 partition 160640 0 -2
cat /proc/meminfo
MemTotal: 250728 kB
MemFree: 128508 kB
Buffers: 13988 kB
[...]
SwapTotal: 160672 kB
SwapFree: 160672 kB
[...]
Nevertheless, I must say that using official firmware I have never ever seen (I keep a log of the output of free every 5 minutes) more than a few Kbyts (<<32) of used swap.
Best,
evr- Mensajes : 279
Fecha de inscripción : 12/10/2010
Re: Swap partitions - activation and situation
Thank you. I used official firmware loong time ago so I only takes what is in boot scripts.
I always forgot the DvdPlayer application which rules them all - there are swapon lines so the "part2" is added by DvdPlayer.
I always forgot the DvdPlayer application which rules them all - there are swapon lines so the "part2" is added by DvdPlayer.
Re: Swap partitions - activation and situation
Hi,
I have just made an interesting (I think) test with strictly official firmware MS400_101027_0128.img. After booting the LG and loging in through telnet (while my wife was watching the TV and/or recorded videos in the LG ;)), I have completely deactivated the swap:
Then I started a memory-hog process: busybox gzip:
I've killed the busybox gzip when the free memory was about 25000 KB. Then, after issuing a reboot command, everything is now working back again as usual.
Main lessons learned:
1. The LG can work perfectly without swap -- IMPORTANT EDIT: This is not totally true.
2. DvdPlayer starts dying when other application(s) eat memory and bring it under 30000 KB.
3. Exhausting the memory kills the bigest process, but doesn't harm other, smaller processes.
4. Without swap, the LG may hang or fall down when doing these barbarian practices, but flash is not damaged and, after reboot, everything goes on O.K as usual.
Keltec, Victor (and/or anybody else), ¿can you please try to completely deactivate the swap (as in the first three code lines above) and see what happens with the Harmony firmware (PM + Custom)?
Best,
I have just made an interesting (I think) test with strictly official firmware MS400_101027_0128.img. After booting the LG and loging in through telnet (while my wife was watching the TV and/or recorded videos in the LG ;)), I have completely deactivated the swap:
- Código:
lg#> swapoff /dev/scsi/host0/bus0/target0/lun0/part2
lg#> swapoff /mnt/rd/swap.img
lg#> echo 0 > /proc/sys/vm/swappiness
lg#>
lg#> grep -e Mem -e Swap /proc/meminfo
MemTotal: 250728 kB
MemFree: 134560 kB
SwapCached: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Then I started a memory-hog process: busybox gzip:
- Código:
lg#> cd /tmp/hdd/volumes/HDD1/tmp/
lg#> ~/busybox gzip -c custom.tar > custom.tar.gz
- Código:
grep Mem /proc/meminfo
MemTotal: 250728 kB
MemFree: 30356 kB
I've killed the busybox gzip when the free memory was about 25000 KB. Then, after issuing a reboot command, everything is now working back again as usual.
Main lessons learned:
1. The LG can work perfectly without swap -- IMPORTANT EDIT: This is not totally true.
2. DvdPlayer starts dying when other application(s) eat memory and bring it under 30000 KB.
3. Exhausting the memory kills the bigest process, but doesn't harm other, smaller processes.
4. Without swap, the LG may hang or fall down when doing these barbarian practices, but flash is not damaged and, after reboot, everything goes on O.K as usual.
Keltec, Victor (and/or anybody else), ¿can you please try to completely deactivate the swap (as in the first three code lines above) and see what happens with the Harmony firmware (PM + Custom)?
Best,
Última edición por evr el Vie Ene 28, 2011 1:39 am, editado 2 veces (Razón : Make an IMPORTANT CORRECTION)
evr- Mensajes : 279
Fecha de inscripción : 12/10/2010
Re: Swap partitions - activation and situation
Very very interesting...
this swap /mnt/rd/swap.img must be activated while booting (without it the DvdPlayer won't start) so the deactivating must be after the DvdPlayer is started.
If we disable the swap and keep all the stuff running (lighttp, samba, transmission) the memory will be exhausted faster. For now I don't know the mechanisms of killing the memory intensive processes by kernel, but I think there must be something like white/black list of processes to be or not to be killed.
this swap /mnt/rd/swap.img must be activated while booting (without it the DvdPlayer won't start) so the deactivating must be after the DvdPlayer is started.
If we disable the swap and keep all the stuff running (lighttp, samba, transmission) the memory will be exhausted faster. For now I don't know the mechanisms of killing the memory intensive processes by kernel, but I think there must be something like white/black list of processes to be or not to be killed.
Re: Swap partitions - activation and situation
Yes.Keltek escribió:[...]this swap /mnt/rd/swap.img must be activated while booting (without it the DvdPlayer won't start) so the deactivating must be after the DvdPlayer is started.
"OOM killer" is your friend See, for instance:If we disable the swap and keep all the stuff running (lighttp, samba, transmission) the memory will be exhausted faster. For now I don't know the mechanisms of killing the memory intensive processes by kernel, but I think there must be something like white/black list of processes to be or not to be killed.
http://linux-mm.org/OOM_Killer
http://lwn.net/Articles/317814/
and maybe this one too:
http://ubuntuforums.org/showthread.php?t=1524536
Best,
evr- Mensajes : 279
Fecha de inscripción : 12/10/2010
Re: Swap partitions - activation and situation
After more systematic tests, this does not seem to be true, sorry about that. See here for more details.evr escribió:[...]I have completely deactivated the swap: [...] Then I've gone on doing busyness as usual: watching TV, playing recorded video, [...] As (I) expected, the LG has not cared at all and it has continued working perfectly. [...] Main lessons learned: 1. The LG can work perfectly without swap [...]
I will edit the original post.
Best,
evr- Mensajes : 279
Fecha de inscripción : 12/10/2010
Página 1 de 1.
Permisos de este foro:
No puedes responder a temas en este foro.