Link to home
Start Free TrialLog in
Avatar of kurajesh
kurajesh

asked on

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.

Avatar of Systech Admin
Systech Admin
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of Michael Eager
Michael Eager
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kurajesh
kurajesh

ASKER

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

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.
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



Run "fdisk -l /dev/sda" and show us the results.
it says
/dev/sda1 doesnt contain a valid partition table
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
please find the attachment
Screenshot.png
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

i tried to copy some files to usbdisk bt it is says

no space left on device where we have the space


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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>

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]#

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
how to set the protection , could you pls let me know the command
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it has worked perfectly fine. thanks eager.