Profile cover photo
Profile photo
Thomas Weeks
Fun loving uber hardware/FOSS Geek, love teaching, HP rockets, descrete electronics design & hacking, #Arduino #RPi, etc..
Fun loving uber hardware/FOSS Geek, love teaching, HP rockets, descrete electronics design & hacking, #Arduino #RPi, etc..
About
Thomas's posts

Post has attachment
Thomas Weeks commented on a post on Blogger.
So where's the best place to get Esplora games?

Post has attachment
Thomas Weeks commented on a post on Blogger.
Nice job!

Is there a centralized place where we can get Esplora games?

Post has attachment

Post has attachment
Linux Geeks:
You think ssh socks5 proxy tunneling is cool? How about a full machine, transparent socks proxy with higher performance (than TCP over TCP)? Check out sshuttle:
http://sshuttle.readthedocs.io/en/stable/overview.html

Linux Geeks:
Ever need to dd or clone a larger disk to a smaller? Or how about a larger 8.1GB SD card to a slightly smaller 7.9GB SD card?

Here's a nice trick.. (assuming you've cloned your SD card to an large image file like this "dd if=/dev/sdb of=Disk.img bs=4096"). This is the kind of stuff we had to do in the old days (before resizefs (which I have had implode on me doing simple shrinks like this)).

Now to the mount a partition from within a disk image. (to prepare to shrink it)
1) Poll the image with fdisk to see where the start of that second partition is within the image file:
# fdisk -lu Disk.img
Disk Disk.img: 8035 MB, 8035237888 bytes
255 heads, 63 sectors/track, 976 cylinders, total 15693824 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009bf4f

Device Boot Start End Blocks Id System
Disk.img1 8192 122879 57344 c W95 FAT32 (LBA)
Disk.img2 122880 15693823 7785472 83 Linux

2) To mount the second partition, multiply the bytes/sector (512 for mine) by the starting sector and feed this into losetup to create your loop device:

# losetup /dev/loop0 Disk.img -o $((122880 * 512))
file -s /dev/loop0
/dev/loop0: Linux rev 1.0 ext4 filesystem data, UUID=f24a4949-f4b2-4cad-a780-a138695079ec (extents) (large files)


3) Mount the sucker..
mount /dev/loop0 /mnt/tmp/
work-1 Images # df -h|grep mnt/tmp
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 7.3G 2.6G 4.4G 37% /mnt/tmp

If it's not full, cool. If it is full.. nuke some unneeded content to make some space). Not a problem here though:
# df -h |grep mnt/tmp
/dev/loop0 7.3G 2.6G 4.4G 37% /mnt/tmp

4) Copy out (cp -a = archive) or tar your filesystem content into a holding space:
# cp -a /mnt/tmp/ Disk_loop-part2-files/

5) Zerofill the partition (wipe filesystem) and resize the image's second partiton (within the partition or loop device.. NOT the device):
dd if=/dev/zero of=/dev/loop0 bs=4096 && sync
dd: error writing ‘/dev/loop0’: No space left on device
1946369+0 records in
1946368+0 records out
7972323328 bytes (8.0 GB) copied, 18.9685 s, 420 MB/s

(Error is expected)

I do this so that if I nee to go in later and inspect with a hexeditor or anything, the zerofill will make things more clear where the end of the new filesystem ends.

6) Nuke the loop device:
# losetup -d /dev/loop0

7) Edit the image's second partition to resize it down to around 7.2GB and reformat it and repopulate it (easier than messing with boundary mismatch issues):
# fdisk -u Disk.img
Command (m for help): p

Disk Disk_PLAY.img: 8035 MB, 8035237888 bytes
255 heads, 63 sectors/track, 976 cylinders, total 15693824 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009bf4f

Device Boot Start End Blocks Id System
Disk_PLAY.img1 8192 122879 57344 c W95 FAT32 (LBA)
Disk_PLAY.img2 122880 15693823 7785472 83 Linux

Command (m for help): d
Partition number (1-4): 2

Command (m for help): p

Disk Disk_PLAY.img: 8035 MB, 8035237888 bytes
255 heads, 63 sectors/track, 976 cylinders, total 15693824 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009bf4f

Device Boot Start End Blocks Id System
Disk_PLAY.img1 8192 122879 57344 c W95 FAT32 (LBA)

Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (1-4, default 2):
Using default value 2
First sector (2048-15693823, default 2048): 122880
Last sector, +sectors or +size{K,M,G} (122880-15693823, default 15693823): 15000000

Command (m for help): p

Disk Disk_PLAY.img: 8035 MB, 8035237888 bytes
255 heads, 63 sectors/track, 976 cylinders, total 15693824 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009bf4f

Device Boot Start End Blocks Id System
Disk_PLAY.img1 8192 122879 57344 c W95 FAT32 (LBA)
Disk_PLAY.img2 122880 15000000 7438560+ 83 Linux

Command (m for help): w
The partition table has been altered!

Syncing disks.

8) New loop device, same as before:
losetup /dev/loop0 Disk.img -o $((122880 * 512))

9) Format it..
# mkfs.ext4 /dev/loop0
mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
...
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done


10) Mount and repopulate the data:
# mount /dev/loop0 /mnt/tmp/
# cp -a Disk_loop-part2-files/tmp/* /mnt/tmp/
# df -h | grep mnt/tmp
/dev/loop0 7.2G 2.8G 4.1G 41% /mnt/tmp

# umount /mnt/tmp

11) Good to go.. Now we can DD this image to a smaller 7.8GB card and not worry about the "end of device" message that corrupted this image on smaller cads. Do so like this:
# dd if=Disk.img of=/dev/sdb bs=4096
dd: error writing ‘/dev/sdb’: No space left on device
(that was writing those zeros.. which are after the end of my new filesystem.. which is fine :)






Actual Conversation w/Daughter Last Night After Youth Group...
Tabitha: So dad.. a boy just flirted with me in another language tonight.
Me: WHAT?! What do you mean? What "language"?
Tabitha: Javascript..
Me: Oh... really?.... Cool!
Tabitha: You're not concerned?
Me: Does he have a github repo?
Tabitha: I don't know..
Me: Good.

Post has attachment
Security / Freedom Geeks:
Do you believe in Open Hardware? You you believe that you should be able to really control your own hardware? That chipsets should be free from BLOBs and backboors? That TPM should work FOR the user instead of against the user? If you said yes to any of these questions, then you really need to rally behind the O

Post has attachment
Just binge watched this four part BBC special "Space Race" that covers the missile and space race between the US and USSR from WWII on through the 70s. It's simply the most complete, dramatic and technically complete documentary on the US and Russian space race I've ever seen. I learned so much.. about the rockets, the governments and the men behind the space race. Awesome piece of documentary work you'll want to share with your family. Oh.. and I just found all four episodes on YouTube:
https://www.youtube.com/watch?v=xcLphSY8PX0&list=PLp-sq3loaBSxi0qevIFPSFmIvoJ7skiO0

Post has attachment
A blog piece of mine on teaching STEM.

http://racksburg.com/teaching-stem/

Post has attachment
Hey! One of my favorite trade rag zines is back in print!
Cool!
Wait while more posts are being loaded