четверг, 8 августа 2013 г.

CentOS работа с дисками (монтирование и прочее)

Итак. У нас есть установленная система CentOS и есть желание поставить еще один диск.




В ОС Linux разделы называются:
/dev/hda — это Primary Master
/dev/hdb — Primary Slave
/dev/hdc — Secondary Master
/dev/hdd — Secondary Slave
Первый раздел на Primary Master называется /dev/hda1, второй — /dev/hda2 и т.д.
Создаем в корне каталог hdd00. Суда мы будем монтировать наш новый диск.
1mkdir /hdd01
Набираем fdisk -l чтобы узнать что у нас есть.
1[root@localhost ~]# fdisk -l
2
3Disk /dev/hda: 250.0 GB, 250059350016 bytes
4255 heads, 63 sectors/track, 30401 cylinders
5Units = cylinders of 16065 * 512 = 8225280 bytes
6
7Device Boot Start End Blocks Id System
8/dev/hda1 * 1 13 104391 83 Linux
9/dev/hda2 14 30401 244091610 8e Linux LVM
10
11Disk /dev/hdc: 500.1 GB, 500107862016 bytes
12255 heads, 63 sectors/track, 60801 cylinders
13Units = cylinders of 16065 * 512 = 8225280 bytes
14Device Boot Start End Blocks Id System
15/dev/hdc1 * 1 1 0 0 Empty
16Partition 1 does not end on cylinder boundary.
17[root@localhost ~]#
Подключаемся к диску
1[root@localhost ~]# fdisk /dev/hdc
2
3The number of cylinders for this disk is set to 60801.
4There is nothing wrong with that, but this is larger than 1024,
5and could in certain setups cause problems with:
61) software that runs at boot time (e.g., old versions of LILO)
72) booting and partitioning software from other OSs
8(e.g., DOS FDISK, OS/2 FDISK)
9Command (m for help): help
10h: unknown command
11Command action
12a toggle a bootable flag
13b edit bsd disklabel
14c toggle the dos compatibility flag
15d delete a partition
16l list known partition types
17m print this menu
18n add a new partition
19o create a new empty DOS partition table
20p print the partition table
21q quit without saving changes
22s create a new empty Sun disklabel
23t change a partition's system id
24u change display/entry units
25v verify the partition table
26w write table to disk and exit
27x extra functionality (experts only)
Создаем новую партицию
1Command (m for help): n
2Command action
3e extended
4p primary partition (1-4)
5p
6Partition number (1-4): 1
7First cylinder (1-60801, default 1):
8Using default value 1
9Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801):
10Using default value 60801
Записываем изменения на диск
1Command (m for help): w
2The partition table has been altered!
3
4Calling ioctl() to re-read partition table.
5WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
6The kernel still uses the old table.
7The new table will be used at the next reboot.
8Syncing disks.
9[root@localhost ~]#
Смотрим что получилось
1[root@localhost ~]# fdisk -l
2
3Disk /dev/hda: 250.0 GB, 250059350016 bytes
4255 heads, 63 sectors/track, 30401 cylinders
5Units = cylinders of 16065 * 512 = 8225280 bytes
6
7Device Boot Start End Blocks Id System
8/dev/hda1 * 1 13 104391 83 Linux
9/dev/hda2 14 30401 244091610 8e Linux LVM
10
11Disk /dev/hdc: 500.1 GB, 500107862016 bytes
12255 heads, 63 sectors/track, 60801 cylinders
13Units = cylinders of 16065 * 512 = 8225280 bytes
14Device Boot Start End Blocks Id System
15/dev/hdc1 1 60801 488384001 83 Linux
16[root@localhost ~]#
Создаем файловую систему ext3
1[root@localhost ~]# mkfs.ext3 /dev/hdc1
2mke2fs 1.39 (29-May-2006)
3Filesystem label=
4OS type: Linux
5Block size=4096 (log=2)
6Fragment size=4096 (log=2)
761063168 inodes, 122096000 blocks
86104800 blocks (5.00%) reserved for the super user
9First data block=0
10Maximum filesystem blocks=4294967296
113727 block groups
1232768 blocks per group, 32768 fragments per group
1316384 inodes per group
14Superblock backups stored on blocks:
1532768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
164096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
17102400000
18
19Writing inode tables: done
20Creating journal (32768 blocks): done
21Writing superblocks and filesystem accounting information: done
22This filesystem will be automatically checked every 31 mounts or
23180 days, whichever comes first. Use tune2fs -c or -i to override.
24[root@localhost ~]#
При монтируем наш новый диск
1[root@localhost /]# mount /dev/hdc1 /hdd00
Проверим на ошибки
1[root@localhost /]# fsck /dev/hdc1
2fsck 1.39 (29-May-2006)
3e2fsck 1.39 (29-May-2006)
4/dev/hdc1: clean, 12/61063168 files, 1966938/122096000 blocks
5[root@localhost /]#
Поверим правильность монтирования
Создадим файлик test в /hdd00/
1[root@localhost /]#touch /hdd00/test
Посмотрим что есть в директории /hdd00
1[root@localhost /]# ls /hdd00
2lost+found test
3[root@localhost /]#
От монтируем диск и посмотрим еще раз.
1[root@localhost /]# umount /dev/hdc1
2umount: /dev/hdc1: not mounted
3[1]+ Done umount /dev/hdc1
4[root@localhost /]# ls /hdd00/
5[root@localhost /]#
Файлика нет ))) он остался на на отмонтированном диске.
Монтируем его обратно
1[root@localhost /]# mount /dev/hdc1 /hdd00
Добавим автоматическое монтирование жестких дисков при загрузке, отредактируем файл /etc/fstab
1[root@localhost /]# vi etc/fstab
Добавим строку:
1/dev/hdc1 /hdd00 ext3 defaults 0 0


















Комментариев нет:

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