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

fdiskfilesystemsmountntfs

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?

Best Answer

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.

Related Question