LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   How do I erase an entry in the partition table? (https://www.linuxquestions.org/questions/linux-desktop-74/how-do-i-erase-an-entry-in-the-partition-table-4175617149/)

stf92 11-07-2017 02:31 PM

How do I erase an entry in the partition table?
 
I guess I need some kind of an editor. There was one for MS-DOS, named pctools.

EDIT: i did dd if=/dev/sda of=mbr.bin bs=512 count=1
With 'hexdump -C mbr.bin' I saw the entry offset is 1BE. I could blank the entry using dd itself /dev/zero, but it's too risky. I need to be able to edit mbr.bin. Then I write it to disk with dd.

smallpond 11-07-2017 03:04 PM

You could use gparted for a graphical tool, or gfdisk for a good command line tool, or fdisk for the most basic partition editor on Linux. Making a backup like you did with dd is a good idea before you edit the partition table. You should save it to a USB stick.

stf92 11-07-2017 03:31 PM

Thanks. Gparted I must first write it to a pendrive. I saw vi can do it with :%!xxd But when I use this command, the buffer completely changes. I don't understand!

EDIT: Also I did
dd if=/dev/zero of=mbr.bin bs=1 count=16 seek=446

but dd erases truncates after the last byte written. That is, the new file changes to 446+16 bytes long.

IsaacKuo 11-07-2017 04:02 PM

You could build a modified file mbr2.bin

That way, you add the rest of the file from mbr.bin after the truncated part.

jefro 11-07-2017 09:29 PM

I might be tempted to use a partition editor like ranish on ultimate boot cd to usb if tools like fdisk or others won't work. https://www.howtogeek.com/106873/how...ions-on-linux/

ondoho 11-08-2017 12:34 AM

x-y-problem.

WHY do you THINK you need to erase an entry in the partition table?

DavidMcCann 11-08-2017 11:46 AM

If you have a live disk or usb stick of Linux, you should find it has Gparted on it. As a Slacker, you probably won't have one, but getting and keeping something like SystemRescueCd or GParted Live is generally a good idea for system repair and data rescue.

stf92 11-09-2017 07:24 AM

I tried gparted but it fails to recognize the partition table though I am using one of the partition right now. I laughable not being able to do such a simple thing as this. I want to write 0x274ef5278 at offset 45 in a file and I can't. Is there not a program to do this?

michaelk 11-09-2017 08:11 AM

If you want to write a few bytes to a file why not use a hex editor?

bless, ghex, khex, emacs, vi are just a few.


All times are GMT -5. The time now is 02:39 PM.