文章目錄

在简化的linux系统中新加的硬盘不会被识别,要手动进行不些设置才能够使用,下面记录下设置方法。
当你添加一块新硬盘后使用fdisk -l查看

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Disk /dev/sda: 31.5 GB, 31457280000 bytes
255 heads, 63 sectors/track, 3824 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: 0x000e00a8


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 1045 7875584 8e Linux LVM

/dev/sda3 1045 3824 22327672 83 Linux

Disk /dev/sdb: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 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/sdb doesn't contain a valid partition table

Disk /dev/sdb这个就是我新加的硬盘,它后面会显示doesn’t contain a valid partition table错误,因为该盘尚未分区和挂载。
然后用fdisk /dev/sdb命令来进行分区,

1.输入n 创建一个新分区
2.输入p 代表主分区
3.输入1 表示1块
4.后面是大小,可以回车用默认的
5.输入w 保存

这时候用fdisk -l就能看见新的分区了

1
2
3
4
5
6
7
8
9
Disk /dev/sdb: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 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: 0xd06cae49


Device Boot Start End Blocks Id System
/dev/sdb1 1 16709 134215011 83 Linux

分区之后开始格式化 mkfs -t ext3 /dev/sdb1
格式化之后我们需要把该盘挂载到一个目录下面,mount /dev/sdb1 /work
挂载之后修改/etc/fstab文件完成开机自动挂载,即在文件中添加
/dev/sdb1 /work ext3 defaults 1 2

但是这块盘现在只有root用户有写权限,如果要让其他用户也可以读写则需要修改权限,
chown -R user: /work改变所属者或者chmod -R 777 /work所有用户可读写

这样用着可能也不是很方便,因为你工作时需要使用新的目录/work,这时可以使用ln -s命令把新的硬盘目录软连接到你想放在的目录里面,
例如ln -s /work /home/xxx,这样就可以在自己熟悉的地方使用新的硬盘了

文章目錄