Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to delete files/directories on Read-Only file system


    Hi folks,


    Ubuntu 7.10


    I have some files and directories on an USB flash pendrive. I can't delele them because on read-only filesystem.


    I tried;

    $ sudo mount -o remount,rw /mnt/maindir
    without result.


    If run;
    $ sudo mount -o remount,rw /dev/sdb1
    Code:
    mount: you must specify the filesystem type
    What filesystem I have to specify there?


    I don't expect running;
    Code:
    $ dd if=/dev/zero of=/dev/sdb1
    to erase the pendrive completely.


    Please shed me some light. TIA


    B.R.
    satimis

  2. #2
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,148
    What filesystem is on the drive? If it is FAT or FAT32 you can use
    Code:
    sudo mount -o remount,rw -t vfat /dev/sdb1

  3. #3
    Quote Originally Posted by bigtomrodney View Post
    What filesystem is on the drive? If it is FAT or FAT32 you can use
    Code:
    sudo mount -o remount,rw -t vfat /dev/sdb1
    Hi bigtomrodney,


    Thanks for your advice.


    Before reading your post I performed following test.


    This USB pendrive looks quite strange to me. I got it in a conference as gift from a multi-nation software company. It has files on it introducing their products taking up 57M out of 1G.


    After mount it with;
    Code:
    $ sudo mount /dev/sdb1 /mnt
    (I found /dev/sdb1 by runnint "fdisk -l")

    I can copy files on it. They can be deleted later.


    If running
    Code:
    $ cp -r /path/to/dir-A /mnt/
    Directory including files can be copied on the pendrive. But they can't be deleted later.


    Then I ran
    $ sudo mount -t vfat -o rw /dev/sdb1 /media/sdb1

    Still I can't delete the directories including their files.


    Later I found on running;
    $ fdisk -l
    Code:
    Disk /dev/sda: 160.0 GB, 160041885696 bytes
    255 heads, 63 sectors/track, 19457 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
    Disk /dev/sdb: 1056 MB, 1056702464 bytes
    33 heads, 62 sectors/track, 1008 cylinders
    Units = cylinders of 2046 * 512 = 1047552 bytes
    The partition table seems gone.


    Therefore I ran
    # fdisk /dev/sdb

    to repartition the drive and afterwards ran;

    # mkfs.ext2 -c /dev/sdb1
    it went though w/o complaint


    But I can't mount the pendrive

    $ sudo mount -t ext2 /dev/sdb1 /media/sdb1/
    Code:
    mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
           missing codepage or other error
           In some cases useful info is found in syslog - try
           dmesg | tail  or so

    Then I ran
    Code:
    dmesg | tail

    It asked me to run "e2fsck /dev/sdb1"

    $ sudo e2fsck /dev/sdb1
    Code:
    ....
    Inode 421 has INDEX_FL flag set but is not a directory.
    Clear HTree index<y>? 
    ......
    It took long time to run without finish. Therefore I manually exited it by pressing [Ctrl]+c


    I don't know how to proceed further. Nor I know what mistake I have committed. Please advise.


    TIA


    B.R.
    satimis

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •