LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Accessing Another Hard Drive? (https://www.linuxquestions.org/questions/linux-hardware-18/accessing-another-hard-drive-425335/)

jvanv8 03-16-2006 06:15 AM

Accessing Another Hard Drive?
 
I'm a newbie so hopefully this will have an easy answer.

Our Raid Hard Drives (3) were filling up so we had the server company where the Linux server is running install another hard drive... not in raid, just an additional storage drive where some backup files will go.

They said they installed it... but now how to I find it in using the command line? What would it be called? How do I access and store things in the new drive?

Looking at the command line history, I see that when they installed it, they ran the following commands:
> fdisk /dev/hdc
> clear
> hostname
> exit
> ipconfig eth0
> fdisk /dev/hdc
> clear
> df -h


Thanks
John

marozsas 03-16-2006 06:47 AM

The command "fdisk -l" would print all partitions in all disks your system have.

Cross check this output with the output of "mount" which list all active partitions that are mounted and are in use in your system.

As a hint, a really new disk wouldn't have a partition table and it should be easier to find in the "fdisk -l" output.

cheers,

jvanv8 03-16-2006 08:18 AM

Thanks Marozsas,
I ran those two commands you mentioned:
Quote:

# fdisk -l
Disk /dev/sda: 73.3 GB, 73397698560 bytes
255 heads, 63 sectors/track, 8923 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 8669 69529320 83 Linux
/dev/sda3 8670 8923 2040255 82 Linux swap

Disk /dev/hdc: 82.3 GB, 82348277760 bytes
255 heads, 63 sectors/track, 10011 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/hdc doesn't contain a valid partition table


# mount
/dev/sda2 on / type ext3 (rw)
none on /proc type proc (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/sda1 on /boot type ext3 (rw)
none on /dev/shm type tmpfs (rw)
I'm guessing that dev/hdc is the new hard drive correct?
And is it bad that it says "Disk /dev/hdc doesn't contain a valid partition table"?
Do I need to configure this drive or something before I can use it?

Thanks for putting up with my newbie questions.
- John

marozsas 03-16-2006 08:45 AM

Yes. Looks like /dev/hdc is the new drive.
Nothing wrong with "doesn't contain a valid partition table". It is normal in a new disk.

How to you want to use this new disk ? It is a 80G disk. Do you want more than one partition, may be a 50GB and another 30G or all 80G in only one partition ?

What is the mount point for theses partitions ? "/disk1" and "/disk2" or all disk in "/export/backup"?

jvanv8 03-16-2006 01:25 PM

the only thing I want to do with the disk is store a backup or 2 of a database on it. The database is about 32 GB.
So can I store a file on this disk or browse the contents?
Being the newbie that I am, I tried:

# cd dev/hdc
-bash: cd: dev/hdc: Not a directory

So how exactly do you use (or is the term mount?) this new drive? I would like to just copy a handful of files from the original drive to the new one.

geeman2.0 03-16-2006 01:45 PM

/dev/hdc is the device itself, you need to create partitions on it.
Use "fdisk /dev/hdc" to create at least one partition.

Then you need to format the partition.
After this is done, you can then mount the partition to a directory.
This would be done by "mount /dev/hdc1 /mnt/point"
/dev/hdc1 refers to the first partition on /dev/hdc, and /dev/hdc2 would be the second if you create two, and so on.
/mnt/point would be the directory you want to mount the new partition to.
Once it's mounted, you can write to it by placing files in /mnt/point.

RobertP 03-16-2006 01:46 PM

fdisk /dev/hdc
Create your partition, perhaps one primary, Linux type
cat /proc/filesystems
Choose the filesystem that you like.
mkfs -t jfs /dev/hdc1
Change jfs to what you like. A journalling filesytem is more reliable.

mkdir somedirectory
mount /dev/hdc1 somedirectory

make somedirectory what you want, e.g. /home/you/backups/ or /root/backups
When you are done backing up, you may
umount /dev/hdc1
You can put a line in /etc/fstab, too, if you want the thing to mount at boot time.

jiml8 03-16-2006 01:53 PM

Actually, the partition creation could be bypassed if OP just wants to back up databases that are on the RAID. The new drive is big enough; the dd command could be used to image the RAID drive to the new drive.

This would be done simply as this:

dd if=/dev/sda of=/dev/hdc

Aside from copying the entire drive, this would also copy the partition table and the new drive would be defacto partitioned. It would also have some blank space at the end, which could be dealt with (if at all) at a later time.

marozsas 03-16-2006 02:02 PM

Ok. First, you need to create a 80G partition on your new disk.

Run fdisk on the target disk (I mean "fdisk /dev/hdc"), then the "o" command to create a empty partition table, and after that, the command "n" to create new primary partition, number 1, which starts at cylinder 1 and ends at last cylinder (use the default answers suggested by fdisk).
Use the "p" command to print the partition table and it looks fine, the "w" to write the partition table to the disk.

Run "fdisk -l /dev/hdc" to check the partition table is there, as you specified.

Now, you need to create a file system structure on /dev/hdc1.
Here there is a optional step you may want to know about. Searching for bad blocks, even in a new disk, is a good idea, specially if this disk will hold backup, important stuff, or in a production environment. If installing this disk is your job and you want to save your ass, search for badblocks on this disk. This is a time consuming operation. It will take several hours. I mean 20-30 hours !
{code]
# badblocks -sw -b 4096 -o /tmp/badblocks.hdc1 /dev/hdc1
[/code]

This command will make a write-read test with several patterns (0000, 1010, 0101, 1111) on every block of disk. A badblocks list (if any) will be created on /tmp/badblocks.hdc1. This list will be used in the next step.

Code:

# mkreiserfs -b 4096 -B /tmp/badblocks.hdc1 /dev/hdc1
Here, I choose to use a Reiser file system, rather than a most commum ext3 file system. The reason ? My experience says a reiser file system is more robust to rebuild the disk after a failure. I have lost less files in a reiser file system if compared to ext3. Your mileage may vary, of course :)

Finally, you just need to mount the disk.
Edit the /etc/fstab and add a entry for this new disk. Something like this:
Code:

/dev/hdc1            /backup                reiserfs  acl,user_xattr        1 2
Create the mount point and mount the disk
Code:

# mkdir /backup
# mount /backup
# df -lh /backup
Filesystem            Size  Used Avail Use% Mounted on
/dev/hdc1            80G  0M  80G  0% /backup

Wow, after that a need a beer ;)

good luck,

jvanv8 03-16-2006 05:35 PM

Wow, thanks Marozsas! If you ever write a Linux For Dummies book let me know and I'll buy a few copies.
Seems to be working fine and I am doing the disk check now (should be good I hope, its new).
I'll skip the beer step since I'm not a fan... even though I am now living in the Czech Republic which is suppose to have "good" beer. :)
Thanks again for helping me learn something!
- John

jvanv8 03-17-2006 04:44 AM

Hmmm, the badblock check finished fine (filesize of 0kb) but the mkreiserfs command wasn't found...
Looks like I either need to install it or try a different filesystem...
Since this seems like a different topic, I posted a new thread for this issue:
http://www.linuxquestions.org/questi...27#post2154727

Thanks

marozsas 03-17-2006 05:04 AM

Quote:

Hmmm, the badblock check finished fine (filesize of 0kb) but the mkreiserfs command wasn't found...
try mkfs.reiserfs....

jvanv8 03-17-2006 11:37 AM

Thanks Marozsas. I tried but...
Quote:

# mkfs.reiserfs -b 4096 -B /tmp/badblocks.hdc1 /dev/hdc1
-bash: mkfs.reiserfs: command not found
hmmm..

marozsas 03-17-2006 11:56 AM

You do not have the reiser tools installed.
Never mind. Use a ext3 filesystem.
Code:

# mke2fs -j /dev/hdc1
or
# mkfs.ext3 /dev/hdc1

The "-j" option to mke2fs creates a ext3 filesystem.
Since you told me your disk is badblocks free, you don't need any additional option.

You need to change the /etc/fstab entry. Change the 3rd column from reiserfs to ext3 and you are done.

see'ya


All times are GMT -5. The time now is 04:27 AM.