Linux Hard disk operation

前期处理IDE 硬盘处理硬盘标记   设备文件IDE 0:0      /dev/hda
IDE 0:1      /dev/hdb
IDE 1:0      /dev/hdc
IDE 1:1      /dev/hdd
SCSI 硬盘处理(需要逐个安装)1. 检查scsi_host:ls /sys/class/scsi_host根据结果修改下条命令中的“host#”2. 输入命令搜索硬盘:echo "- - -" > /sys/class/scsi_host/host#/scan
3. 查看是否找到新建硬盘:fdisk -l硬盘标记  设备文件SCSI 0:0   /dev/sda
SCSI 0:1   /dev/sdb
 ....
最多可以添加60个硬盘

If after fdisk, you can not find the block file create in /dev folder.
Solution: 
1. Restart the server
2. System automatically check: start_udev
3. Manually create: mkmod command
Example: mkmod /dev/sda4 b 8 4

If the disk is over 2T, need to use "parted" command to operate the disk
parted <partition>
print: list the information of partition
help: help about the command
mkpart: create partition
mklable: create label
mkpartfs: create partition and file system

硬盘-->文件系统:

1. 直接处理挂载a. 硬盘划分处理:fdisk /dev/hdd
新建:n
主分区:p(可建四个。如果建四个,则无法建扩展分区)
扩展分区:e(首先需要将剩余的空间创建为扩展,再细分)
查询划分情况:p
保存所有修改:w
取消所有修改:q
b. 硬盘划分查询:fdisk -l /dev/hdd
c. 格式化硬盘分区:mkfs.ext3 /dev/hdd
d. 通知kernelpartprobe
e.挂载文件系统:mount+设备文件+挂载点
例如:mount /dev/hdd /mnt/d

后续:a. 取消挂载文件系统:umount+挂载点
例如:umount /mnt/a

2. 建立LVM再挂载:a. 创建physical volumn:pvcreate+硬盘分区
例如:pvcreate /dev/hdd
b. 创建volumn group:vgcreate+vg名字+硬盘分区
例如:vgcreate testvg /dev/hdd
c. 扩展volumn group: vgextend+vg名字+硬盘分区
例如:vgextend testvg /dev/hdb
d. 创建logical volumn:lvcreate+大小+lv名字+vg名字
例如:lvcreate -L 10g -n testlv testvg
e. 扩展logical volumn:lvextend+扩展大小+lv名字
例如:lvextend -L +1g /dev/testvg/testlv
如果lv已经挂载,需要:resize2fs+lv名字
例如:resize2fs /dev/testvg/testlv
f. 挂载文件系统mount+lv名字+挂载点
例如:mount /dev/testvg/testlv /mnt/b

后续:a. 取消挂载文件系统:umount+挂载点
例如:umount /mnt/a
b. 删除logical volumn:lvremove+lv名字
例如:lvremove /dev/testvg/testlv
c. 删除volumn group:vgremove+vg名字
例如:vgremove testvg
d. 删除physical volumn:pvremove+pv名字
例如:pvremove /dev/hdd

Additional1. check the hard disk partition information: dumpe2fs <partition>
2. system config file
/boot/grub/grub.conf --> load root partition read only
/etc/fstab --> load all partition

Comments

Popular posts from this blog

Nginx Proxy & Load Balance & LNMP

Snort+barnyard2+Snorby CentOS 6.5_64 Installation

ORACLE Error