0

How do I access harddisk in ubuntu? "/ dev / sdb" is just a node. The code I added below was coded to replace zero with the data on the entire disk. but what I noticed later is that there is no "/ dev / sdb" dimension.

import os
def main(sektor):
    s=sektor
    if os.name == "nt":
        print(read_sector(r"\\.\physicaldrive0",s-1))
        wipe(r"\\.\physicaldrive0",s-1)
        print("----------------------------------------------------------------------------------------------------------------------------------------------------------------------")
        print(read_sector(r"\\.\physicaldrive0",s-1))
    else:
        print(read_sector("/dev/sdb",s-1))
        print("-----------------------------------------------------------------------------------------------------------------------------------------------------------------------")
        wipe("/dev/sdb",s-1)
        print(read_sector("/dev/sdb",s-1))
def read_sector(disk, sector_no=0):
    f = open(disk, 'rb')
    f.seek(sector_no * 512)
    read = f.read(512)
    return read

def wipe(disk,sector_no=0):
    w= open(disk, 'wb')
    w.seek(sector_no*512)
    byte_arr = [0]
    binary_format = bytearray(byte_arr)
    for i in range(512):
        w.seek((sector_no*512)+i)
        w.write(binary_format)
    w.close()

if __name__ == "__main__":
    main(16) 
  • 'here is no "/ dev / sdb" dimension.' could you explain what do you mean? – Michał Walenciak Feb 24 '20 at 12:57
  • There is a sdb file in the "/ dev" directory. right click shows 0 bytes when properties are made. Data is still on the disk when I open it with open ("/ dev / sdb", "wb") and print 0 to the last sector of the disk. should give an alert that it should normally be deleted or formatted. I'm using translate. – Muhammet Onur Aslan Feb 24 '20 at 13:24
  • Please consider getting help from someone who speaks english, as it is hard to understand what you mean when you use translator. – Michał Walenciak Feb 25 '20 at 13:12

0 Answers0