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

Bug#265194: resizing needs to be mentioned more in the partitioning utility



I'm just kind of thinking out loud here, in case anyone else is
entertaining the idea of using "ntfsresize" for shrinking NTFS partitions
in d-i.

IMHO, growing NTFS partitions is not very important, it's the shrinking of
them.  That's the scenrio all the Windows refugees are in, they want more
free disk space to install Debian in.  So that would simplify the problem
to just focus on the shrinking.

Anton Zinoviev wrote:
> If the user tries to resize a partition with unsupported file system the
> following happens:
>
> 1. If the partition doesn't exist on the disk (because it is new) then
> it is immediately resized
>
> 2. If the partition exists on the disk then
>    a. the user sees a confirmation dialog
>    b. the changes are written to the disk
>    c. partman attemts to resize (it simply uses the capability of
> parted)

Ok, I think I've found the code where this calling to partman takes place:

in partman's source in parted_server.c, lines 230 to 242:

/* Like ped_file_system_resize but automaticaly creates PedTimer */
int
timered_file_system_resize(PedFileSystem *fs, PedGeometry *geom)
{
        int result;
        PedTimer *timer;
        start_timer();
        timer = ped_timer_new(&timer_handler, NULL);
        result = ped_file_system_resize(fs, geom, timer);
        stop_timer();
        ped_timer_destroy(timer);
        return result;
}

Then when I looked in parted's source in doc/API, which miraculously
exists, ped_file_system_resize, PedFileSystem, PedFileSystemType,
PedGeometry, PedSector were all explained.

So if I'm not mistaken, all we'd need for args for shell out to ntfsresize
and cfdisk or equivalent (to delete the partition around the NTFS data,
then create a new one partition snugly around the smaller NTFS data) are,
if I'm not mistaken:

- fs->type->name has the name of the filesystem type, a const char* const
like "ntfs" (or "NTFS"?)
- geom->dev->path has the device name, a char* like "/dev/hda1"
- geom->start has the starting sector, a long long
- geom->end has the ending sector, a long long
- geom->length has the length in sectors, a long long
(...where start + length - 1 == end)

The command "ntfsresize --info" can return the smallest size that the NTFS
partition can be shrunken to.  That size plus a padding of, say, 100MB
could be offered to the user as a lower size range to collect input for
new size to shrink down to.

So based on user input on what to shrink it down to, after offering a
range in the GUI, "ntfsresize --size size[k|M|G] device" would shrink the
NTFS partition down!

Then apparently cfdisk can delete and recreate the partition around the
smaller NTFS data, but I don't know the args.

Maybe this info will be useful to someone... :)


>    d. parted fails but partman doesn't care about this
>    e. the user is returned to the main partitioning screen where the
> partition has its old size



Dustin Harriman

Root Shell Computer Support
http://rootshell.ca




Reply to: