手机站 | 电信站 | 联通站|联系电话:18925583550

Linux下添加新硬盘,分区及挂载

#####Linux下添加新硬盘,分区及挂载 
 
[root@cloud mnt]# cd /mnt
[root@cloud mnt]# mkdir data
[root@cloud mnt]# fdisk -l
###下面 /dev/sdb 就是需要新增加的硬盘
 
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00051f5f
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
 
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
 
Disk /dev/mapper/vg_cloud-lv_root: 8128 MB, 8128561152 bytes
255 heads, 63 sectors/track, 988 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
 
Disk /dev/mapper/vg_cloud-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
 
### 分区 
[root@cloud mnt]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab                                                                             el
Building a new DOS disklabel with disk identifier 0xf69edce2.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305):
Using default value 1305
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
 
 
 
### 检查分区
[root@cloud mnt]# fdisk -l
 
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00051f5f
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1306     9972736   8e  Linux LVM
 
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf69edce2
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1305    10482381   83  Linux
 
Disk /dev/mapper/vg_cloud-lv_root: 8128 MB, 8128561152 bytes
255 heads, 63 sectors/track, 988 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
 
Disk /dev/mapper/vg_cloud-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
 
### 格式化
 
[root@cloud mnt]# mkfs -t ext4 -c /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
æ–作系统:Linux¾=
å大å°=4096 (log=2)
分å大å°=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2620595 blocks
131029 blocks®å=000%) reserved for the super user
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
 
Checking for bad blocks (read-only test): 完æˆ
正在写入inode表: 完æˆ
Creating journal (32768 blocks): 完æˆ
Writing superblocks and filesystem accounting information: 完æˆ
 
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
 
 
### 重mount 加载点
 
[root@cloud mnt]# mount /mnt/data /dev/sdb1
mount: you must specify the filesystem type
[root@cloud mnt]# mount  /dev/sdb1 /mnt/data
[root@cloud mnt]# vi /etc/fstab
[root@cloud mnt]# df -TH
文件系统    ç±»åž‹      å®¹é‡  å·²ç”¨  å¯ç”¨ 已用%% 挂载点
/dev/mapper/vg_cloud-lv_root
              ext4     8.1G   3.8G   3.9G  50% /
tmpfs        tmpfs     254M    74k   254M   1% /dev/shm
/dev/sda1     ext4     508M    35M   447M   8% /boot
/dev/sdb1     ext3      11G   158M   9.9G   2% /mnt/data
[root@cloud mnt]#
[root@cloud mnt]# vi /etc/fstab
 
系统重启自动挂载该分区可修改/etc/fstab文件,在最后加一段 /dev/sdb1    /www    ext3    defaults 1 2 (格式说明:/dev/sdb1 代表哪个分区  ext3是该分区的格式 defaults 是挂载时所要设定的参数(只读,读写,启用quota等),输入defaults包括的参数有(rw、dev、exec、auto、nouser、async) ,1是使用dump是否要记录,0是不要。 2是开机时检查的顺序,是boot系统文件就为1,其他文件系统都为2,如不要检查就为0)
 
/dev/sdb1               /mnt/data               ext3    defaulte        1 2
 
 
 
 
 
分享到:

热门关注