[root@localhost ~]# fdisk -l //查看磁盘,发现有一个不能识别的磁盘
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1288 10241437+ 83 Linux
/dev/sda3 1289 1415 1020127+ 82 Linux swap / Solaris
/dev/sda4 1416 2610 9598837+ 5 Extended
/dev/sda5 1416 2610 9598806 83 Linux
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
[root@localhost ~]# fdisk /dev/sdb //对新磁盘进行分区操作
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. 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)
Command (m for help): m //输入m查看帮助
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n //输入n新增一个分区
Command action
e extended
p primary partition (1-4)
p //输入p新增一个主分区
Partition number (1-4): 1 //输入分区数为1
First cylinder (1-261, default 1): //输入新增分区的第一个磁柱号码
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): //输入新分区的结束磁柱号码
Using default value 261
Command (m for help): p //输入p查看分区
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 83 Linux
Command (m for help): w //输入w将分区信息写入磁盘并退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# fdisk -l //再次查看分区信息,新磁盘已经可以识别了
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1288 10241437+ 83 Linux
/dev/sda3 1289 1415 1020127+ 82 Linux swap / Solaris
/dev/sda4 1416 2610 9598837+ 5 Extended
/dev/sda5 1416 2610 9598806 83 Linux
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 83 Linux
[root@localhost ~]# mkfs.ext3 /dev/sdb1 //对新磁盘进行格式化操作,并格式化为ext3
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524112 blocks
26205 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]# df //查看磁盘,新磁盘还没有被挂载
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda2 9920624 1110888 8297668 12% /
/dev/sda5 9297996 152296 8665760 2% /home
/dev/sda1 101086 11534 84333 13% /boot
tmpfs 517552 0 517552 0% /dev/shm
[root@localhost ~]# mkdir /hdd //新建一个文件夹用于挂载磁盘
[root@localhost ~]# mount /dev/sdb1 /hdd //将磁盘挂载到新建的文件夹下
[root@localhost ~]# df //查看磁盘,新盘已经可以使用了
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda2 9920624 1110892 8297664 12% /
/dev/sda5 9297996 152296 8665760 2% /home
/dev/sda1 101086 11534 84333 13% /boot
tmpfs 517552 0 517552 0% /dev/shm
/dev/sdb1 2063504 35880 1922804 2% /hdd
[root@localhost ~]# mkdir /hdd/new
[root@localhost ~]# ls /hdd
lost+found new
[root@localhost ~]# nano /etc/fstab //编辑这个文件,使新磁盘实现开机挂载
[root@localhost ~]# cat /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/home /home ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
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
LABEL=SWAP-sda3 swap swap defaults 0 0
/dev/sdb1 /hdd ext3 defaults 0 0
[root@localhost ~]# shutdown -r now //重启系统。完成操作