Re: Please How do I calculate the offset of a file within a ext3 partition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The reason why I am using a file as my swap partition is because, I want to be able to change the size of my swap just as easy as if I was to create a smaller or larger file.

In the swsusp kernel documentation: Documentation/power/swsusp-and-swap-files.txt

It says that the swap files need not to be contiguous. swsusp need only to find the header of the the swap-file to find where all the blocks belonging to the swap-file are located and use it.

The reason why I wanted to backup my data first in case something go wrong was just because, I was not certain that the header was in the first block of the swapfile, and I am not sure whether swsusp do check if the file being used is a valid swap-file.

Thank you to Theodore Tso, for reminding me to multiply the block number by the size of a single block, otherwise I was going to use the block number instead of calculating its offset.

I still haven't tried anything, because I only have one machine and I need to wait till the weekend when I don't need to use it much for work and try it. So if something wrong happen, I have enough time to fix it.

I will let you guys know of the outcome...

William Tambe


Stephen Samuel wrote:
What I'd note here is that the file has discontinuities, so this file
is probably not appropriate for doing suspends to swap.
At a quick guess, you probably need to either:
 1) set up a proper swap PARTITION.
(e.g. remove the current swap file, shrink the /var (or /, as the case
may be) partition by that much, and then use the newly freed space to
create a proper partition.)

I believe that you can use qtparted to do the work of shrinking the
partition for you.  You might want to download a live-CD linux (like
Knoppix, or the Ubuntu live CD)  so that you can do the resize without
having to worry about the partition being in use.

or
2) Find a program that will allow you to allocate a file as one
contiguous chunk (nothing off the top of my head). then allocate the
swap file using that,

On 7/23/07, Stephen Samuel <darkonc@xxxxxxxxx> wrote:
What I'd note here is that the file has discontinuities, so this file
is probably not appropriate for doing suspends to swap.
At a quick guess, you probably need to either:
   1) set up a proper swap PARTITION.
(e.g. remove the current swap file, shrink the /var (or /, as the case
may be) partition by that much, and then use the newly freed space to
create a proper partition.)

I believe that you can use qtparted to do the work of shrinking the
partition for you.  You might want to download a live-CD linux (like
Knoppix, or the Ubuntu live CD)  so that you can do the resize without
having to worry about the partition being in use.

or
2) Find a program that will allow you to allocate a file as one
contiguous chunk (nothing off the top of my head). then allocate the
swap file using that,

On 7/23/07, Theodore Tso <tytso@xxxxxxx> wrote:
> On Mon, Jul 23, 2007 at 02:17:40PM -0500, William Tambe wrote:
> > Thank you for warning me, I am already using a specific file as my swap,
> > so I had already done mkswap on it.
> > I only wanted to be able suspend on it and resume from it using swsusp.
> > To do that I needed to give to the kernel as arguments the following:
> > resume=<swap_file_partition> resume_offset=<swap_file_header_offset>
>
> If you have the filefrag program, you can just do
>
> # filefrag -v /var/cache/swap  | head
> Checking /var/cache/swap
> Filesystem type is: ef53
> Filesystem cylinder groups is approximately 578
> Blocksize of file /var/cache/swap is 4096
> File size of /var/cache/swap is 1073741824 (262144 blocks)
> First block: 13778944
> Last block: 14406757
> Discontinuity: Block 6137 is at 13785112 (was 13785087)
> Discontinuity: Block 12251 is at 13791992 (was 13791231)
>
> So the first block is 13778944.  So the byte offset is 4096*13778944
> or 56438554624.
>
>
>                                         - Ted
>
> _______________________________________________
> Ext3-users mailing list
> Ext3-users@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/ext3-users
>


--
Stephen Samuel http://www.bcgreen.com
778-861-7641




_______________________________________________
Ext3-users mailing list
Ext3-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/ext3-users

[Index of Archives]         [Linux RAID]     [Kernel Development]     [Red Hat Install]     [Video 4 Linux]     [Postgresql]     [Fedora]     [Gimp]     [Yosemite News]

  Powered by Linux