Author Topic: How To: Create And Mount A Squashfs Image  (Read 34712 times)

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
How To: Create And Mount A Squashfs Image
« on: February 01, 2007, 05:49:57 pm »
Hi all,

I didn't really see a squashfs tutorial thread on the forum, so I thought I'll do one.

Most of the info is available from mksquashfs --help but I also gleaned from
http://www.artemio.net/projects/linuxdoc/s...ml#mksqoverview
For what squashfs is about and why you might want to use it, see the next post.

1. Install mksquashfs if it's not installed already.
2. Create a mksquashfs image

eg, you want to create an image based on a directory 'myfiles'
Code: [Select]
$ mksquashfs myfiles/ myfiles.squashfs
Creating little endian 2.1 filesystem on ati.squashfs, block size 65536.

Little endian filesystem, data block size 65536, compressed data, compressed metadata, compressed fragments
Filesystem size 12785.03 Kbytes (12.49 Mbytes)         27.52% of uncompressed filesystem size (46448.82 Kbytes)
Inode table size 17172 bytes (16.77 Kbytes)         33.86% of uncompressed inode table size (50709 bytes)
Directory table size 13324 bytes (13.01 Kbytes)         35.20% of uncompressed directory table size (37853 bytes)
Number of duplicate files found 4
Number of inodes 2118
Number of files 1889
Number of fragments 400
Number of symbolic links  0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 229
Number of uids 1         root (0)
Number of gids 0

If yours went through, you should get an image file myfiles.squashfs.

3. Mount the image
Code: [Select]
# mkdir /mnt/mydir
# mount myfiles.sqsh /mnt/mydir -t squashfs -o loop

That's it! Now when you look into /mnt/mydir, you should see the original directory structure with files in it.

For more on loop devices, you can refer to meanie's site or search google.

TIP: Meanie's pdaXqtrom for cacko creates additional loop devices.
« Last Edit: February 01, 2007, 05:51:31 pm by Snappy »
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
How To: Create And Mount A Squashfs Image
« Reply #1 on: February 01, 2007, 06:00:45 pm »
Squashfs simply allows you to create an image for a whole directory, partition or filesystem into an image, partition or filesystem. The example above compresses a whole directory into a single read-only image file. This image is then mounted and the files and directory structure can be accessed directly as before.

The advantage (for me anyway) is that a lot of space is saved! In my case, the original directory was 40+mb, while the image was 12mb!

YMMV, so if your files can benefit from compression and are not changed often, and you don't need to modify the files, then squashfs may be for you.
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

speculatrix

  • Administrator
  • Hero Member
  • *****
  • Posts: 3707
    • View Profile
How To: Create And Mount A Squashfs Image
« Reply #2 on: February 14, 2007, 06:46:13 pm »
thanks for this. I started writing up a quick guide on my website to document how I did the oesf forum archive.
Gemini 4G/Wi-Fi owner, formerly zaurus C3100 and 860 owner; also owner of an HTC Doubleshot, a Zaurus-like phone.

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
How To: Create And Mount A Squashfs Image
« Reply #3 on: February 14, 2007, 07:25:44 pm »
Quote
thanks for this. I started writing up a quick guide on my website to document how I did the oesf forum archive.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=154149\"][{POST_SNAPBACK}][/a][/div]

Great!

Was looking around as well for RW compressed format and found that jffs3 or something provides journalling and compression in RW format. Wonder if anyone tried that?
« Last Edit: March 04, 2007, 07:29:08 pm by Snappy »
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
How To: Create And Mount A Squashfs Image
« Reply #4 on: February 28, 2007, 08:59:25 pm »
Quote
Quote
thanks for this. I started writing up a quick guide on my website to document how I did the oesf forum archive.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=154149\"][{POST_SNAPBACK}][/a][/div]

Great!

Was looking around as well for RW compressed format and found that jffs3 or something provides journalling and compression in RW format. Wonder if anything tried that?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=154165\"][{POST_SNAPBACK}][/a][/div]

jffs2 is what is used on the NAND afaik, jffs2/jffs3 can only be installed on a device like the NAND....
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

speculatrix

  • Administrator
  • Hero Member
  • *****
  • Posts: 3707
    • View Profile
How To: Create And Mount A Squashfs Image
« Reply #5 on: March 02, 2007, 06:30:55 pm »
I imagine you can do a loopback mount of jffsX images as well, however, it's probably not the best way to use them, they're designed specifically for putting directly onto flash block devices to level wear and recover from bad blocks?
Gemini 4G/Wi-Fi owner, formerly zaurus C3100 and 860 owner; also owner of an HTC Doubleshot, a Zaurus-like phone.

Snappy

  • Hero Member
  • *****
  • Posts: 793
    • View Profile
    • http://
How To: Create And Mount A Squashfs Image
« Reply #6 on: March 04, 2007, 07:30:38 pm »
hmmm ... guess have to keep looking ...

Makes me miss doublespace and stacker ... for those who still recall those 'huge' 40mb hdd in DOS days!
Snappy!
------------------------
Akita (Daily use)
<span style='font-size:8pt;line-height:100%'>SL-C1000 with Cacko 1.23 full
Accessories: Wifi XI-825 CF  |  16GB (6) SDHC (Transcend) | 1GB 80x CF (RiDATA PRO-2) </span>

Collie (Sandbox)
<span style='font-size:8pt;line-height:100%'>SL-5500 with OZ/GPE 3.5.4.1 alpha3 build 2006-04-27
Accessories: 512MB A-Data SD | 64MB Toshiba SD</span>