添加新硬盘

原本的一块硬盘是sda,新加了一块硬盘为sdb

查看新硬盘
[root@jin dev]# fdisk -l

Disk /dev/sda: 136.4 GB, 136365211648 bytes
255 heads, 63 sectors/track, 16578 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000d203d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        6400    51200000   83  Linux
/dev/sda3            6400       12774    51200000   83  Linux
/dev/sda4           12774       16579    30563328    5  Extended
/dev/sda5           12774       13029     2048000   82  Linux swap / Solaris
/dev/sda6           13030       16579    28513280   83  Linux

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
分区
[root@jin dev]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xf0f50ac9.
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)

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

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').
# n 新建分区
Command (m for help): n
# 选择分区类型
Command action
   e   extended
   p   primary partition (1-4)
p
# 分区数字编号
Partition number (1-4): 1
# 开始柱面
First cylinder (1-130, default 1):  
Using default value 1
# 结束柱面,直接写"+存储容量"也行
Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +10M
# 打印当前磁盘分区就能看到了
Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x752ab7eb

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1           2       16032+  83  Linux
# 下面这个不用管
Partition 1 does not end on cylinder boundary.
Partition 1 does not start on physical sector boundary.
# w写入,如果没有这一步的话,刚刚的操作无效
Command (m for help): w    
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
格式化分区

如果系统版本较老(centOS 5或之前的版本需先运行partprobe命令)

[root@jin dev]# mkfs.ext4 /dev/sdb1 
mke2fs 1.41.12 (17-May-2010)
/dev/sdb1 alignment is offset by 512 bytes.
This may result in very poor performance, (re)-partitioning suggested.
Discarding device blocks: 完成                            
文件系统标签=
操作系统:Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=4 blocks, Stripe width=0 blocks
4016 inodes, 16032 blocks
801 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=16515072
2 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks: 
    8193

正在写入inode表: 完成                            
Creating journal (1024 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
挂载
[root@jin ~]# mount /dev/sdb1 testDir
配置启动加载
查看磁盘 UUID

dumpe2fs 1.41.12 (17-May-2010) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: 5634cbae-e0fa-4d12-9ae2-031c5cbda12d ...
编辑vim /etc/fstab文件
UUID=7cfd829d-d09b-4efd-bc9b-5ac19100c25f /                       ext4    defaults        1 1 
UUID=39eac6d2-0188-4a1f-a795-5564bc7c2187 /boot                   ext4    defaults        1 2 
UUID=e5f913f4-97d2-4a0d-92a8-e95bb59be591 /home                   ext4    defaults        1 2 
UUID=b37cd8cf-392a-4587-83ad-6ea0be1c4a11 /var                    ext4    defaults        1 2 
UUID=e3cdd9d3-3281-416d-bfed-0f3c0c3671a0 swap                    swap    defaults        0 0 
# 新添加的一行,分别是,设备UUID,所要挂载到文件,挂载选项(man mount搜索defaults可以查看),dump备份时的时间周期设置,开机检测文件系统的顺序
UUID=5634cbae-e0fa-4d12-9ae2-031c5cbda12d /root/testDir           ext4    defaults        0 1 
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

标签: linux

添加新评论