Установка дополнительного жесткого диска в CentOS

Итак. У нас есть установленная система CentOS 5.6 и есть желание поставить еще один диск на котором планируем размещать файлы ftp.
В ОС Linux разделы называются:
/dev/hda — это Primary Master
/dev/hdb — Primary Slave
/dev/hdc — Secondary Master
/dev/hdd — Secondary Slave
Первый раздел на Primary Master называется /dev/hda1, второй — /dev/hda2 и т.д.

Создаем в корне каталог hdd00. Суда мы будем монтировать наш новый диск.
# mkdir /hdd01

Набираем fdisk -l чтобы узнать что у нас есть.
[root@localhost ~]# fdisk -l

Disk /dev/hda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 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       30401   244091610   8e  Linux LVM

Disk /dev/hdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1   *           1           1           0    0  Empty
Partition 1 does not end on cylinder boundary.
[root@localhost ~]# 

Поключаемся к диску
[root@localhost ~]# fdisk /dev/hdc

The number of cylinders for this disk is set to 60801.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): help
h: unknown command
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Создаем новую партицию
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-60801, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801): 
Using default value 60801

Записываем изменения на диск
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost ~]#

Смотрим что получилось
[root@localhost ~]# fdisk -l

Disk /dev/hda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 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       30401   244091610   8e  Linux LVM

Disk /dev/hdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdc1               1       60801   488384001   83  Linux
[root@localhost ~]#

Создаем файловую систему ext3
[root@localhost ~]# mkfs.ext3 /dev/hdc1
mke2fs 1.39 (29-May-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
61063168 inodes, 122096000 blocks
6104800 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
3727 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]#

Примонтируем наш новый диск
[root@localhost /]# mount /dev/hdc1 /hdd00

Проверим на ошибки
[root@localhost /]# fsck /dev/hdc1
fsck 1.39 (29-May-2011)
e2fsck 1.39 (29-May-2011)
/dev/hdc1: clean, 12/61063168 files, 1966938/122096000 blocks
[root@localhost /]# 

Поверим правильность монтирования
Создадим файлик test в /hdd00/
[root@localhost /]#touch /hdd00/test

Посмотрим что есть в директории /hdd00
[root@localhost /]# ls /hdd00
lost+found  test 
[root@localhost /]# 

Отмонтируем диск и посмотрим еще раз.
[root@localhost /]# umount /dev/hdc1
umount: /dev/hdc1: not mounted
[1]+  Done                    umount /dev/hdc1
[root@localhost /]# ls /hdd00/
[root@localhost /]# 

Файлика нет. Он остался на на отмонтированном диске.
Монтируем его обратно
[root@localhost /]# mount /dev/hdc1 /hdd00

Добавим автоматическое монтирование жестких дисков при загрузке, отредактируем файл /etc/fstab
[root@localhost /]# vi etc/fstab

Добавим строку:
/dev/hdc1     /hdd00            ext3    defaults    0 0

Получилось:
[root@localhost /]# cat /etc/fstab 
/dev/VolGroup01/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup01/LogVol01 swap                    swap    defaults        0 0
/dev/hdc1               /hdd00                  ext3    defaults        0 0
[root@localhost /]# 


Ошибки:
если в системе присутствуют только одни sda и на hda нет не единого намека, то вам прямая дорого в bios.
comments powered by Disqus

2 комментария

avatar
Если нужно создать один раздел на весь диск, не нужно раздел создавать fdisk, можно просто сразу создать один раздел: mkfs.ext4 /dev/hdc1.
avatar
DISQUS УМЕР в 2021 году
копируем для истории

Оставить комментарий