I have a flash usb drive and up till now it has worked well. Recently I recorded iso to it using dd. Now I want to delete it.

$ lsblk
sdb      8:16   1  14.6G  0 disk 
└─sdb1   8:17   1  14.5G  0 part /media/alex/ARCH_201404
sr0     11:0    1  1024M  0 rom  

$ mount 

/dev/sdb1 on /media/alex/ARCH_201404 type iso9660    (ro,nosuid,nodev,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)

When I did this

$ sudo dd ibs=4096 count=1 if=/dev/zero of=/dev/sdb1
1+0 records in
8+0 records out
4096 bytes (4.1 kB) copied, 0.00053675 s, 7.6 MB/s

it seemed to succeed but when I explored the usb flash all the files were still there. When did this:

sudo rm -r /media/alex/ARCH_201404/*

and I got the error:

rm: cannot remove ‘/media/alex/ARCH_201404/loader/entries/uefi-shell-v1-x86_64.conf’: Read-only file system
rm: cannot remove ‘/media/alex/ARCH_201404/loader/entries/uefi-shell-v2-x86_64.conf’: Read-only file system
rm: cannot remove ‘/media/alex/ARCH_201404/loader/loader.conf’: Read-only file system

What can I do about it?

  • Unmout the drive before you dd anything to it! Now you need to reformat it (after you've unmounted it if you can). – Mat Apr 27 '14 at 7:20
  • 1
    drive is mounted in readonly mode, please remount it in readwrite mode, so that you can be able to remove files from that. – Avinash Raj Apr 27 '14 at 7:26
  • 1
    @AvinashRaj the file system cannot be mounted in read/write since its type is iso9660. This file system is always in read only. – eppesuig Apr 27 '14 at 11:25

You only zeroed the first 4kb of the partition. Usually all file systems keep a few unused blocks at the start of their partition in order to give space to boot loaders that might be installed on the partition itself. I think that at least 16 blocks are always kept unused.

You copied, with dd, a file system of type ISO 9660, so you have 2048 bytes blocks.

ISO 9660 reserve about 32kb for boot loaders, as explained here: http://wiki.osdev.org/ISO_9660#System_Area

So, in order to really delete the content of the partition, you may need to delete at least the first 1Mb.

| improve this answer | |
  • @Alex - this guy is correct. I didn't realize it, but I guess specified only 4kb when I meant 4mb. With dd you can just use bs=4M or bs=$((4*1024*1024)). Thanks, eppesuig. By the way - this is the reason I suggested you zero out the iso partition table in the first place. They're a pain on usb. – mikeserv Apr 27 '14 at 10:15

You may try remounting the drive with read-write flag. Something like following should work.

# mount -o remount,rw /dev/sdb1 /media/alex/ARCH_201404
| improve this answer | |
  • 1
    This cannot work: iso9660 is a read-only file system type. – eppesuig Apr 27 '14 at 11:14
  • Yes that correct. One can recreate the iso9660 fs using 'mkisofs' command. – shantanoo Apr 29 '14 at 17:59

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.