Pages

Friday, November 18, 2011

How to format Flash/Pen Drive in Linux


Note: I have used my device name and number in examples, you have to change it
as your device name and number, otherwise unwanted device data will be wiped
out.

Put your USB flash drive in one of your computer's free USB ports. After a few
seconds, Linux will automatically recognize it and an icon for it will appear on
your desktop. If pen drive doesn't mounted automatically, login as root and try
to mount it, still it is not mounted there may be a problem with pen drive or it
is defective.

Finding device:


Very very first thing is you should to know what device you are working with.
For that you can use any one of the following methods.

Method 1: Using ls /dev/sd* command

First make sure your usb drive is not plugged in. Then run:

[venu@ras ~]$ ls /dev/sd*
/dev/sda /dev/sda10 /dev/sda12 /dev/sda2 /dev/sda6 /dev/sda8
/dev/sda1 /dev/sda11 /dev/sda13 /dev/sda5 /dev/sda7 /dev/sda9

Once you have done that, put in your pen drive and run the above command again.

[venu@ras ~]$ ls /dev/sd*
/dev/sda /dev/sda10 /dev/sda12 /dev/sda2 /dev/sda6 /dev/sda8 /dev/sdb
/dev/sda1 /dev/sda11 /dev/sda13 /dev/sda5 /dev/sda7 /dev/sda9 /dev/sdb1

Whatever drive (ex sdb) was not there before is your pen drive. From the above
list my pen drive is sdb. Don't be confuse with /dev/sdb and /dev/sdb1, sdb is
a drive and sdb1 is first partition in that drive.

Method 2: Using df command

[venu@ras ~]$ df
Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda10 29753556 8008860 20208884 29% /
/dev/sda12 19840892 1528664 17288088 9% /msfiles
/dev/sda11 21825108 16772836 3925716 82% /venu
tmpfs 1032232 0 1032232 0% /dev/shm
/dev/sdb1 1947636 4 1947632 1% /media/VENU

As you can see above my pen drive (/dev/sdb1) is mounted at /media/VENU. If you
have any doubt about which one is your pen drive, do same thing as in method1.
Run df command before and after inserting pen drive.

Method 3: dmesg | tail

[venu@ras ~]$ dmesg | tail
sdb: assuming drive cache: write through
SCSI device sdb: 3903359 512-byte hdwr sectors (1999 MB)
sdb: Write Protect is off
sdb: Mode Sense: 0b 00 00 08
sdb: assuming drive cache: write through
sdb: sdb1
sd 8:0:0:0: Attached scsi removable disk sdb
sd 8:0:0:0: Attached scsi generic sg1 type 0
usb-storage: device scan complete
SELinux: initialized (dev sdb1, type vfat), uses genfs_contexts

Method 4: mount -l

[venu@ras ~]$ mount -l
/dev/sda10 on / type ext3 (rw) [/]
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda12 on /msfiles type ext3 (rw) [/msfiles1]
/dev/sda11 on /venu type ext3 (rw) [/venu1]
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sdb1 on /media/VENU type vfat (rw,nosuid,nodev,shortname=winnt,uid=500)
[VENU]

Method 5: fdisk -l

fdisk command need root privileges. So login as root and run the command:

[root@ras ~]# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 5099 40957686 7 HPFS/NTFS
/dev/sda2 5100 60800 447418282+ f W95 Ext'd (LBA)
/dev/sda5 5100 10198 40957686 7 HPFS/NTFS
/dev/sda10 50994 54817 30716248+ 83 Linux
/dev/sda11 54818 57622 22531131 83 Linux
/dev/sda12 57623 60172 20482843+ 83 Linux
/dev/sda13 60173 60694 4192933+ 82 Linux swap / Solaris

Disk /dev/sdb: 1998 MB, 1998519808 bytes
32 heads, 63 sectors/track, 1936 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 1936 1951456+ b W95 FAT32

fdisk -l displays all detected drives even drive is unmounted.

Formatting pen drive:


First decide which file system you want. FAT32 is probably the file system you
want, but that's up to you. Ext3 may not be work on windows, It asks for fomatt-
ing.

1.Once you have Identified your pen drive, unmount it.

[root@ras ~]# umount /dev/sdb1

2.Format pen drive now.

Depending on distribution different commands are available for formatting, but
in general most used ones that I have seen are mkdosfs or mkfs.vfat for FAT32
and mke2fs or mkfs.ext3 for Linux filesystems.

For Ms-Dos or Windows file system:

Use mkdosfs -n "Label" -I /dev/sdx, Replace Label with the name you want the
pen drive to have and /dev/sdx with your drive.

[root@ras ~]# mkdosfs -n "KVMREDDY" -I /dev/sdb1
mkdosfs 2.11 (12 Mar 2005)
or
[root@ras ~]# mkfs.vfat -n "KVMREDDY" -I /dev/sdb1
mkfs.vfat 2.11 (12 Mar 2005)

(Note: I – capital letter of i )

If you don't want any Label then no need to supply option n. switch I will
force mkdosfs to work properly but it is not mandatory, you can remove that
also.

For Linux File system:

Use mkfs.ext3 -L "Label" /dev/sdx for ext3 file system or mke2fs -L 'Label'
/dev/sdx
for ex2, Replace Label with the name you want the pen drive to have
and /dev/sdx with your drive.

Ext3 file system:

[root@ras ~]# mkfs.ext3 -L "KVMREDDY" /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=KVMREDDY
OS type: Linux
.............................
[root@ras ~]#

ext2 file system:

[root@ras ~]# mke2fs -L 'VENU' /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=VENU
OS type: Linux
...........................
[root@ras ~]#

After formatting you will be returned to the prompt then remove and insert the
pen drive to have mounted again.

22 comments:

  1. Hi that was useful info, thanks for sharing

    ReplyDelete
  2. I am using Scientific Linux. I have tried the above commands but I have not been able to format a flash that has been infected by viruses. Thank you for your contribution.
    Victor

    ReplyDelete
  3. Replies
    1. I was scratching my head trying to figure out how to reformat my new ScanDisk flashdrive. Control Center wouldn't let me do it, but your way worked great. Thanks a million!

      Delete
  4. i have a sandisk pen drive and its current format is RAR i want to change in fat32 format but i couldn't, i have also use the function of disk utility but no result found i am using ubuntu 12.04

    PLEASE HELP ME

    thanks in advance

    ReplyDelete
  5. It is the easiest way is to open your flash drive from the drop down menu on the right then click the partition tab then click format to and then pick fat 32 system and then format the drive.
    ----------------------------------------------------------------------
    Hybrid Cloud

    ReplyDelete
  6. it's not work please tell me the the other solution !

    ReplyDelete
  7. Hi Venu,
    Many Thanks for this simple easy steps.

    ReplyDelete
  8. Hi Rajan
    Can you give me the data what u r getting. If possible send screen shot.
    r u unmounted your Pendrive before formatting it.
    if possible post bellow commands output.
    fdisk -l
    which mkdosfs or which mkfs

    ReplyDelete
  9. Respected sir,
    i have use the 'Disk utility' for formatting and also use those commands which are written in this page on the terminal but nothing happen .
    the error is ....
    "Error creating file system: helper exited with exit code 1: cannot mount /dev/sdb at /var/run/udisks/job-mkfs-jF0l6C: Invalid argument"

    and after run the command fdisk -l the out put is ..

    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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
    Disk identifier: 0x0008a3a8

    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 972771327 486384640 83 Linux
    /dev/sda2 972773374 976771071 1998849 5 Extended
    /dev/sda5 972773376 976771071 1998848 82 Linux swap / Solaris

    Disk /dev/sdb: 67 MB, 67108864 bytes
    3 heads, 43 sectors/track, 1016 cylinders, total 131072 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
    Disk identifier: 0x00000000

    Disk /dev/sdb doesn't contain a valid partition table

    Please help me sir

    ReplyDelete
  10. Dear Rajan,

    I think your partition table is corrupted or your flash drive file system is not supported by your OS. Give me two more commands output

    fdisk -l /dev/sdb

    sfdisk -d /dev/sdb | sfdisk --force /dev/sdb

    ReplyDelete
  11. The out put of the above commands are ....

    rajan@rajan-laptop:~$ fdisk -l /dev/sdb
    Cannot open /dev/sdb
    rajan@rajan-laptop:~$ sfdisk -d /dev/sdb | sfdisk --force /dev/sdb
    /dev/sdb: Permission denied
    /dev/sdb: Permission denied

    sfdisk:
    sfdisk: cannot open /dev/sdb for reading
    cannot open /dev/sdb read-write

    now what should be done

    ReplyDelete
  12. eliko@eliko-PC:~$ mount
    /dev/sda6 on / type ext4 (rw,errors=remount-ro,user_xattr,commit=0)
    proc on /proc type proc (rw,noexec,nosuid,nodev)
    sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
    fusectl on /sys/fs/fuse/connections type fusectl (rw)
    none on /sys/kernel/debug type debugfs (rw)
    none on /sys/kernel/security type securityfs (rw)
    udev on /dev type devtmpfs (rw,mode=0755)
    eliko@eliko-PC:~$ mkfs.vfat -F 32 -n USBFLASH -I /dev/sdb1
    mkfs.vfat 3.0.9 (31 Jan 2010)
    /dev/sdb1: Permission denied
    eliko@eliko-PC:~$ mkfs.vfat -F 32 -n USBFLASH -I /dev/sdb1

    mkfs.vfat 3.0.9 (31 Jan 2010)
    /dev/sdb1: Permission denied

    eliko@eliko-PC:~$ dmesg |tail
    [15924.839809] sd 14:0:0:0: [sdb] No Caching mode page present
    [15924.839817] sd 14:0:0:0: [sdb] Assuming drive cache: write through
    [15924.844414] sdb: sdb1
    [15924.847315] sd 14:0:0:0: [sdb] No Caching mode page present
    [15924.847322] sd 14:0:0:0: [sdb] Assuming drive cache: write through
    [15924.847329] sd 14:0:0:0: [sdb] Attached SCSI removable disk
    [15935.779511] FAT-fs (sdb1): error, invalid access to FAT (entry 0x0048f1ad)
    [15935.779516] FAT-fs (sdb1): Filesystem has been set read-only
    [15935.779837] FAT-fs (sdb1): error, invalid access to FAT (entry 0x19012eb8)
    [15935.780045] FAT-fs (sdb1): error, invalid access to FAT (entry 0x0eabf7cb)

    eliko@eliko-PC:~$ sudo mkfs.vfat -n ‘Label’ -I /dev/sdb
    mkfs.vfat 3.0.9 (31 Jan 2010)
    mkfs.vfat: unable to open /dev/sdb

    eliko@eliko-PC:~$ dmesg |tail
    [15924.844414] sdb: sdb1
    [15924.847315] sd 14:0:0:0: [sdb] No Caching mode page present
    [15924.847322] sd 14:0:0:0: [sdb] Assuming drive cache: write through
    [15924.847329] sd 14:0:0:0: [sdb] Attached SCSI removable disk
    [15935.779511] FAT-fs (sdb1): error, invalid access to FAT (entry 0x0048f1ad)
    [15935.779516] FAT-fs (sdb1): Filesystem has been set read-only
    [15935.779837] FAT-fs (sdb1): error, invalid access to FAT (entry 0x19012eb8)
    [15935.780045] FAT-fs (sdb1): error, invalid access to FAT (entry 0x0eabf7cb)
    [17370.072887] FAT-fs (sdb1): error, invalid access to FAT (entry 0x0048f1ad)
    [17370.073145] FAT-fs (sdb1): error, invalid access to FAT (entry 0x19012eb8)

    eliko@eliko-PC:~$ sudo umount /dev/sdb
    umount: /dev/sdb: не примонтирован

    eliko@eliko-PC:~$ sudo umount /dev/sdb1

    eliko@eliko-PC:~$ sudo mkfs.vfat -n ‘Label’ -I /dev/sdb1
    mkfs.vfat 3.0.9 (31 Jan 2010)
    mkfs.vfat: failed whilst writing FAT

    eliko@eliko-PC:~$ sudo umount /dev/sdb1

    eliko@eliko-PC:~$ sudo mkfs.vfat -n ‘Label’ -I /dev/sdb1
    mkfs.vfat 3.0.9 (31 Jan 2010)

    eliko@eliko-PC:~$ lsusb
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 002: ID 0bda:8197 Realtek Semiconductor Corp. RTL8187B Wireless Adapter
    Bus 001 Device 003: ID 064e:d104 Suyin Corp.
    Bus 001 Device 005: ID 0bda:0159 Realtek Semiconductor Corp. Digital Media Card Reader
    Bus 002 Device 008: ID 19d2:0016 ONDA Communication S.p.A.

    eliko@eliko-PC:~$ hdparm /dev/sdb
    /dev/sdb: Permission denied

    eliko@eliko-PC:~$ hdparm /dev/sdb1
    /dev/sdb1: Permission denied

    eliko@eliko-PC:~$ sudo umount /dev/sdb1

    eliko@eliko-PC:~$ sudo mkfs -t vfat /dev/sdb1
    mkfs.vfat 3.0.9 (31 Jan 2010)
    sudo eject /dev/sdb1
    eliko@eliko-PC:~$ sudo eject /dev/sdb1
    eliko@eliko-PC:~$ fdisk -l
    eliko@eliko-PC:~$ sudo umount /dev/sdb1
    umount: /dev/sdb1: не примонтирован
    eliko@eliko-PC:~$ sudo umount /dev/sdb
    umount: /dev/sdb: не примонтирован
    eliko@eliko-PC:~$ mkdosfs /dev/sdb1
    mkdosfs 3.0.9 (31 Jan 2010)
    /dev/sdb1: Permission denied
    eliko@eliko-PC:~$ mkfs.vfat /dev/sdb1
    mkfs.vfat 3.0.9 (31 Jan 2010)
    /dev/sdb1: Permission denied
    eliko@eliko-PC:~$ mkfs.vfat /dev/sdb
    mkfs.vfat 3.0.9 (31 Jan 2010)
    /dev/sdb: Permission denied

    ReplyDelete
  13. eliko@eliko-PC:~$ sudo fdisk -l

    Диск /dev/sda: 320.1 Гб, 320072933376 байт
    255 головок, 63 секторов/треков, 38913 цилиндров, всего 625142448 секторов
    Units = секторы of 1 * 512 = 512 bytes
    Размер сектора (логического/физического): 512 байт / 512 байт
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Идентификатор диска: 0xc83d8e54

    Устр-во Загр Начало Конец Блоки Id Система
    /dev/sda1 * 2048 821247 409600 27 Hidden NTFS WinRE
    /dev/sda2 821248 251951103 125564928 7 HPFS/NTFS/exFAT
    /dev/sda3 313391104 625141759 155875328 7 HPFS/NTFS/exFAT
    /dev/sda4 251953150 313391103 30718977 5 Расширенный
    /dev/sda5 251953152 258095103 3070976 82 Linux своп / Solaris
    /dev/sda6 258097152 313391103 27646976 83 Linux

    Пункты таблицы разделов расположены не в дисковом порядке

    Диск /dev/sdb: 8048 МБ, 8048869376 байт
    255 головок, 63 секторов/треков, 978 цилиндров, всего 15720448 секторов
    Units = секторы of 1 * 512 = 512 bytes
    Размер сектора (логического/физического): 512 байт / 512 байт
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Идентификатор диска: 0x00000000

    Устр-во Загр Начало Конец Блоки Id Система
    /dev/sdb1 8192 15711569 7851689 b W95 FAT32
    eliko@eliko-PC:~$ sudo umount /dev/sdb1
    umount: /dev/sdb1: не примонтирован
    eliko@eliko-PC:~$ sudo umount /dev/sdb1
    eliko@eliko-PC:~$ sudo mkdosfs -F 32 /dev/sdb1
    mkdosfs 3.0.9 (31 Jan 2010)
    eliko@eliko-PC:~$ dd if=/dev/zero of=/dev/sdb bs=1M
    dd: открытие «/dev/sdb»: Отказано в доступе
    eliko@eliko-PC:~$ dd if=/dev/urandom of=/dev/sdb bs=1M
    dd: открытие «/dev/sdb»: Отказано в доступе
    eliko@eliko-PC:~$ fdisk -l /dev/sdb
    Невозможно открыть /dev/sdb
    eliko@eliko-PC:~$ fdisk -l /dev/sdb
    Невозможно открыть /dev/sdb
    eliko@eliko-PC:~$ ls /dev/sd*
    /dev/sda /dev/sda2 /dev/sda4 /dev/sda6 /dev/sdb1
    /dev/sda1 /dev/sda3 /dev/sda5 /dev/sdb
    eliko@eliko-PC:~$ df
    Файловая система 1K-блоков Исп Доступно Исп% смонтирована на
    /dev/sda6 27214716 21205444 4626928 83% /
    udev 1459848 12 1459836 1% /dev
    tmpfs 586776 916 585860 1% /run
    none 5120 4 5116 1% /run/lock
    none 1466940 404 1466536 1% /run/shm
    /dev/sdb1 7847584 879360 6968224 12% /media/NO_NAME

    ReplyDelete
    Replies
    1. The root user should only be used for specific administration or monitoring tasks.
      try to logged in as super user.

      Delete
  14. eliko@eliko-PC:~$ dmesg | tail
    [20441.453708] sd 16:0:0:0: [sdb] Sense Key : Hardware Error [current]
    [20441.453713] sd 16:0:0:0: [sdb] Add. Sense: No additional sense information
    [20441.453718] sd 16:0:0:0: [sdb] CDB: Write(10): 2a 00 00 00 94 3e 00 00 f0 00
    [20441.453728] end_request: I/O error, dev sdb, sector 37950
    [20485.413839] FAT-fs (sdb1): error, invalid access to FAT (entry 0x0048f1ad)
    [20485.413844] FAT-fs (sdb1): Filesystem has been set read-only
    [20485.414216] FAT-fs (sdb1): error, invalid access to FAT (entry 0x19012eb8)
    [20485.414373] FAT-fs (sdb1): error, invalid access to FAT (entry 0x0eabf7cb)
    [20888.800365] FAT-fs (sdb1): error, invalid access to FAT (entry 0x0048f1ad)
    [20888.815662] FAT-fs (sdb1): error, invalid access to FAT (entry 0x19012eb8)
    eliko@eliko-PC:~$ mount -l
    /dev/sda6 on / type ext4 (rw,errors=remount-ro,user_xattr,commit=0)
    proc on /proc type proc (rw,noexec,nosuid,nodev)
    sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
    fusectl on /sys/fs/fuse/connections type fusectl (rw)
    none on /sys/kernel/debug type debugfs (rw)
    none on /sys/kernel/security type securityfs (rw)
    udev on /dev type devtmpfs (rw,mode=0755)
    devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
    tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
    none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
    none on /run/shm type tmpfs (rw,nosuid,nodev)
    binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
    gvfs-fuse-daemon on /home/eliko/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=eliko)
    /dev/sdb1 on /media/NO_NAME type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks) [NO_NAME]
    eliko@eliko-PC:~$ sudo fdisk -l

    Диск /dev/sda: 320.1 Гб, 320072933376 байт
    255 головок, 63 секторов/треков, 38913 цилиндров, всего 625142448 секторов
    Units = секторы of 1 * 512 = 512 bytes
    Размер сектора (логического/физического): 512 байт / 512 байт
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Идентификатор диска: 0xc83d8e54

    Устр-во Загр Начало Конец Блоки Id Система
    /dev/sda1 * 2048 821247 409600 27 Hidden NTFS WinRE
    /dev/sda2 821248 251951103 125564928 7 HPFS/NTFS/exFAT
    /dev/sda3 313391104 625141759 155875328 7 HPFS/NTFS/exFAT
    /dev/sda4 251953150 313391103 30718977 5 Расширенный
    /dev/sda5 251953152 258095103 3070976 82 Linux своп / Solaris
    /dev/sda6 258097152 313391103 27646976 83 Linux

    Пункты таблицы разделов расположены не в дисковом порядке

    Диск /dev/sdb: 8048 МБ, 8048869376 байт
    255 головок, 63 секторов/треков, 978 цилиндров, всего 15720448 секторов
    Units = секторы of 1 * 512 = 512 bytes
    Размер сектора (логического/физического): 512 байт / 512 байт
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Идентификатор диска: 0x00000000

    Устр-во Загр Начало Конец Блоки Id Система
    /dev/sdb1 8192 15711569 7851689 b W95 FAT32
    eliko@eliko-PC:~$ umount /dev/sdb1
    eliko@eliko-PC:~$ sudo mkdosfs -n "KVMREDDY" -I /dev/sdb1
    mkdosfs 3.0.9 (31 Jan 2010)

    mkfs.vfat -n "KVMREDDY" -I /dev/sdb1
    sudo mkfs.vfat -n "KVMREDDY" -I /dev/sdb1
    eliko@eliko-PC:~$
    eliko@eliko-PC:~$ mkfs.vfat -n "KVMREDDY" -I /dev/sdb1
    mkfs.vfat 3.0.9 (31 Jan 2010)
    /dev/sdb1: Permission denied
    eliko@eliko-PC:~$ sudo mkfs.vfat -n "KVMREDDY" -I /dev/sdb1
    mkfs.vfat 3.0.9 (31 Jan 2010)

    doesn't work.

    ReplyDelete
  15. Respected venu k sir
    as you guided me to run the commands
    fdisk -l /dev/sdb

    sfdisk -d /dev/sdb | sfdisk --force /dev/sdb

    the out puts are ...

    ajan@rajan-laptop:~$ fdisk -l /dev/sdb
    Cannot open /dev/sdb
    rajan@rajan-laptop:~$ sfdisk -d /dev/sdb | sfdisk --force /dev/sdb
    /dev/sdb: Permission denied
    /dev/sdb: Permission denied

    sfdisk:
    sfdisk: cannot open /dev/sdb for reading
    cannot open /dev/sdb read-write

    now please guide me further ...

    ReplyDelete
    Replies
    1. Dear Rajan,

      You need super user privileges to do this. Your command prompt showing that you logged in as a normal user. Check method 5, I pointed there you need super user privileges.

      Delete
  16. thanks for reply me
    venu k sir
    the out put of the method no 5 is ...

    root@rajan-laptop:/home/rajan# fdisk -l

    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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
    Disk identifier: 0x0008a3a8

    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 972771327 486384640 83 Linux
    /dev/sda2 972773374 976771071 1998849 5 Extended
    /dev/sda5 972773376 976771071 1998848 82 Linux swap / Solaris

    Disk /dev/sdb: 67 MB, 67108864 bytes
    3 heads, 43 sectors/track, 1016 cylinders, total 131072 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
    Disk identifier: 0x00000000

    Disk /dev/sdb doesn't contain a valid partition table

    now further ,what steps should be follow

    thanks...

    ReplyDelete
  17. Dear Rajan,

    I hope bellow solution may solve your issue. Delete old partition table and create new one on your device. It won't harm anything. Only caution on device number, check your device is /dev/sdb or not.

    I have ntfs formatted pen-drive. I have removed ntfs support from my system.

    [root@ras ~]# mount /dev/sdb1 /mnt/

    mount: unknown filesystem type 'ntfs'

    [root@ras ~]# fdisk -l /dev/sdb



    Disk /dev/sdb: 4022 MB, 4022337024 bytes

    1 heads, 63 sectors/track, 124700 cylinders

    Units = cylinders of 63 * 512 = 32256 bytes



    Device Boot Start End Blocks Id System

    /dev/sdb1 2 124695 3927861 7 HPFS/NTFS

    /dev/sdb2 124696 124696 31+ 21 Unknown


    [root@ras ~]# fdisk /dev/sdb
    . .................

    Command (m for help): d (here give value d then enter)

    Partition number (1-4): 1 (give 1 then enter)

    Command (m for help): n

    Command action

    e extended

    p primary partition (1-4)

    p (here you will see cursor is blinking, p and enter)
    Partition number (1-4): 1 (1 and enter)

    First cylinder (2-124700, default 2): (here you will see cursor is blinking don't
    enter anything just press enter)

    Using default value 2

    Last cylinder or +size or +sizeM or +sizeK (2-124695, default 124695):
    (here also blinking only press enter)

    Using default value 124695


    Command (m for help): w (w and enter)
    The partition table has been altered!


    Calling ioctl() to re-read partition table.

    Syncing disks.

    [root@ras ~]# partprobe /dev/sdb


    some times you will get “can not mount volume” window, close the window or click ok button.

    New partition table has been created on your volume. Now format it

    [root@ras ~]# mkfs.vfat -n "KVMREDDY" -I /dev/sdb1

    mkfs.vfat 2.11 (12 Mar 2005)
    [root@ras ~]# mount /dev/sdb1 /mnt/

    [root@ras ~]#

    If you still have a problem bring it to my attention.

    ReplyDelete
  18. thanks for sharing
    http://www.hitech-cloud.com/

    ReplyDelete