I recently created a bootable usb thumb drive for installing Kubuntu on different computers at work. I also planned to to use this device as a live system for the rare instances where I need another Linux system in my office to test things. Creating the bootable drive was a piece of cake with the usb-creator-gtk package.
Today I wanted to test out some cool stuff like dns2tcp, ptunnel, stunnel and ppp. I pulled out my thumb drive, smacked it into an available machine and booted off the cool little guy. I quickly found that I needed to install more packages and as I did, I ran out of space in the 128 MB that I had allocated for “extra space” on the 4GB drive.
Yeah it was obviously a dumb move to only allocate 128 MB for my /home and customizations. The fun thing about Linux is where there is a stupid mistake there is a chance to learn something new and do something fun, if you like that sort of thing.
As it turns out usb-creator-gtk creates a file in the root of the drive called casper-rw. This file is an ext3 filesystem image and is what contains most of the writable data in your live environment. All I needed to do to get some more space (provided that drive wasn’t physically full) was to enlarge this file and then resize the ext3 filesystem inside the file to be able to use all of the newly available space in the file.
Oblig Warning: Only do this if you understand what these commands do and agree that they are the best course of action for your situation. Use at your own risk.
The following steps where taken from a computer which was running Kubuntu Karmic. You must not be running in the live environment on the usb device when doing this procedure.
-
me@puter:/$ cd ~
-
me@puter:~$ mkdir /mnt/disk
-
me@puter:~$ sudo mount /dev/sdc1 /mnt/disk/
-
me@puter:~# ls -l /mnt/disk
-
total 1181148
-
-rwxr-xr-x 1 root root 144 2009-12-22 15:13 autorun.inf
-
-rwxr-xr-x 1 root root 1404 2010-01-07 20:10 bootex.log
-
drwxr-xr-x 2 root root 4096 2009-12-22 15:16 casper
-
-rwxr-xr-x 1 root root 1207959552 2010-01-07 16:41 casper-rw
-
drwxr-xr-x 3 root root 4096 2009-12-22 15:16 dists
-
drwxr-xr-x 2 root root 4096 2009-12-22 15:16 install
-
-r-xr-xr-x 1 root root 14607 2009-12-22 15:13 ldlinux.sys
-
-rwxr-xr-x 1 root root 4050 2009-12-22 15:13 md5sum.txt
-
drwxr-xr-x 2 root root 4096 2009-12-22 15:16 pics
-
drwxr-xr-x 4 root root 4096 2009-12-22 15:16 pool
-
drwxr-xr-x 2 root root 4096 2009-12-22 15:16 preseed
-
-rwxr-xr-x 1 root root 223 2009-12-22 15:13 README.diskdefines
-
drwxr-xr-x 2 root root 8192 2009-12-22 15:16 syslinux
-
-rwxr-xr-x 1 root root 1468640 2009-12-22 15:13 wubi.exe
-
-
me@puter:~$ dd if=/dev/zero of=img bs=1M count=1024
-
1024+0 records in
-
1024+0 records out
-
1073741824 bytes (1.1 GB) copied, 20.2902 s, 52.9 MB/s
-
-
me@puter:~$ sudo -i
-
-
root@puter:~# cat /home/me/img >> /mnt/disk/casper-rw
-
root@puter:~# cd /mnt/disk
-
root@puter:/mnt/disk# resize2fs casper-rw
-
resize2fs 1.41.9 (22-Aug-2009)
-
Please run ‘e2fsck -f casper-rw’ first.
-
-
root@puter:/mnt/disk# e2fsck -f casper-rw
-
e2fsck 1.41.9 (22-Aug-2009)
-
Pass 1: Checking inodes, blocks, and sizes
-
Pass 2: Checking directory structure
-
Pass 3: Checking directory connectivity
-
Pass 4: Checking reference counts
-
Pass 5: Checking group summary information
-
casper-rw: 2235/32768 files (4.8% non-contiguous), 130869/131072 blocks
-
-
root@puter:/mnt/disk# resize2fs casper-rw
-
resize2fs 1.41.9 (22-Aug-2009)
-
Resizing the filesystem on casper-rw to 1179648 (1k) blocks.
-
The filesystem on casper-rw is now 1179648 blocks long.