Extend TorBery filesystem, minimal Raspbian image

Torbery is very, very nice raspberry pi image wich will be your instant anonymous proxy server:

Torberry image:
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/torberry/torberry-0.40.img.xz
0a5ad217e93c95928b395e86406c84fa
4666be1c8150a64c3d50b4a9390b3420e2e1c601

To use it as proxy server just push image to SD card and set the Raspberry Pi IP adreess into another workstations internet browser settings:
If you want to use this box for another purpose you probably need to extend root filesystem. SSH is enable for this box by default. So we log into this system with default username pi and password raspberry and we can launch df command to see how mush space we can still use it:
pi@torberry ~ $ df
Filesystem     1K-blocks   Used Available Use% Mounted on
rootfs            337127 270927     48792  85% /
/dev/root         337127 270927     48792  85% /
devtmpfs          216132      0    216132   0% /dev
tmpfs              44880    188     44692   1% /run
tmpfs               5120      0      5120   0% /run/lock
tmpfs              89740      0     89740   0% /run/shm
/dev/mmcblk0p1     57288  18888     38400  33% /boot
tmpfs              49152      4     49148   1% /var/lib/tor
tmpfs               6144      4      6140   1% /var/log/tor
At first we can disable tor service at startup and stop it right now:
sudo chmod -x /etc/init.d/tor && sudo /etc/init.d/tor stop
To extend root file system launch partition tool and print partition table:
sudo fdisk /dev/mmcblk0

Command (m for help): p

Disk /dev/mmcblk0: 31.7 GB, 31724666880 bytes
4 heads, 16 sectors/track, 968160 cylinders, total 61962240 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: 0x00065c03

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          122880      819199      348160   83  Linux
We have to remember the first block of second partition which in this case always be 122880

So we just delete MBR information about second partition existence in your SD card:
Command (m for help): d
Partition number (1-4): 2
Now we create new information about second partition. This time we will set same start block 122880 but this time the last block will be much bigger:
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): 2
First sector (2048-61962239, default 2048): 122880
Last sector, +sectors or +size{K,M,G} (122880-61962239, default 61962239):
Using default value 61962239
And at last we write changes with w:
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
All together look like this:
Now wee need reboot the system:
sudo reboot
After reboot nothing is resized untill we run the command:
sudo resize2fs /dev/mmcblk0p2
This will take up to ten seconds and the output will be similar to this:
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 118
The filesystem on /dev/mmcblk0p2 is now 30919680 blocks long.
And now the system is much bigger:
df
Filesystem     1K-blocks   Used Available Use% Mounted on
rootfs          29951137 271448  28439789   1% /
/dev/root       29951137 271448  28439789   1% /
devtmpfs          216132      0    216132   0% /dev
tmpfs              44880    180     44700   1% /run
tmpfs               5120      0      5120   0% /run/lock
tmpfs              89740      0     89740   0% /run/shm
/dev/mmcblk0p1     57288  18888     38400  33% /boot
tmpfs              49152      0     49152   0% /var/lib/tor
tmpfs               6144      0      6144   0% /var/log/tor

No comments: