Script to resize embedded images



  • Hi,

    New in this Forum, i say hello to everyone interested.
    I have recreate a skript to create 128, 256, 512 or 1gb Images out of the original 64mb embedded one.
    Works only on FreeBSD, feel free to modify it for Linux.

    How to use:
    Save skript in your homedir.
    #> mv mkflash_new.txt mkflash_new.sh
    #> chmod +x mkflash_new.sh
    Download latest Snapshot from http://www.pfsense.com/~sullrich/
    Get pfSense.img.gz from there and place it in your homedir
    Unpack pfSense.img.gz with
    #> gzip -d pfSense.img.gz
    Be shure to get root-rights
    #> su
    execute skript like:
    Usage: /home/marcel/mkflash_new.sh {128|252|512|1024} {Originalimage}
    Example: #> /home/marcel/mkflash.sh 128 /home/marcel/pfSense.img

    Voila, take a look on the new image-file:
    pfSense-128MB.img.gz
    pfSense-128MB.img.gz.md5

    Have fun,
    Marcel

    edit: changed heading to resize image….
    mkflash_new.txt



  • Feel free to add this to our wiki at wiki.pfsense.com  :)





  • :) very good



  • I have troubles using it in a FreeBSD 6.2 machine:

    ./mkflash_new.sh 256 pfSense.img.gz

    abr 19 17:16:32: Creating 256MB Compact Flash
    abr 19 17:16:32: And using pfSense.img.gz as source image.
    abr 19 17:16:32:
    abr 19 17:16:32:        Real flash size: 222 MB
    abr 19 17:16:32:        root size: 218, root blocks: 446464
    abr 19 17:16:32:        conf size: 4, conf blocks: 8192 446464
    abr 19 17:16:32:        cylinders: 888, heads: 16, sectors: 32
    abr 19 17:16:32:
    abr 19 17:16:32: Creating empty 256MB flash image in /usr/home/super/pfsense
    abr 19 17:16:45:
    abr 19 17:16:45: Preparing Filesystems on /usr/home/super/pfsense/pfSense-256MB.img
    abr 19 17:16:45:        Bsdlabel
    abr 19 17:16:45:        Newfs
    abr 19 17:16:45:
    abr 19 17:16:45: Extracting content from pfSense.img.gz
    mount: /dev/md0a: No such file or directory
    mount: /dev/md0d: No such file or directory

    abr 19 17:16:45:        -> /usr/home/super/pfsense/pfSense-slash.tar.bz2
    abr 19 17:16:45:        -> /usr/home/super/pfsense/pfSense-conf.tar.bz2
    umount: /dev/md0a: statfs: No such file or directory
    umount: /dev/md0a: unknown file system
    umount: /dev/md0d: statfs: No such file or directory
    umount: /dev/md0d: unknown file system

    abr 19 17:16:46:
    abr 19 17:16:46: Restoring content to /usr/home/super/pfsense/pfSense-256MB.img
    abr 19 17:16:46:        <- /usr/home/super/pfsense/pfSense-slash.tar.bz2
    abr 19 17:16:46:        <- /usr/home/super/pfsense/pfSense-conf.tar.bz2
    abr 19 17:16:47:        Cleanig up.
    abr 19 17:16:47:
    abr 19 17:16:47: Compressing /usr/home/super/pfsense/pfSense-256MB.img
    abr 19 17:17:04:        Creating MD5 hash
    abr 19 17:17:04:
    abr 19 17:17:04: READY! Now you have a 256MB pfSense image.
    abr 19 17:17:04: You can get this image on your CF Card using:
    abr 19 17:17:04: zcat /usr/home/super/pfsense/pfSense-256MB.img.gz | dd of=/dev/da0 bs=16k

    Please, help!

    Josep Pujadas



  • It seems there is no support fpr Memory Disks on your System.
    Does a```
    #> kldload /boot/kernel/geom_md.ko



  • kldload /boot/kernel/geom_md.ko

    kldload: can't load /boot/kernel/geom_md.ko: File exists

    Any other idea?

    Thanks,

    Josep Pujadas



  • The Sourceimage has to be decompressed FIRST!

    Use```
    #>./mkflash_new.sh 256 pfSense.img



  • I'm very sorry!

    I forgot gunzip the image file before running the script …

    Many thanks!

    Josep Pujadas



  • What values should i use inside the following variables:

    • flash_MB

    • conf_MB

    • heads

    • sectors

    for a 2 GB CF card
    if i wanted to modify the script(http://wiki.pfsense.com/wikka.php?wakka=FlashHowToSkript ) to support 2 GB cards?



  • Hello!

    I don't know if it is standard, but I found at http://www.industrialcompactflash.com/datasheets/wincflash.pdf :

    Table 48: Product Capacity & Part Numbering

    | Card Capacity Part Number Real Capacity Total Sectors/Card (Max LBA+1) Cylinders Heads Sectors |
    | 128 MB CFLASH-G-128-I 131MB 256,512 1,002 8 32 |
    | 256 MB CFLASH-G-256-I 262MB 513,536 1,003 16 32 |
    | 512 MB CFLASH-G-512-I 526MB 1,028,160 1,020 16 63 |
    | 1 GB CFLASH-G-1024-I 1,054MB 2,060,352 2,044 16 63 |
    | 2 GB CFLASH-G-2048-I 2,118MB 4,136,832 4,104 16 63 |
    | 4 GB CFLASH-G-4204-I 4,204MB 8,211,168 8,146 16 63 |
    | 8 GB CFLASH-G-8415-I 8,415MB 16,435,440 16,305 16 63 |

    Regards,

    Josep Pujadas



  • Nice, thanks :D.


Log in to reply