a1ive / grub

Fork of GRUB 2 to add various features.
GNU General Public License v3.0
138 stars 38 forks source link

dd support for /dev/zero #37

Closed steve6375 closed 4 years ago

steve6375 commented 4 years ago

I want to write all 00's to an existing NTFS file to fill it with 00's. Does dd support something like --if=/dev/zero ? Also, I want to write a string (the value of a variable) into an existing file (NTFS or FAT). Is there a way to do this?

a1ive commented 4 years ago

I want to write a string (the value of a variable) into an existing file (NTFS or FAT).

dd --str=STRING --of=... 深度截图_选择区域_20200223081540

a1ive commented 4 years ago

now you can use (proc) as /dev/zero. disk size is 2TB (UINT32_MAX). 深度截图_选择区域_20200223095359

steve6375 commented 4 years ago

Thanks! When booting WinPE ISOs that have been made using WinBuilder, they look for an INI file in the root of all drives.

I have added some code to my map.sh and now Gandalf WinPE boots correctly using map (no yellow triangle on Desktop and apps work).

My first partition has all three .ini files WinBuilder INI files.zip

    loopback -d loop;
    loopback loop "${grubfm_file}";
    set installiso="${grubfm_path}";
    tr --set=installiso "/" "\\";
    set "iso1=[IsoInfo]\x0d\x0aIsoName=${installiso}\x0d\x0a"
    if [ -f (loop)/CdUsb.Y -o -f (loop)/Win10PE.cd -o -f (loop)/Win8PE.cd ] ; then 
        echo Info: WinBuilder ISO detected!
        if [ -f (hd0,msdos1)/Win10PESE.ini ] ; then dd --if (proc) --of=(hd0,msdos1)/Win10PESE.ini ; dd -s "$iso1" --of=(hd0,msdos1)/Win10PESE.ini ; fi
        if [ -f (hd0,msdos1)/Win8PESE.ini ]  ; then dd --if (proc) --of=(hd0,msdos1)/Win8PESE.ini  ; dd -s "$iso1" --of=(hd0,msdos1)/Win8PESE.ini  ; fi
        if [ -f (hd0,msdos1)/Win7PESE.ini ]  ; then dd --if (proc) --of=(hd0,msdos1)/Win7PESE.ini  ; dd -s "$iso1" --of=(hd0,msdos1)/Win7PESE.ini  ; fi
        #grubfm_hex (hd0,msdos1)/Win7PESE.ini
    unset iso1
    fi
steve6375 commented 4 years ago

P.S. dd seems very slow when using (proc) ???

a1ive commented 4 years ago

P.S. dd seems very slow when using (proc) ???

If you are trying to dd a file, grub2 will convert file to blocklists.

steve6375 commented 4 years ago

yes, as in example code above.

a1ive commented 4 years ago

If (hd0,1) is fat, why not use fatfs create file and write?

set installiso="${grubfm_path}";
tr --set=installiso "/" "\\";
set "iso1=[IsoInfo]\x0d\x0aIsoName=${installiso}\x0d\x0a";
mount (hd0,1) 1;
touch 1:/Win10PESE.ini;
write_file 1:/Win10PESE.ini "${iso1}";

深度截图_选择区域_20200223193626

steve6375 commented 4 years ago

Because the files are already in partition 1 as part of easy2boot. agFM is an optional extra.

a1ive commented 4 years ago

As long as (hd0,1) is FAT, you could use write_file rather than dd.

steve6375 commented 4 years ago

It is usually NTFS