-1

I have been having some trouble with my 16Gb USB. You see I decided to attempt to encrypt it using cryptsetup, and I have done this before without problems, but his time, when I was creating a filesystem (ntfs), my computer froze and at the end i had to perform a hard restart. This messed up the drive really bad! I had already installed one layer of AES 265-bit encryption, but when i open it, it seems to have a second layer of encryption. This second layer is not readable (because of the hard restart).

Basically the entire drive is locked in readonly mode. I really hope i can put ntfs in the drive again.

Some info (please request what you need):

BTW: The deice i would like to wipe is /dev/sdc (/dev/sdc1)

root@kali:~# ls -l /dev/sd*
brw-rw---- 1 root disk 8,  0 apr 15 08:32 /dev/sda
brw-rw---- 1 root disk 8,  1 apr 15 08:32 /dev/sda1
brw-rw---- 1 root disk 8,  2 apr 15 08:32 /dev/sda2
brw-rw---- 1 root disk 8,  3 apr 15 08:32 /dev/sda3
brw-rw---- 1 root disk 8,  4 apr 15 08:32 /dev/sda4
brw-rw---- 1 root disk 8, 16 apr 15 08:32 /dev/sdb
brw-rw---- 1 root disk 8, 17 apr 15 08:32 /dev/sdb1
brw-rw---- 1 root disk 8, 18 apr 15 08:32 /dev/sdb2
brw-rw---- 1 root disk 8, 19 apr 15 08:32 /dev/sdb3
brw-rw---- 1 root disk 8, 32 apr 15 08:04 /dev/sdc
brw-rw---- 1 root disk 8, 33 apr 15 08:04 /dev/sdc1

&

(parted) print devices 
/dev/sda (180GB)
/dev/sdb (124GB)
/dev/sdc (15,4GB)
/dev/mapper/luks-73c77bc9-710c-4e0a-9af7-0d1775e27acd (15,4GB)
/dev/mapper/sdb3 (121GB)

&

root@kali:~# cryptsetup luksDump /dev/sdc1
LUKS header information for /dev/sdc1

Version:        1
Cipher name:    aes
Cipher mode:    xts-plain64
Hash spec:      sha256
Payload offset: 4096
MK bits:        256

&

root@kali:~# fdisk -l
Disk /dev/sdc: 14,3 GiB, 15376000000 bytes, 30031250 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0c7b9850

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdc1        2048 30029823 30027776 14,3G  b W95 FAT32


Disk /dev/mapper/luks-73c77bc9-710c-4e0a-9af7-0d1775e27acd: 14,3 GiB, 15372124160 bytes, 30023680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

When i run: (notice i run as root)

root@kali:~# sudo umount /dev/sdc1
umount: /dev/sdc1: not mounted.
root@ralphiboi:~# sudo mkfs.ntfs /dev/sdc1
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes:   0%Error writing to /dev/sdc1: Operation not permitted
This should not happen.
root@kali:~# dd if=/dev/zero of=/dev/sdc1
dd: writing to '/dev/sdc1': Operation not permitted
1+0 records in
0+0 records out
0 bytes copied, 0,000281734 s, 0,0 kB/s
root@kali:~# dd if=/dev/zero of=/dev/sdc
dd: failed to open '/dev/sdc': Read-only file system
root@kali:~# dd if=/dev/zero of=/dev/sdc1
dd: writing to '/dev/sdc1': Operation not permitted
1+0 records in
0+0 records out
0 bytes copied, 0,000284234 s, 0,0 kB/s
root@kali:~# sudo wipefs /dev/sdc1
offset               type
----------------------------------------------------------------
0x0                  crypto_LUKS   [crypto]
                     UUID:  73c77bc9-710c-4e0a-9af7-0d1775e27acd
1

What I understood is you want to wipe /dev/sdc1.

You can do that by re-creating the file system as follows

sudo umount /dev/sdc1
Install ntfs-3g if already not installed
sudo mkfs.ntfs /dev/sdc1

If the above method failed first fill the entire partition with zero as follows then try the above

dd if=/dev/zero of=/dev/sdc1

NOTE

  1. If you're more familiar with GUI you may use Gparted instead mkfs

  2. Further /dev/sdc is not same as /dev/sdc1. Make sure what you want to wipe. sdc is the whole disk including partition table. /dev/sdc1 is a partition on /dev/sdc.

  3. To fill a disk with zero using dd is time consuming and considering disk helth it's recommend as a last resort. To wipe file system on /dev/sdc1 you may use wipefs as follows.

    sudo wipefs /dev/sdc1         //this will list offset of all existing file system
    sudo wipefs -o offset /dev/sdc1 // this will wipe the actual file system
    
  4. To remove partition table and recreate one (if necessary) you may use fdisk (recommend if you use msdos partition table) or gdisk (recommend if you chose GNU partition table). Alternatively Gparted as GUI will do the work.

  • It just printed exactly what i got when i was trying this before: "Operation not permitted". The problem isn't that i don't know how to wipe and reset a drive, but rather that i can't. It is, as i stated, created with cryptsetup. I need some sort of HARD OVERWRITE to bypass the cryptsetup blocking. Or instructions on how to undo the encryption (aes 256-bit). (I have the key) – Carl Jacksson Apr 16 '18 at 18:12
  • @CarlJacksson With which command you're getting "Operation not permitted" Error? Is the error from dd if=/dev/zero of=/dev/sdc1? If so try the same command appended with sudo i.e. sudo dd if=/dev/zero of=/dev/sdc1. – Abhik Bose Apr 16 '18 at 20:37
  • As i mentioned in the edited question (I run as root). sudo didn't change anything. still operation not permitted – Carl Jacksson Apr 17 '18 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.