如何給linux添加一塊硬碟 overview:添加一塊15G的硬碟 170 fdisk -l 列出所有硬碟 171 sudo pvcreate /dev/sdb ----------sdb為新添加的物理盤,準備供lvm使用 172 sudo vgcreate 12c /dev/sdb -------------------建立名為12c的卷組 174 sudo lvcreate -l 100%FREE -n 12clv 12c ----------------------------建立名為12lv的邏輯卷 175 sudo mkfs -t ext4 /dev/12c/12clv --------------------------建立檔案系統 176 sudo mkdir /12c ----------------------------建立掛載點 177 sudo vi /etc/fstab -------------------------設定掛載的選項,掛載點 178 sudo mount /12c -------------------------- 掛載這個檔案系統 eg:[root@localhost ~]# fdisk -lDisk /dev/sda: 14.3 GB, 14343061504 bytes255 heads, 63 sectors/track, 1743 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 1743 13896225 8e Linux LVMDisk /dev/sdb: 16.1 GB, 16106127360 bytes255 heads, 63 sectors/track, 1958 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk /dev/sdb doesn't contain a valid partition tableDisk /dev/dm-0: 13.1 GB, 13153337344 bytes255 heads, 63 sectors/track, 1599 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk /dev/dm-0 doesn't contain a valid partition tableDisk /dev/dm-1: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk /dev/dm-1 doesn't contain a valid partition table [root@localhost ~]# sudo pvcreate /dev/sdb Writing physical volume data to disk "/dev/sdb" Physical volume "/dev/sdb" successfully created [root@localhost ~]# sudo vgcreate 12c /dev/sdb Volume group "12c" successfully created [root@localhost ~]# sudo lvcreate -l 100%FREE -n 12clv Path required for Logical Volume "12clv" Please provide a volume group name Run `lvcreate --help' for more information. [root@localhost ~]# sudo lvcreate -l 100%FREE -n 12clv 12c Logical volume "12clv" created [root@localhost ~]# sudo mkfs -t ext4 /dev/12c/12clvmke4fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks983040 inodes, 3931136 blocks196556 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=4026531840120 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 22 mounts or180 days, whichever comes first. Use tune4fs -c or -i to override. [root@localhost ~]# sudo mkdir /12c [root@localhost ~]# sudo vi /etc/fstab/dev/VolGroup00/LogVol00 / ext3 defaults 1 1LABEL=/boot /boot ext3 defaults 1 2tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0/dev/VolGroup00/LogVol01 swap swap defaults 0 0/dev/12c/12clv /12c ext4 defaults 0 0~~ "/etc/fstab" 8L, 610C written [root@localhost ~]# sudo mount /12c [root@localhost ~]# cd /[root@localhost /]# lltotal 166drwxr-xr-x 3 root root 4096 Jun 26 07:26 12cdrwxr-xr-x 3 root root 4096 Jun 20 00:04 bindrwxr-xr-x 4 root root 1024 Jun 19 10:34 bootdrwxr-xr-x 13 root root 3900 Jun 26 07:25 devdrwxr-xr-x 98 root root 12288 Jun 26 07:30 etcdrwxr-xr-x 4 root root 4096 Jun 26 06:29 homedrwxr-xr-x 11 root root 4096 Jun 20 00:04 libdrwxr-xr-x 9 root root 4096 Jun 20 00:04 lib64drwx------ 2 root root 16384 Jun 19 10:23 lost+founddrwxr-xr-x 3 root root 4096 Jun 26 07:18 mediadrwxr-xr-x 2 root root 0 Jun 26 07:18 miscdrwxr-xr-x 2 root root 4096 Feb 16 2010 mntdrwxr-xr-x 2 root root 0 Jun 26 07:18 netdrwxr-xr-x 2 root root 4096 Feb 16 2010 optdr-xr-xr-x 123 root root 0 Jun 26 07:17 procdrwxr-x--- 15 root root 4096 Jun 26 06:46 rootdrwxr-xr-x 2 root root 12288 Jun 20 00:04 sbindrwxr-xr-x 2 root root 4096 Jun 19 10:23 selinuxdrwxr-xr-x 2 root root 4096 Feb 16 2010 srvdrwxr-xr-x 13 root root 0 Jun 26 07:17 sysdrwxr-xr-x 3 root root 4096 Jun 19 10:31 tftpbootdrwxrwxrwt 8 root root 4096 Jun 26 07:19 tmpdrwxr-xr-x 15 root root 4096 Jun 19 10:26 usrdrwxr-xr-x 21 root root 4096 Jun 19 10:37 var [root@localhost /]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol00 12G 8.7G 2.6G 78% //dev/sda1 99M 24M 71M 25% /boottmpfs 244M 0 244M 0% /dev/shm/dev/mapper/12c-12clv 15G 166M 14G 2% /12c [root@localhost /]# cd /12c [root@localhost 12c]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol00 12G 8.7G 2.6G 78% //dev/sda1 99M 24M 71M 25% /boottmpfs 244M 0 244M 0% /dev/shm/dev/mapper/12c-12clv 15G 166M 14G 2% /12c[root@localhost 12c]#到此成功添加一塊硬碟,並建立檔案系統