Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
.......
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?

share|improve this question
    
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 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 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 at 11:25

2 Answers 2

up vote 3 down vote accepted

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.

share|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 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
share|improve this answer
1  
This cannot work: iso9660 is a read-only file system type. –  eppesuig Apr 27 at 11:14
    
Yes that correct. One can recreate the iso9660 fs using 'mkisofs' command. –  shantanoo Apr 29 at 17:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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