LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-10-2010, 03:54 PM   #1
matt_thumper
Member
 
Registered: Feb 2010
Posts: 37

Rep: Reputation: 15
Formatting and Accessing the Secondary Drive


OK, this is the question asked ALOT, but I can't find the 1-2-3 solution that should be available for this common question. I do apologize for the repeat question...but telling me to read the documentation, reference material, or FAQ won't help because I have tried. (And yes, I am kind of slow...OK, stupid, I admit it)

I have a secondary drive on my new RedHat Linux computer and I want to make it permanently accessible from the RedHat system that is now running on the computer.

It is an old Windows NTFS drive that was a secondary drive when this was a Windows machine.

What do I need to do to, and how do I do it:
1) Format it into a format that Linux uses.
2) After it is formatted correctly, permanently mount it so it will always be accessible
3) After it is successfully formatted and mounted, how do I access it? (For example, to add a new ascii text file to it via 'cp')

Thanks,
Matt
 
Old 03-10-2010, 04:21 PM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 97
how name of disk? fdisk -l
1. mkfs.ext4 partition. likely, should be changed partition table before.
2. mount partition mount_point; echo "partition mount_point ext4 default 1 2" >> /etc/fstab
3. partition is in mount_point. for example in /mnt/disk. cp file /mnt/disk/file
 
Old 03-10-2010, 04:42 PM   #3
penguiniator
Member
 
Registered: Feb 2004
Location: Olympia, WA
Distribution: SolydK
Posts: 442
Blog Entries: 3

Rep: Reputation: 60
Also, a mount point is directory. So, mkdir /path/to/mount/point.
 
Old 03-10-2010, 06:23 PM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Create a new directory on an existing drive, for example "/home/user-name/more_space".


Now it's all done as root.

Find your disk

Code:
fdisk -l
will show you all your disks
Which one is the old windows disk ? Well, you can see which one has a windows format in the list that fdisk just showed you.
Example output:
Code:
Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        4751    38057985   83  Linux
/dev/hda3            4752        4865      915705   82  Linux swap / Solaris
Notice there are no windows drives in that output.
If you wanted to work on this disk you would enter
Code:
fdisk /dev/hda
in the next section.

Prepare your disk


Code:
fdisk /dev/<device-name>
will allow you to work on that disk you found in the section above. Usually <device-name> is /dev/hdX or /dev/sdX. Ignore the numbers after the letters. The numbers are partitions. X stands for the letter you found in the last section.
sdX is for SATA or scsi disks. hdX is for ide or PATA disks.

Once in fdisk, there are several commands :

p print the partition table

n create a new partition

d delete a partition

q quit without saving changes

w write the new partition table and exit

So choose p to see what partitions there are on the disk. Then use d to delete the first partition you found on that disk.
Choose d until all partitions on that disk are gone.
Then choose n then p and create one primary partition (enter 1 when asked).
Make it the default size which is the whole of the disk (just hit enter)

Then enter w to save your changes, and q to quit fdisk.

Format your disk

Code:
mke2fs -j /dev/hdX1
(or /dev/sdX1 depending on what the device is called above)
will format the drive as ext3. ext4 is fairly new so stick to what works.

Mount your disk

edit /etc/fstab

add a line like :

Code:
/dev/hdX    /home/user-name/more_space      ext3       defaults     1 1
(the spaces above are actually tabs except between 1 1)
Save the file and restart your computer.
Code:
shutdown -r now
Done
You should be able to access and write to the new drive by writing to /home/user-name/more_space

It will show up in your file manager.

Last edited by smoker; 03-10-2010 at 07:06 PM.
 
Old 03-10-2010, 06:53 PM   #5
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
except that putting the mount point in your user's home directory limits the contents to that user, ok if only you use that machine
personally i would make a mount point under /media or /mnt
 
Old 03-10-2010, 07:10 PM   #6
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
@frieza

Yes but it's a bit early to be getting into permissions, don't you think ?
He can always mount it somewhere else later.
 
Old 03-11-2010, 04:29 PM   #7
matt_thumper
Member
 
Registered: Feb 2010
Posts: 37

Original Poster
Rep: Reputation: 15
smoker,
Many thanks. This is exactly what I needed.

Just a quick couple of follow-ups if you would be patient with me!

I may have gotten off track with the fdisk d (delete) option.
See - you couldn't hold my hand completely!
I did delete number 1.

After trying to delete others I moved on to the mke2fs command.
Here's what I get (and a follow up with fdisk -l):

/ : [162]

mke2fs -j /dev/hda
mke2fs 1.39 (29-May-2006)
/dev/hda is entire device, not just one partition!
Proceed anyway? (y,n) y
/dev/hda is apparently in use by the system; will not make a filesystem here!


/ : [164]

fdisk -l

Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda2 14 38913 312464250 8e Linux LVM

Disk /dev/hdb: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 9726 78124063+ 8e Linux LVM

/ : [165]

Do you have any idea what's up?

Again, thanks for your help.
Matt
 
Old 03-11-2010, 08:07 PM   #8
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Firstly, you have linux using part of that drive you are trying to wipe. Is that really what you want to do ?
Code:
/dev/hda2 14 38913 312464250 8e Linux LVM
I believe I covered that in Find your disk.

Secondly, you skipped the whole "making a new partition" part
Code:
So choose p to see what partitions there are on the disk. Then use d to delete the first partition you found on that disk.
Choose d until all partitions on that disk are gone.
Then choose n then p and create one primary partition (enter 1 when asked).
Make it the default size which is the whole of the disk (just hit enter)

Then enter w to save your changes, and q to quit fdisk.
So open fdisk again
Code:
fdisk /dev/hda
and create a new primary partition where the old one was, following the instructions above. You don't need to delete anything this time.

When you've done that, go on to the mke2fs part but the command will be
Code:
mke2fs -j /dev/hda1
(as I said it would be)

Once that's done, you are back on track. Carry on from Mount your disk.

Last edited by smoker; 03-11-2010 at 08:15 PM.
 
Old 03-12-2010, 01:12 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,744

Rep: Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924
As stated your NTFS disk is not being recognized or is it actually dev/hdb.

Typically two partitions are created with a default install i.e. /boot and LVM which will contain your / and swap. If you deleted hda1 then you have deleted your /boot. If you recreate the partition exactly like it was all of the files should still be intact.
 
Old 03-12-2010, 03:05 AM   #10
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Quote:
Originally Posted by michaelk View Post
As stated your NTFS disk is not being recognized or is it actually dev/hdb.

Typically two partitions are created with a default install i.e. /boot and LVM which will contain your / and swap. If you deleted hda1 then you have deleted your /boot. If you recreate the partition exactly like it was all of the files should still be intact.
Why is hdb1 showing as bootable ?
I know linux can't boot from an LVM...
A 23GB boot partition ?

Code:
Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda2 14 38913 312464250 8e Linux LVM

Code:
Disk /dev/hdb: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 9726 78124063+ 8e Linux LVM

Last edited by smoker; 03-12-2010 at 03:17 AM.
 
Old 03-12-2010, 03:27 AM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,744

Rep: Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924
It does not matter since linux does not use the boot flag.
 
Old 03-12-2010, 04:03 AM   #12
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
That doesn't explain a 23GB boot partition. But of course I don't know what the OP deleted. I would have thought it was unlikely that RH put the boot on an NTFS drive, and the OP was instructed to only delete non-linux partitions.

But I'm not there, so I don't know for sure.
 
Old 03-12-2010, 04:22 AM   #13
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,744

Rep: Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924
hda1 appeared to be about 100MB which is typical for /boot. How did you calculate 23GB?
 
Old 03-12-2010, 04:36 AM   #14
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda2 14 38913 312464250 8e Linux LVM


Start is at 14
End is at 38913

38899 * 8225280 bytes = ~ 297 GB

On a 320 GB drive that leaves about 23 GB ?
 
Old 03-12-2010, 04:48 AM   #15
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,744

Rep: Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924Reputation: 5924
My calculator:

38899 * 8225280 bytes = ~ 319 GB

or

14 * 8.22MB = ~106MB

Last edited by michaelk; 03-12-2010 at 04:49 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with samba client accessing Windows shares on secondary subnet KevinFink Linux - Networking 1 10-01-2009 01:13 AM
Booting Windows on secondary hard drive with Grub on primary drive mpmackenna Linux - General 1 11-09-2008 06:16 PM
formatting drive with EXT3 for data drive digity Linux - Newbie 2 09-16-2008 07:56 PM
SATA Secondary Drive in 9.1 BEI Slackware 3 09-18-2004 10:05 AM
formatting a secondary hard drive Bronzzy Linux - Newbie 2 03-27-2004 11:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 07:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration