Using unsquashfs command on low RAM computers

General Q&A stuff about FoxyRoxyLinux

Using unsquashfs command on low RAM computers

Postby saintless » Sat Nov 10, 2012 9:59 pm

I use low RAM computers with 64 - 512 Mb RAM and I had strange problem with unsquashfs command (it presents in every FoxyRoxy script). This was the usual result I get:
Code: Select all
root@debian:~# unsquashfs -d /live/image/2 /live/image/live/01-FoxyRoxy.squashfs
Parallel unsquashfs: Using 1 processor
38057 inodes (35160 blocks) to write

[======|                                                    ]  4237/35160  12%

At first I thought it has something to do with mothreboard types or HDD types but it was nothing like this. The strange thing was I have this problem on a computer with 512 Mb RAM + 512 MB SWAP partition and I don't have it on a computer with 128 Mb RAM and 2 Gb SWAP partition. Actually it was memory issue.
As you know by default FoxyRoxy uses /tmp (which is in RAM) to unsquash files and there is /scripts/99-setdirs script if you have low RAM computer and you need to change /tmp to some partition formatted in ext2, ext3 or ext4.
Lets say you need to unsquash file with 300 Mb uncompressed data but you have 128 Mb RAM. It will never work unless you have big enough SWAP partition. It seems even if you change the path /tmp to some ext partition you still have low RAM problem because while the unsquashfs command is working and it writes on your hard drive, at the same time it uses cache buffer in RAM or SWAP partition with much bigger size than your RAM has. This is the memory report while unsquashfs command is uncompressing 01-FoxyRoxy.squashfs:
Code: Select all
root@debian:~# free -m
             total       used       free     shared    buffers     cached
Mem:           247        243          3          0          4         24
-/+ buffers/cache:        215         31
Swap:         1021        264        757

To solve this problem you have two choices:
1. To create SWAP partition on your HDD and to add swapon option in your kernel grub line. This is not convenient because you will use part of your hard drive space as SWAP partition permanently.
2. To create and use SWAP file only when you need it and delete it when you don't need it. Here is the way to do this. In my example the SWAP file is 512 MB and it is placed in /live/image:
Code: Select all
root@debian:~# dd if=/dev/zero of=/live/image/swapfile bs=1024 count=524288

Code: Select all
root@debian:~# mkswap /live/image/swapfile 524288

You can use this swapfile right a way without reboot by typing:
Code: Select all
root@debian:~# swapon /live/image/swapfile

This command will stop it and then you can delete it to save hard drive space:
Code: Select all
root@debian:~# swapoff /live/image/swapfile
User avatar
Posts: 246
Joined: Sat Jul 14, 2012 7:01 am
Location: Bulgaria

Re: Using unsquashfs command on low RAM computers

Postby jbv » Sun Dec 30, 2012 9:49 am

Hi Toni,

If you need to free-up some memory, you can also use the little script below that I have created.

Not sure how much memory it will free up on machines with only a little RAM, but on my 4Gb systems, on some occasions it has returned as much as 512Mb to the system pool.

Just unzip and drop it into /scripts, then do a 99-snap.
Alternatively, use 02-load and punch it directly into your FoxyDesktop

Cheers, Brenton
Drops all cache data to free up some RAM
(235 Bytes) Downloaded 947 times
Posts: 600
Joined: Sat Jul 14, 2012 2:02 am
Location: Sydney, Australia

Re: Using unsquashfs command on low RAM computers

Postby saintless » Sun Dec 30, 2012 1:25 pm

Thanks, Brenton :)
Even 5 Mb free memory will be welcome for low ram computer :)
User avatar
Posts: 246
Joined: Sat Jul 14, 2012 7:01 am
Location: Bulgaria

Return to Do General Stuff

Who is online

Users browsing this forum: No registered users and 1 guest