On Mon, 15 Mar 2004, Szakacsits Szabolcs wrote:
> On Mon, 15 Mar 2004, Anton Altaparmakov wrote:
[snip]
> > the hidden sectors entry in the ntfs boot sector means the sector
> > location of the start of the partition relative to the beginning of
> > the disk.
[snip]
> > Does anyone have any ideas as to how mkntfs (or ntfsclone for that
> > matter) could determine the value necessary for the hidden sectors field
> > in the ntfs boot sector?
>
> I didn't investigate this yet. Perhaps Linux kernel has (or had before
> 2.6) some ioctl to query this. It should actually ... Otherwise we must
> parse the partition table: duplicated effort.
The answer is yes it does! See include/lunux/hdreg.h. The ioctl is
HDIO_GETGEO and returns the drive geometry (struct hd_geometry {
blah...
unsigned long start;
}; and start is the kernel's idea of the starting sector of the partition
within the disk device for which the ioctl is performed.
Also, HDIO_GETGEO is implemented by it would seem all block device drivers
including IDE, SCSI, MD, LVM, etc, so this should work for all types of
disks and also it should work for dynamic disks, normal partitioned disks,
etc. In fact it is completely independent of underlying partitioning
scheme so it is perfect solution for us.
> > Perhaps as a start we could provide a command line option that allows
> > the user to set the value of hidden_sectors?
>
> I'm not sure. I planned ntfsck would fix this for the user.
>
> ntfsclone could have also an option for "system cloning". Problem can
> arise if the value is changed without asking the user, if the user doesn't
> restore the image by ntfsclone but by some other way (dd, cp, etc). In
> these cases they couldn't boot if the partition was boot partition.
We will always need a command line option for when people are not using
Linux as we can only do the ioctl on Linux... Also some people may be
running mkntfs on a file that will later be copied (e.g. using dd) to a
real partition so they could then use the option to specify the correct
offset.
But yes, one day an ntfsck should definitely fix this as one of the things
it does.
I will add support for doing the HDIO_GETGEO to libntfs soon and modify
mkntfs to use it + add a command line option then we can try it and see if
it makes bootable partitions...
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
|