Format windows (NTFS) hard drive on Ubuntu using command line

21,965

Solution 1

Depending on who set up the old Windows machine (ie: if it's from HP, Lenovo, etc) you may have many different partitions on the disk that you normally wouldn't see with Windows. Those partitions might include recovery, unused space, etc. As mentioned in the answer above, use fdisk to see the partitions.

fdisk -l /dev/sdb

Using that information you can find out which partition is where the files you need are located. The largest partition is probably the one you want.

Depending on your distribution and version of Windows, you might need to get the ntfs-4g package in order to mount the disk. It looks like you wanted to mount it readonly and that you expect it to be ntfs3 based on your fstab entry.

mount -o ro /dev/sdbX /media/Microsoft

For the second part of the question you should have several options depending on what you want to do. You can make a normal file systems with mkfs or you could create a logical volume. If you have a modern installation of a recent linux distribution then your system is more than likely using LVM - you can check with the command "vgs". If you receive output with details about a volume group then LVM is in place. You could add the disk to LVM to expand your existing partitions or create a new, independent disk that is mounted somewhere separately.

Solution 2

Find the partitions of /dev/sdb,and mount the right one which contain files you need to backup.Try below to list partitions of /dev/sdb:

sudo fdisk -l /dev/sdb

No need to edit /etc/fstab to mount.Just use the command like this.(man mount)

sudo mount -t type device dir

You need to specify the type,maybe ntfs or vfat,cause it is windows partitions.

After that create partition using fdisk/gparted,then build filesystem using mkfs,mkfs.ext3,mkfs.ext4,anything you need.

Solution 3

firt mount the partition by:

sudo fdisk -l or mount

sudo umount /dev/sdb1

sudo mkfs.vfat -n usbname -I /dev/sdb1

or

sudo mkntfs /dev/sdb1

or any format for example .ext3, .ext4 and ...

Share:
21,965

Related videos on Youtube

c11ada
Author by

c11ada

Updated on September 18, 2022

Comments

  • c11ada
    c11ada over 1 year

    I had an old Windows machine which recently died. So I decided to put the hard drive into my Ubuntu server. This hard drive is currently NTFS file format, the Disk info is as follows

       description: ATA Disk
       product: SAMSUNG HD502HI
       physical id: 0.0.0
       bus info: scsi@1:0.0.0
       logical name: /dev/sdb
       version: 1AG0
       serial:
       size: 465GiB (500GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 sectorsize=512 signature=000c6181
    

    Part One

    I need to get some files of this hard drive, but when I try to mount the hard drive all that seems to mount is the /boot partition. Here is what I am doing

    Edit fstab and add the following:

    /dev/sdb /media/Microsoft ntfs-3g defaults,locale=en_US.utf8 0 0
    

    Then after this I mount using the following command

    sudo mount -ro /dev/sdb /media/Microsoft 
    

    Can some one tell me what I am doing wrong, and how I can mount the right partition?

    Part Two

    Once I have successfully mounted the hard drive and copied the files. How do I go about formatting the hard drive and make it usable for my Linux system? From what I have read I have to do something like

    mkfs.ext3 /dev/sdb
    

    then create a partition using fdisk

    Can some one direct me to what I actually need to do?

  • dhag
    dhag about 9 years
    The question asked how to make the disk usable primarily by a Linux system, so suggesting Windows file systems may not be the most useful advice...