Re: Read/Write bytes directly from hard drive
phil-news-nospam_at_ipal.net
Date: 04/23/05
- Next message: tom: "Re: Read/Write bytes directly from hard drive"
- Previous message: tom: "Re: Read/Write bytes directly from hard drive"
- In reply to: Grant Edwards: "Re: Read/Write bytes directly from hard drive"
- Next in thread: Peter T. Breuer: "Re: Read/Write bytes directly from hard drive"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Apr 2005 02:32:46 GMT
On Fri, 22 Apr 2005 21:48:19 -0000 Grant Edwards <grante@visi.com> wrote:
| On 2005-04-22, tom <tom@dbservice.com> wrote:
|> asharma wrote:
|>> We are writing a disk partitioner from scratch. We were not sure how to
|>> access any byte from the disk, including the master table or any other
|>> data. Are there any system calls that handle read/write operations?
|>>
|>
|> int fd = open("/dev/hda", O_SYNC);
|>
|> Read the first x bytes and you get the partition table of your first IDE
|> disk. Replace x with the size of your partition table.
|
| Be careful though. I seem to remember hearing Grub developers
| complain that the Linux filesystem code or buffer cache did
| something they didn't like with the first disk sector. I don't
| know the details, but the end result was that they couldn't
| reliably write to the boot sector when the drive had mounted
| partitions. I don't know if it was just the MBR or if the boot
| sectors within partitions were the problem. IIRC it wasn't an
| issue if no partitions on the disk were mounted.
I have been able to write sector 0 and change partitions even though some
partitions were mounted. I did not change any that were mounted, so I
cannot say that what is going on doesn't check for such a situation. But
what did not work was rereading the partition table to set up the new
partition size. I had to reboot.
-- ----------------------------------------------------------------------------- | Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ | | (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ | -----------------------------------------------------------------------------
- Next message: tom: "Re: Read/Write bytes directly from hard drive"
- Previous message: tom: "Re: Read/Write bytes directly from hard drive"
- In reply to: Grant Edwards: "Re: Read/Write bytes directly from hard drive"
- Next in thread: Peter T. Breuer: "Re: Read/Write bytes directly from hard drive"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|