LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-22-2009, 04:28 PM   #1
dj32
LQ Newbie
 
Registered: Dec 2009
Posts: 16

Rep: Reputation: 0
Linux Debian 2 hard drives question.


Hello i have one server with 2 hard drives and i want to know how to browse each one of them at a time,i mean how i use cd /home/blabla something like that,and switch to the other hard drive.I want to use the first drive for running my gameserver and the second for installing and running only the database of the server.Thank you
 
Old 12-22-2009, 05:41 PM   #2
r0m23
LQ Newbie
 
Registered: Aug 2007
Posts: 9

Rep: Reputation: 1
Hi, it sounds like you need to know how to mount a drive within your filesystem. You can find out how to do this by typing
Code:
$ man mount
However, what will be most helpful is learning how to use the /etc/fstab file to mount all of your filesystems automatically at boot time. You can get started by looking at
Code:
$ man fstab
I assume you are more or less brand new to Linux, but relatively adept at Windows. Sorry if this is a bit pedantic.

In Windows, every physical device appears as a separate entity, as does each partition on devices that have more than one. (Drives A:-Z: ) In Unix-like operating systems, each disk partition is identified by a combination of drive name and partition number. Debain, like most GNU/Linux systems, uses the following scheme: (s,h)d(a-z)(1-9). Looks confusing, but it's pretty simple: Your primary hard drive will be called sda if it's a serial (ie, SATA) device or hda if it's an older IDE device. Devices like optical drives and USB disks are named similarly, but not exactly the same.

After the disk identifier, each volume name will be appended with the partition number in question. My own desktop machine has two drives, hda and sda. I have partitions hda1, hda2, hda5-hda9 and sda1, sda2 and sda5-sda7. The numbers should correspond to the native partition numbers as Debian sees them. Note that your partitions may not be numbered contiguously, depending on how your drives are partitioned. The Gnome Disks utility will give you a simple overview of each drive layout; KDE and other window managers have similar utilities. The program Gparted will give you a more detailed view, but be careful with it. On the other hand, it can be just as informative and easier to use the terminal:
Code:
# fdisk -l
will present you with a nice table of partitions very quickly. (Like Gparted, be very careful with the fdisk command; also use the sudo command whenever possible, rather than logging in as root -- the # prompt may appear to suggest you should actually log in as root, but it is commonly understood as shorthand for '$ sudo [command]'. See the manpages for sudo and sudoers for more information.)

Note that there is a different scheme called UUID, which uses long hexadecimal numbers to identify each volume. I don't believe Debian stable will use UUIDs out of the box, but recent Ubuntu versions can use either scheme. Just something to be aware of.

Based on the information you gave, I suspect your layout will look something like this: sda, which is probably subdivided into multiple partitions; and sdb, which might be one large partition, or might contain multiple partitions as well.

Now that you know how to identify your disk partitions, you need to understand how the filesystem sees them. Unlike the discrete volumes found in Windows, Unix-like OSes organize every volume into one big filesystem. For example, your sda1 partition probably holds your root (/) filesystem, sda2 might hold /var, sda3 might hold /usr and sdb1 might hold /home. When you look at the file hierarchy, the fact that different directories reside on different volumes is hidden from you. It may be a headache now, but it will become very convenient as you become familiar with it.

I'm going to assume you understand how to use the mount command with a basic level of expertise. mount assigns each partition on your disks to a directory in the filesystem, whereas the fstab file tells the kernel where to look for each filesystem automatically so you will only need to use the mount command rarely. Debian organizes all of its volumes as files under /dev, but you can't cd or cp directly into them -- they will appear as special files rather than directories. Your hard drive partitions will be known as /dev/sda1-/dev/sdax and /dev/sdb1-/dev/sdbx. All of the filesystems that are essential for system operation should already be defined in fstab. What you need to do now is a) create a diretory and an fstab entry for any partitions on sda that you want access to, then b) create directories and fstab entries for any partitions on sdb you want access to.

This magical file resides at /etc/fstab. You must edit it as root, so use the command
Code:
# edit /etc/fstab
where you may replace 'edit' with your favorite text editor -- Gnome's GUI text editor is called gedit, while KDE features kedit. Most Linux systems will also feature some or all of the other popular terminal based editors. Conveniently, your Debian install probably has assigned one of the simpler, more intuitive editors to an environment variable that 'edit' stands in for. In other words, you can issue the 'edit' command with little regard for what program will actually be doing the work. Here is my laptop's fstab:
Code:
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda2       /               ext3    errors=remount-ro 0       1
/dev/hda6       /home           ext3    defaults        0       2
/dev/hda5       none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0
The first 2 columns of each line do exactly what mount does: assigns a device file (/dev/hda2) to a mount point in the filesystem (/). The third column defines the filesystem type. You will probably be using ext3 for all of your data filesystems, but remember that any swap partitions have their own filesystem type. Make sure you know what type of filesystem is used for each volume before you save your /etc/fstab. The options column can safely be set to 'defaults' for any data partitions. The fifth column defines how often each filesystem will be 'dumped'. I hate to encourage ignorance, but I have been using Linux for 3 years without knowing anything about filesystem dumping. Use a 0 here. The sixth column tells the init scripts in which order to check each filesystem for errors. The root filesystem should already be assigned a value of 1; any other partitions that should be checked will be labeled 2. Partitions that do not need to be checked should be labeled 0. In other words, any filesystems in your fstab should keep the default value already assigned. For filesystems you add to fstab yourself, you will need to decide whether they will need to be checked for errors on startup; assign a 2 if so, or a 0 if not.

As a practical matter, you will probably want to mount all of your data partitions under /home. If this is a single-user machine, create directories such as /home/username/music, /home/username/www and /home/username/video. If it is a multiple-user machine, create the directories you want directly under /home, then make sure each directory has the proper permissions for each authorized user to access it. Remember that you are assigning entire filesystems to each of these directories. It is possible to assign sub-sections of a filesystem to a given directory, but the syntax is a bit different.

Now that you have entered values for each of the filesystems you want to mount automatically, you will need to save /etc/fstab and then reload it. To relaod fstab, you can either reboot or use the following command:
Code:
# mount -a
which will run through /etc/fstab and mount or re-mount every filesystem defined there. That should be enough to get you started. Be prepared to have some headaches with file permissions either immediately or down the road -- the next thing you'll probbaly want to learn is how the permissions of the target directories can affect the level of access each user has to each filesystem.

Last edited by r0m23; 12-22-2009 at 08:26 PM. Reason: added more details
 
1 members found this post helpful.
Old 12-23-2009, 01:15 AM   #3
dj32
LQ Newbie
 
Registered: Dec 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Thank you very much for your reply,I used fdisk -l command and it gave me this output.Can you tell me please if this guide i found is also good http://linux.justinhartman.com/Insta...ond_hard_drive ,and if it is safe to partition sdb ?because i don't know if it contains anything.And what about the /dev/md0 /dev/md1 /dev/md2 ?wha are these things?And operating system and all things are in sda hard disk ?Because i need sdb emty,to partision it,and format it.Thank you

root:~# fdisk -l

Disk /dev/sda: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000750e8

Device Boot Start End Blocks Id System
/dev/sda1 1 523 4200966 fd Linux raid autodetect
/dev/sda2 524 785 2104515 fd Linux raid autodetect
/dev/sda3 786 91201 726266520 fd Linux raid autodetect

Disk /dev/sdb: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000d1d9f

Device Boot Start End Blocks Id System
/dev/sdb1 1 523 4200966 fd Linux raid autodetect
/dev/sdb2 524 785 2104515 fd Linux raid autodetect
/dev/sdb3 786 91201 726266520 fd Linux raid autodetect

Disk /dev/md0: 4301 MB, 4301717504 bytes
2 heads, 4 sectors/track, 1050224 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk identifier: 0x00000000

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

Disk /dev/md1: 2154 MB, 2154954752 bytes
2 heads, 4 sectors/track, 526112 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk identifier: 0x00000000

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

Disk /dev/md2: 743.6 GB, 743696826368 bytes
2 heads, 4 sectors/track, 181566608 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk identifier: 0x00000000

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

Last edited by dj32; 12-23-2009 at 01:21 AM.
 
Old 12-23-2009, 02:11 AM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
The md devices are software RAID. It looks like the partitions on both of your drives are used in some sort of RAID set-up. If you post the output of "cat /proc/mdstat" we should be able to see how exactly the RAID is configured. If it's RAID-1, it might be possible to break up the RAID to use the second hard drive separately, othgerwise it seems likely that you'll need to repartition.
 
Old 12-23-2009, 02:21 AM   #5
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
If there is nothing useful on either drive, do this:

dd if=/dev/zero of=/dev/sda bs=4k count=10000
dd if=/dev/zero of=/dev/sdb bs=4k count=10000

To zero out the partition tables and boot sectors on the two hard drives.

then do:

parted
parted) select /dev/sda
parted) mklabel msdos
parted) mkpart p ext3 0 <end>
parted) select /dev/sdb
parted) mklabel msdos
parted) mkpart p ext3 0 <end>
parted) q

mkfs.ext3 /dev/sda1
mkfs.ext3 /dev/sdb1

Or you can use the linux installer to partition and format the drives. But you shouldn't use an old installation that used RAID.

Once you have linux installed:

mkdir /mnt/server
mount /dev/sdb1 /mnt/server
 
Old 12-23-2009, 03:34 AM   #6
dj32
LQ Newbie
 
Registered: Dec 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Okay i tried the cat /proc/mdstat command as you told me and it gives me this output.

root:~# cat /proc/mdstat
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md2 : active raid1 sda3[0] sdb3[1]
726266432 blocks [2/2] [UU]

md1 : active raid1 sda2[0] sdb2[1]
2104448 blocks [2/2] [UU]

md0 : active (auto-read-only) raid1 sda1[0] sdb1[1]
4200896 blocks [2/2] [UU]




I also tried this command cat /proc/partitions and it gave me this output.

root:~# cat /proc/partitions
major minor #blocks name

8 0 732574584 sda
8 1 4200966 sda1
8 2 2104515 sda2
8 3 726266520 sda3
8 16 732574584 sdb
8 17 4200966 sdb1
8 18 2104515 sdb2
8 19 726266520 sdb3
9 0 4200896 md0
9 1 2104448 md1
9 2 726266432 md2


unused devices: <none>


I also used this command df -h and gave me this output


root:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md2 688G 550M 652G 1% /
tmpfs 4.0G 0 4.0G 0% /lib/init/rw
udev 10M 772K 9.3M 8% /dev
tmpfs 4.0G 0 4.0G 0% /dev/shm
/dev/md1 2.0G 79M 1.9G 5% /boot

Last edited by dj32; 12-23-2009 at 03:57 AM.
 
Old 12-23-2009, 09:17 AM   #7
dj32
LQ Newbie
 
Registered: Dec 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Okay i found the solution myself,Thanks for your kind replies Merry Christmas
 
  


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
Combining hard drives from two linux (debian) installations sticmann Linux - General 7 05-29-2009 09:59 AM
Problems in detecting hard drives for debian linux 64bit utrivedi Linux - Hardware 1 07-31-2008 11:30 AM
Linux and Hard drives question Gortex Linux - Newbie 1 11-28-2005 08:18 PM
Debian install with 2 Hard Drives AndeAnderson Linux - Newbie 3 04-04-2005 09:24 AM
Debian not detecting my hard drives. brynjarh Debian 2 10-21-2004 07:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:59 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