|
Resizing COW files - a demonstration
Let's start. Among the prerequisites, the kernel must contain my COW-resize
patches, as well as the ext2-resize ones. The file system must thus obviously
be ext2 for now, even though tools like GNU parted might relax this restriction.
When booting for the first time, without a parameter, the COW file is created.
Creating "slackcow" as COW file for "root_fs_slack8.1"
An empty COW file with the same size as the backing file has been created,
and it is a sparse file, so it doesn't waste any space.
*** Resizing cow file: 210819584 -> 314572800
### got size: 314572800 (move 210819584 bytes, move them 103778816 bytes)
At the second boot, the COW file is enlarged afterwards because of the size
parameter which is larger than the current file size.
Of course, the debug output should not appear in the final version.
josef@noosphere /src/Linux/images/UML $ ls -las root_fs_slack8.1 slackcow
205824 -rw------- 1 josef josef 210763776 Apr 27 10:36 root_fs_slack8.1
624 -rw-r--r-- 1 josef josef 210819584 Apr 27 11:30 slackcow
Now let's resize the filesystem so it covers the whole virtual partition.
We login and check for the storage usage first.
Welcome to Linux 2.4.20-4um (tty0)
darkstar login: root
Linux 2.4.20-4um.
Last login: Fri Apr 4 19:54:44 +0000 2003 on tty0.
You have mail.
root@darkstar:~# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/ubd/0 199309 43862 145156 24% /
This is the old size. We do however want the new one. Thus we use ext2online to
enlarge the filesystem to the maximum possible size.
root@darkstar:~# ext2online / 262144
ext2online v1.1.17 - 2001/03/18 for EXT2FS 0.5b
ext2online: resizing to 262144 blocks
OK, and what's the size now?
root@darkstar:~# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/ubd/0 254127 43868 197156 19% /
If we take a look at the files again, we see that the COW file is larger than
the backing file, but also includes the backing data, so this is partially a
waste of space. This might be improved in the future.
josef@noosphere /src/Linux/images/UML $ ls -las root_fs_slack8.1 slackcow
205824 -rw------- 1 josef josef 210763776 Apr 27 10:36 root_fs_slack8.1
206220 -rw-r--r-- 1 josef josef 314654208 Apr 27 16:54 slackcow
That's it. The new luxury can now be enjoyed.
Back to the index page
Josef Spillner (mail)
Created: 26.04.2003
|