1

I'm quite new to C# and I need to write a file (grub) on an EXt2 linux partition from windows 7.

What is the good way to do such thing? Do I need to mount the partition with external program?

Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
Ben Liard
  • 11
  • 2

5 Answers5

1

I think you need to mount it with an external program such as: http://www.fs-driver.org/

Brosto
  • 4,445
  • 2
  • 34
  • 51
1

Mount the drive using a a driver like FS-driver and then write to it using standard C# file writing techniques.

Stephan
  • 5,430
  • 2
  • 23
  • 31
0

If you use Total Commander under Windows, one of the available plugins is for accessing ext2/3/4. It's probably already been mentioned here but it makes accessing Linux from Windows almost transparent. I don't have it installed right now or I'd look at the name.

Alan Corey
  • 577
  • 6
  • 10
0

You can use Ext2Fsd to mount the partition in windows, and then write to as you would any other partition.

EXT2FSD Home Page

0

SharpExt4 may help you with Linux file system read and write.

A .Net library to provide full access (read/write) to Linux ext2/ext3/ext4 filesystem

Here is the GitHub link https://github.com/nickdu088/SharpExt4

//Open EXT4 SD Card
//Here is SD Card physical disk number. you can get from Windows disk manager
ExtDisk SharpExt4.ExtDisk.Open(int DiskNumber);
//In your case FAT32 is 1st one, ext4 is 2nd one
//Open EXT4 partition
var fs = ExtFileSystem.Open(disk.Parititions[1]); 

//Create /home/pi/file.conf file for write
var file = fs.OpenFile("/home/pi/file.conf", FileMode.Create, FileAccess.Write);
var hello = "Hello World";
var buf = Encoding.ASCII.GetBytes(hello);
//Write to file
file.Write(buf, 0, buf.Length);
file.Close();

How to use SharpExt4 to access Raspberry Pi SD Card Linux partition

Nick
  • 96
  • 5