http://blog.ruski.co.za/page/Resize-a-Portable-Ubuntu-Image.aspx
When you first download and install Portable Ubuntu, you’re going to be left with only about 500 MB of space on your Linux file system. This isn’t enough to do much of anything with, so the first order of business is going to be increasing the size of the image.
There are instructions for doing so at the Portable Ubuntu website, but for convenience sake I am repeating them here.
The process is fairly straight forward and basically consists of creating a new larger image file and then copying the existing image over to it. Once that is done we make the new image our primary partition.
To start, make sure that you’re not currently running Portable Ubuntu. Exit it if you are.
Open a Windows Command Prompt window by clicking Start -> Run and entering “cmd”.
Change to the directory in which you’ve installed Portable Ubuntu. For the purposes of this article we’ll assume that is C:Portable_Ubuntu.
Change to the images folder:

C:Portable_Ubuntu> cd images

Then we create a new image using the fsutil utility. The number at the end is the size of the new image you want to create in bytes. I’ve opted to create a 4 GB image in the example below.

C:PortableUbuntuimages> fsutil file createnew rootfs.img 4294967296

Next we must mount the new image in our Ubuntu instance. Edit the portable_ubuntu.conffile in the C:Portable_Ubuntuconfig directory using Notepad. You can use explorer for this or the commands below.

C:Portable_Ubuntuimages> cd .. C:Portable_Ubuntu> cd config C:Portable_Ubuntuconfig> notepad portableubuntu.conf

Replace the line in the config file that starts with “cobd3=“ with the following in notepad:cobd3=imagesrootfs.img
Save the file and close Notepad.
Now we need to run Portable Ubuntu again so that we can copy the contents of the original image over to the new image.
Run Portable Ubuntu and open a Terminal window when it is ready.
Type the following to make sure you have root access:

$ sudo su

You will be asked for a password. The default password for Portable Ubuntu is 123456
Next we’ll run the Data Definition (dd) tool on linux to create a raw copy of the original image. Don’t screw this up as the dd tool has earned the nickname “Data Destroyer” for a good reason.

$ dd if=/dev/cobd0 of=/dev/cobd3

Once that is completed we’ll have an exact copy of our data from the original image to the new larger image.
Next we’ll do a file system check on the new image to make sure it’s good.

fsck.ext3 -f /dev/cobd3

Then we resize the partition on the new image to take up all the space.

resize2fs -f /dev/cobd3

Now that that is done, we can make the new image our main image. To do this, exit the running Portable Ubuntu image.
Go back to the images folder and rename rootfs.img to rootfs.img.old and rootfs_img torootfs.img.
Remove the line that you had modified in the portableubuntu.conf file (cobd3=imagesrootfs.img) using Notepad.
Now you can run Portable Ubuntu again and you’ll have a useful amount of free space left. You can delete the rootfs.img.old file if everything is working properly.

知识共享授权条款
本著作Chen, Zai-Chun制作,以知识共享 姓名标示-相同方式分享 4.0 国际 授权条款释出

留言

Nov 30 2010