• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

external hard disk in linux

i have purchased a new external hdd and i need to format this in order to use in my linux server.
it is itb hdd and how do i format that same in linux to get the full space for my linux server.

0
kurajesh
Asked:
kurajesh
  • 10
  • 8
  • 2
  • +1
7 Solutions
 
eagerCommented:
If the drive is not partitioned, the previous examples will not work.

Plug in the USB drive.  
Run "dmesg".  You should see some lines at the end which tell you the drive letter which was assigned to the drive.  
Run "fdisk /dev/sd?"  (use the drive letter assigned)
Create a partition using the full disk.  Make sure that it is assigned type 83 (Linux).
Run 'mke2fs -j /dev/sd?1" to create the file system.
Create a mount point and mount the drive.

0
 
kurajeshSenior Systems AnalystAuthor Commented:
initially i have copied some files to this hard disk and after doing mke2fs -j /dev/sda1 i can see the same files which was copied earlier. i understand by mke2fs it will format the disk also right. but still the files are there

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
KishorDasCommented:
Even you format the external harddisk using mkfs or mke2fs command but the kernel is using the older partition table. So reload the partition table using the following command, assuming your external hard disk is detected as /dev/hdd.

# partprobe /dev/hdd

Hope you will now see the data you copied after formating the drive.

Thank You.
0
 
kurajeshSenior Systems AnalystAuthor Commented:
i have given the command
partprobe /dev/sda1.

but still the files are there.
how can i utilise the full space (1tb) for my linux server by fomatting the entire data



0
 
eagerCommented:
Run "fdisk -l /dev/sda" and show us the results.
0
 
kurajeshSenior Systems AnalystAuthor Commented:
it says
/dev/sda1 doesnt contain a valid partition table
0
 
eagerCommented:
Run "fdisk -l /dev/sda" not "fdisk -l /dev/sda1".
0
 
kurajeshSenior Systems AnalystAuthor Commented:
please find the attachment
Screenshot.png
0
 
eagerCommented:
Your disk has an NTFS partition.

As root, run "fdisk /dev/sda"
Change the Id of the partition to 83 (Linux) using the 't' command in fdisk.
Exit fdisk

When you run "fdisk -l /dev/sda" it should now show the Id as 83 and System as Linux.

Run "mke2fs -j /dev/sda1".  This will format the partition.

Create a mount point, which is just a directory, something like "mkdir /mnt/d" or where ever you chose.
Mount the drive:  "mount /dev/sda1 /mnt/d".
0
 
kurajeshSenior Systems AnalystAuthor Commented:
i have just given those commands.

now the mount point is
 mount /dev/sda1 /mnt/usbdrive/
now if give ls it says
[root@dr usbdrive]# ls
lost+found


whereas

[root@dr usbdrive]# cd /media/
[root@dr media]# cd My_Passport/
[root@dr My_Passport]# ls
115102upgrade  1159install

it shows two directories which were copied earlier

0
 
kurajeshSenior Systems AnalystAuthor Commented:
i tried to copy some files to usbdisk bt it is says

no space left on device where we have the space


0
 
eagerCommented:
Please try to give more complete information.  Give the command you enter and the results.

Run "df" and give the full listing.

What is mounted at /media/My_Passport?

Run "fdisl -l /dev/sda" and give the listing.
0
 
KishorDasCommented:
1. Your external hard is having an NTFS file system. If you want to use that NTFS patition then format your device using mkfs.ntfs /dev/sda1, but yor linux device will mount that device as a read-only device/medium. To wite to the ntfs patition from linux you have to use the ntfs-3g program to mount your ntfs filesystem device as a read write device.

2. Or you delete your ntfs partition and create new vfat partition tha can be accessibleby both windows and linux OS.
 # fdisk /dev/sda

Then use the command d to delete the partition, when asked press 1 to delete the /dev/sda1 .

Then press n to create a new partition, and change the partition id to b from 83.

Then press wq
To save the settings
THEN USE

# partprobe /dev/sda
to reload the new partition table

# mkfs.vfat /dev/sda1

Once formatting is completed your device will be detected and mounted as a read write device and you can store data to tha DEVICE>
0
 
kurajeshSenior Systems AnalystAuthor Commented:

i have done the following

fdisk /dev/sda
selected d to delete partition and also n for a new one.

now the output is
[root@dr usbdrive]# fdisk -l /dev/sda

Disk /dev/sda: 1000.1 GB, 1000170586112 bytes
255 heads, 63 sectors/track, 121597 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1      121597   976727871    5  Extended
[root@dr usbdrive]#

0
 
eagerCommented:
You have created an extended partition, which is a container for logical partitions.

Do the following:
  fdisk /dev/sda
  delete partition 5
  create partition 1 (primary partition)
  change type to 83 (Linux)

Run "fdisk -l /dev/sda" and include the output here.

Run "mke2fs" as previously mentioned.   Mount partition.  

Run "df" and include complete output here.
0
 
kurajeshSenior Systems AnalystAuthor Commented:
root@dr ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d1p1     50394964  28412672  19422336  60% /
/dev/cciss/c0d1p7    191643740  97436348  84472408  54% /DR
/dev/cciss/c0d0p7    184368976   1078916 173924572   1% /DR1
/dev/cciss/c0d1p2    151187172 103065604  40441696  72% /apps
/dev/cciss/c0d0p2    171347196 147793016  14850164  91% /apps1
/dev/cciss/c0d0p5     85672504  66929056  14391444  83% /apps2
/dev/cciss/c0d1p5     85672504  69080016  12240484  85% /apps3
/dev/cciss/c0d0p3    110871104  90648464  14590656  87% /apps4
/dev/cciss/c0d1p3     85672536  67263528  14057000  83% /apps5
/dev/cciss/c0d0p1      2016016     44760   1868844   3% /boot
none                   2072752         0   2072752   0% /dev/shm
/dev/cciss/c0d0p6     10080488     56036   9512384   1% /home
/dev/sda1            961401996    110656 912454948   1% /mnt/usbdrive
[root@dr ~]# fdisk -l /dev/sda

Disk /dev/sda: 1000.1 GB, 1000170586112 bytes
255 heads, 63 sectors/track, 121597 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1      121597   976727871   83  Linux
[root@dr ~]#



this was the output and i assume that now files can be copied to my usb drive

0
 
eagerCommented:
Make sure that the protections on /mnt/usbdrive are set to 0777.  

You should be able to store files on the USB drive.


0
 
kurajeshSenior Systems AnalystAuthor Commented:
how to set the protection , could you pls let me know the command
0
 
eagerCommented:
As root:
  chmod 0777 /mnt/usbdrive
0
 
kurajeshSenior Systems AnalystAuthor Commented:
it has worked perfectly fine. thanks eager.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 10
  • 8
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now